Module for declaring the Falling Asleep API. More...
Typedefs | |
typedef uint8_t | sys_sleep_approver_id_t |
Approver ID typedef. | |
Functions | |
void | sys_sleep_init (void) |
Function for initializing the system sleep module. More... | |
sys_sleep_approver_id_t | sys_sleep_approver_register (sys_event_desc_t *p_event_falling_asleep, sys_event_desc_t *p_event_wake_up) |
Function for registering the approver of the system sleep request. More... | |
void | sys_sleep_approver_unregister (sys_sleep_approver_id_t approver_id, sys_event_desc_t *p_event_falling_asleep, sys_event_desc_t *p_event_wake_up) |
Function for unregistering the approver of the system sleep request. More... | |
void | sys_sleep_approve (sys_sleep_approver_id_t approver_id) |
Function for approving the system sleep request. More... | |
void | sys_sleep_request_ms (uint32_t sleep_time_ms) |
Function for requesting the system to safely enter into sleep mode. More... | |
hal_wakeup_reason_t | sys_sleep_wakeup_reason (void) |
Function for getting information about the wakeup reason. More... | |
Module for declaring the Falling Asleep API.
Because additional preparation may be required to be done by user modules, prior to putting hardware into the sleep mode, a notification and approval mechanism is provided to the user. Each module that wants to be notified about the "falling asleep" event, has to subscribe to the HAL_EVENT_FALLING_ASLEEP event, using sys_sleep_approver_register(), and to get the unique approver's ID value. In the handler of the HAL_EVENT_FALLING_ASLEEP event, the module is able to perform the required preparation before falling asleep, and to approve the falling asleep request, using the module unique approver ID, after all preparation to sleep is finished. The hardware will fall asleep only after all the registered approvers approve the fall asleep request.
void sys_sleep_approve | ( | sys_sleep_approver_id_t | approver_id | ) |
Function for approving the system sleep request.
This function is to be called by the registered approver in order to approve putting the system into the sleep mode.
[in] | approver_id | The unique approver ID. |
sys_sleep_approver_id_t sys_sleep_approver_register | ( | sys_event_desc_t * | p_event_falling_asleep, |
sys_event_desc_t * | p_event_wake_up | ||
) |
Function for registering the approver of the system sleep request.
After the sleep approver is registered with this function, the hardware will not fall asleep without its approval.
[in] | p_event_falling_asleep | Event descriptor, which will handle the SYS_EVENT_FALLING_ASLEEP event. |
[in] | p_event_wake_up | Event descriptor, which will handle the SYS_EVENT_WAKE_UP event. |
The | unique approver ID, reserved for this newly-registered approver. This ID will be required to approve system sleep requests by this approver module. |
void sys_sleep_approver_unregister | ( | sys_sleep_approver_id_t | approver_id, |
sys_event_desc_t * | p_event_falling_asleep, | ||
sys_event_desc_t * | p_event_wake_up | ||
) |
Function for unregistering the approver of the system sleep request.
After the approver is unregistered, its approval will not be required to put the system into sleep mode.
[in] | approver_id | The unique approver ID to be unregistered. |
[in] | p_event_falling_asleep | Event descriptor to unsubscribe from the SYS_EVENT_FALLING_ASLEEP event. |
[in] | p_event_wake_up | Event descriptor to unsubscribe from the SYS_EVENT_WAKE_UP event. |
void sys_sleep_init | ( | void | ) |
Function for initializing the system sleep module.
This function must be called before any usage of the System Sleep module.
void sys_sleep_request_ms | ( | uint32_t | sleep_time_ms | ) |
Function for requesting the system to safely enter into sleep mode.
This function notifies all the registered sleep approvers with the HAL_EVENT_FALLING_ASLEEP event, allowing them to perform all the needed preparation before the hardware falls asleep. The hardware will enter sleep mode only after all registered approvers approve the fall asleep request.
[in] | sleep_time_ms | Defines sleep time in ms. |
hal_wakeup_reason_t sys_sleep_wakeup_reason | ( | void | ) |
Function for getting information about the wakeup reason.
hal_wakeup_reason | Interrupt source which was the wakeup reason. |