Routine infrastructure

This commit is contained in:
Aaron Cook 2025-08-31 22:03:41 -05:00
commit 17b3f0a89f
11 changed files with 527 additions and 30 deletions

22
includes/ble.h Normal file
View file

@ -0,0 +1,22 @@
#ifndef _INCLUDES_BLE_H_
#define _INCLUDES_BLE_H_
#include <stdint.h>
/**
* @brief Register a callback to occur when a new complete input is sent
*/
void ble_register_oninput_callback(void (*callback)(const void *buffer, uint16_t buffer_len));
/**
* @brief Clear the on-input callback registered with
* ble_register_oninput_callback
*/
void ble_clear_oninput_callback(void);
/**
* @brief Set a new value for telemetry data
*/
void ble_set_telemetry_data(const void *buffer, uint16_t buffer_len);
#endif /* _INCLUDES_BLE_H_ */

47
includes/routine.h Normal file
View file

@ -0,0 +1,47 @@
#ifndef _INCLUDES_ROUTINE_H_
#define _INCLUDES_ROUTINE_H_
#include <stdint.h>
typedef enum routine_return_enum {
/** Routine executed successfully */
ROUTINE_RETURN_SUCCESS = 0,
/** Generic error occured during routine */
ROUTINE_RETURN_FAILURE,
} routine_return_e;
typedef routine_return_e (*routine_t)(void);
typedef struct routine_listing_struct {
/** Method that will be called to enter the routine */
routine_t entry;
/** Name that will be listed for the routine */
const char *name;
} routine_listing_t;
typedef enum routine_status_enum {
/** no routine is currently running */
ROUTINE_STATUS_STOPPED = 0,
/** a routine is running */
ROUTINE_STATUS_RUNNING,
/** a routine is running but has been requested to stop*/
ROUTINE_STATUS_STOPPING,
} routine_status_e;
/**
* @brief Get the current routine status
*/
routine_status_e routine_status(void);
/**
* @brief Delay the routine for the specified number of milliseconds
*/
void routine_delay(uint32_t milliseconds);
/**
* @brief Function that a routine should call while running in a loop to allow
* for the rest of the system to properly execute
*/
void routine_yield(void);
#endif /* _INCLUDE_ROUTINE_H_ */