123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211 |
- #ifndef APP_SCHEDULER_H__
- #define APP_SCHEDULER_H__
- #include "sdk_config.h"
- #include <stdint.h>
- #include "app_error.h"
- #include "app_util.h"
- #ifdef __cplusplus
- extern "C" {
- #endif
- #define APP_SCHED_EVENT_HEADER_SIZE 8
- #define APP_SCHED_BUF_SIZE(EVENT_SIZE, QUEUE_SIZE) \
- (((EVENT_SIZE) + APP_SCHED_EVENT_HEADER_SIZE) * ((QUEUE_SIZE) + 1))
- typedef void (*app_sched_event_handler_t)(void * p_event_data, uint16_t event_size);
- #define APP_SCHED_INIT(EVENT_SIZE, QUEUE_SIZE) \
- do \
- { \
- static uint32_t APP_SCHED_BUF[CEIL_DIV(APP_SCHED_BUF_SIZE((EVENT_SIZE), (QUEUE_SIZE)), \
- sizeof(uint32_t))]; \
- uint32_t ERR_CODE = app_sched_init((EVENT_SIZE), (QUEUE_SIZE), APP_SCHED_BUF); \
- APP_ERROR_CHECK(ERR_CODE); \
- } while (0)
- uint32_t app_sched_init(uint16_t max_event_size, uint16_t queue_size, void * p_evt_buffer);
- void app_sched_execute(void);
- uint32_t app_sched_event_put(void const * p_event_data,
- uint16_t event_size,
- app_sched_event_handler_t handler);
- uint16_t app_sched_queue_utilization_get(void);
- uint16_t app_sched_queue_space_get(void);
- void app_sched_pause(void);
- void app_sched_resume(void);
- #ifdef __cplusplus
- }
- #endif
- #endif
|