The scheduler is used for transferring execution from the interrupt context to the main context. More...
Modules | |
Events scheduler configuration | |
Macros | |
#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)) |
Compute number of bytes required to hold the scheduler buffer. More... | |
#define | APP_SCHED_INIT(EVENT_SIZE, QUEUE_SIZE) |
Macro for initializing the event scheduler. More... | |
Typedefs | |
typedef void(* | app_sched_event_handler_t )(void *p_event_data, uint16_t event_size) |
Scheduler event handler type. | |
Functions | |
uint32_t | app_sched_init (uint16_t max_event_size, uint16_t queue_size, void *p_evt_buffer) |
Function for initializing the Scheduler. More... | |
void | app_sched_execute (void) |
Function for executing all scheduled events. More... | |
uint32_t | app_sched_event_put (void *p_event_data, uint16_t event_size, app_sched_event_handler_t handler) |
Function for scheduling an event. More... | |
uint16_t | app_sched_queue_utilization_get (void) |
Function for getting the maximum observed queue utilization. More... | |
uint16_t | app_sched_queue_space_get (void) |
Function for getting the current amount of free space in the queue. More... | |
void | app_sched_pause (void) |
A function to pause the scheduler. More... | |
void | app_sched_resume (void) |
A function to resume a scheduler. More... | |
The scheduler is used for transferring execution from the interrupt context to the main context.
See Applications using the Scheduler for sequence diagrams illustrating the flow of events when using the Scheduler.
For an example usage of the scheduler, see the implementations of HID Mouse Application and HID Keyboard Application.
#define APP_SCHED_BUF_SIZE | ( | EVENT_SIZE, | |
QUEUE_SIZE | |||
) | (((EVENT_SIZE) + APP_SCHED_EVENT_HEADER_SIZE) * ((QUEUE_SIZE) + 1)) |
Compute number of bytes required to hold the scheduler buffer.
[in] | EVENT_SIZE | Maximum size of events to be passed through the scheduler. |
[in] | QUEUE_SIZE | Number of entries in scheduler queue (i.e. the maximum number of events that can be scheduled for execution). |
#define APP_SCHED_EVENT_HEADER_SIZE 8 |
Size of app_scheduler.event_header_t (only for use inside APP_SCHED_BUF_SIZE()).
#define APP_SCHED_INIT | ( | EVENT_SIZE, | |
QUEUE_SIZE | |||
) |
Macro for initializing the event scheduler.
It will also handle dimensioning and allocation of the memory buffer required by the scheduler, making sure the buffer is correctly aligned.
[in] | EVENT_SIZE | Maximum size of events to be passed through the scheduler. |
[in] | QUEUE_SIZE | Number of entries in scheduler queue (i.e. the maximum number of events that can be scheduled for execution). |
uint32_t app_sched_event_put | ( | void * | p_event_data, |
uint16_t | event_size, | ||
app_sched_event_handler_t | handler | ||
) |
Function for scheduling an event.
Puts an event into the event queue.
[in] | p_event_data | Pointer to event data to be scheduled. |
[in] | event_size | Size of event data to be scheduled. |
[in] | handler | Event handler to receive the event. |
void app_sched_execute | ( | void | ) |
Function for executing all scheduled events.
This function must be called from within the main loop. It will execute all events scheduled since the last time it was called.
uint32_t app_sched_init | ( | uint16_t | max_event_size, |
uint16_t | queue_size, | ||
void * | p_evt_buffer | ||
) |
Function for initializing the Scheduler.
It must be called before entering the main loop.
[in] | max_event_size | Maximum size of events to be passed through the scheduler. |
[in] | queue_size | Number of entries in scheduler queue (i.e. the maximum number of events that can be scheduled for execution). |
[in] | p_evt_buffer | Pointer to memory buffer for holding the scheduler queue. It must be dimensioned using the APP_SCHED_BUFFER_SIZE() macro. The buffer must be aligned to a 4 byte boundary. |
NRF_SUCCESS | Successful initialization. |
NRF_ERROR_INVALID_PARAM | Invalid parameter (buffer not aligned to a 4 byte boundary). |
void app_sched_pause | ( | void | ) |
A function to pause the scheduler.
When the scheduler is paused events are not pulled from the scheduler queue for processing. The function can be called multiple times. To unblock the scheduler the function app_sched_resume has to be called the same number of times.
uint16_t app_sched_queue_space_get | ( | void | ) |
Function for getting the current amount of free space in the queue.
The real amount of free space may be less if entries are being added from an interrupt. To get the sxact value, this function should be called from the critical section.
uint16_t app_sched_queue_utilization_get | ( | void | ) |
Function for getting the maximum observed queue utilization.
Function for tuning the module and determining QUEUE_SIZE value and thus module RAM usage.
void app_sched_resume | ( | void | ) |
A function to resume a scheduler.
To unblock the scheduler this function has to be called the same number of times as app_sched_pause function.