openrcore/includes/routine.h
2025-09-08 15:42:26 -05:00

47 lines
1.2 KiB
C

#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_ */