ruuvi.drivers.c
${PROJECT_VERSION}
Drivers for external sensors and peripherals on embedded systems.
|
Files | |
file | ruuvi_interface_scheduler_test.h |
Test interface functions to scheduler. | |
file | ruuvi_interface_scheduler.h |
Interface functions to scheduler. | |
Typedefs | |
typedef void(* | ruuvi_scheduler_event_handler_t) (void *p_event_data, uint16_t event_size) |
Type definition for scheduler event handler. More... | |
Functions | |
bool | ri_scheduler_run_integration_test (const rd_test_print_fp printfp) |
Run all scheduler integration tests. More... | |
rd_status_t | ri_scheduler_init (void) |
Enable implementation selected by application. More... | |
rd_status_t | ri_scheduler_execute (void) |
Executes all scheduled tasks. More... | |
rd_status_t | ri_scheduler_event_put (const void *const p_event_data, const uint16_t event_size, const ruuvi_scheduler_event_handler_t handler) |
Schedule given task to be executed on next call to ri_scheduler_execute. More... | |
rd_status_t | ri_scheduler_uninit (void) |
Uninitialize scheduler. More... | |
bool | ri_scheduler_is_init (void) |
Check if scheduler is initialized. More... | |
typedef void(* ruuvi_scheduler_event_handler_t) (void *p_event_data, uint16_t event_size) |
Type definition for scheduler event handler.
[in] | p_event_data | Data for the event handler. |
[in] | event_size | Size of the event data. Must be smaller than or equal to max_event_size. |
Definition at line 48 of file ruuvi_interface_scheduler.h.
rd_status_t ri_scheduler_event_put | ( | const void *const | p_event_data, |
const uint16_t | event_size, | ||
const ruuvi_scheduler_event_handler_t | handler | ||
) |
Schedule given task to be executed on next call to ri_scheduler_execute.
[in] | p_event_data | Context for the scheduled event, will be stored to scheduler queue. Use NULL if there is no context for the task. |
[in] | event_size | Size of context in bytes. Use 0 if there is no context for the task. |
[in] | handler | Function to handle the event. Must not be NULL |
RD_SUCCESS | on success. |
RD_ERROR_NULL | if handler is NULL |
RD_ERROR_INVALID_LENGTH | if event data is larger than task queue event size. |
RD_ERROR_NO_MEM | if the task cannot be added to queue due to queue full. |
rd_status_t ri_scheduler_execute | ( | void | ) |
Executes all scheduled tasks.
If task schedules itself to be run immediately this will be run in a never-ending loop, without sleeping.
RD_SUCCESS | if queue was executed successfully. |
error | code from the stack if error occurs. |
rd_status_t ri_scheduler_init | ( | void | ) |
Enable implementation selected by application.
Initialize scheduler.
Allocates memory for scheduler task queue. Because memory allocation is static, the size has to be defined in macors RI_SCHEDULER_SIZE and RI_SCHEDULER_LENGTH. The RI_SCHEDULER_SIZE defines maximum size of scheduler event and RI_SCHEDULER_LENGTH defines maximum number of events that can be queued.
RD_SUCCESS | on success. |
error | code from stack on error. |
bool ri_scheduler_is_init | ( | void | ) |
Check if scheduler is initialized.
true | If scheduler is initialized. |
false | If scheduler is not initialized. |
bool ri_scheduler_run_integration_test | ( | const rd_test_print_fp | printfp | ) |
Run all scheduler integration tests.
[in] | printfp | Function to which test JSON is passed. |
false | if no errors occured. |
true | if error occured. |
rd_status_t ri_scheduler_uninit | ( | void | ) |
Uninitialize scheduler.
Scheduler has to be re-initialized after uninitialization, and all the previous tasks not yet executed are discarded. As the memory is statically allocated, no memory is freed.