The sleep manager is a service for ensuring that the device is not put to sleep in deeper sleep modes than the system (e.g., peripheral drivers, services or the application) allows at any given time.
It is based on the use of lock counting for the individual sleep modes, and will put the device to sleep in the shallowest sleep mode that has a non-zero lock count. The drivers/services/application can change these counts by use of sleepmgr_lock_mode and sleepmgr_unlock_mode. Refer to sleepmgr_mode for a list of the sleep modes available for locking, and the device datasheet for information on their effect.
The application must supply the file conf_sleepmgr.h.
For the sleep manager to be enabled, the symbol CONFIG_SLEEPMGR_ENABLE must be defined, e.g., in conf_sleepmgr.h. If this symbol is not defined, the functions are replaced with dummy functions and no RAM is used.
Macros | |
#define | CONFIG_SLEEPMGR_ENABLE |
Configuration symbol for enabling the sleep manager. More... | |
Enumerations | |
enum | sleepmgr_mode { SLEEPMGR_ACTIVE = 0, SLEEPMGR_IDLE, SLEEPMGR_STANDBY, SLEEPMGR_BACKUP, SLEEPMGR_OFF, SLEEPMGR_NR_OF_MODES } |
Sleep mode locks. More... | |
Functions | |
static void | sleepmgr_enter_sleep (void) |
Go to sleep in the deepest allowed mode. More... | |
static enum sleepmgr_mode | sleepmgr_get_sleep_mode (void) |
Retrieves the deepest allowable sleep mode. More... | |
static void | sleepmgr_init (void) |
Initialize the lock counts. More... | |
static void | sleepmgr_lock_mode (enum sleepmgr_mode mode) |
Increase lock count for a sleep mode. More... | |
static void | sleepmgr_sleep (const enum sleepmgr_mode sleep_mode) |
static void | sleepmgr_unlock_mode (enum sleepmgr_mode mode) |
Decrease lock count for a sleep mode. More... | |
Internal arrays | |
uint8_t | sleepmgr_locks [] |
Sleep mode lock counters. More... | |
#define CONFIG_SLEEPMGR_ENABLE |
Configuration symbol for enabling the sleep manager.
If this symbol is not defined, the functions of this service are replaced with dummy functions. This is useful for reducing code size and execution time if the sleep manager is not needed in the application.
This symbol may be defined in conf_sleepmgr.h.
enum sleepmgr_mode |
Sleep mode locks.
Identifiers for the different sleep mode locks.
|
inlinestatic |
Go to sleep in the deepest allowed mode.
Searches through the sleep mode lock counts, starting at the shallowest sleep mode, until the first non-zero lock count is found. The device is then put to sleep in the sleep mode that corresponds to the lock.
References cpu_irq_disable, cpu_irq_enable, sleep_mode, SLEEPMGR_ACTIVE, sleepmgr_get_sleep_mode(), and sleepmgr_sleep().
Referenced by main().
|
inlinestatic |
Retrieves the deepest allowable sleep mode.
Searches through the sleep mode lock counts, starting at the shallowest sleep mode, until the first non-zero lock count is found. The deepest allowable sleep mode is then returned.
References Assert, sleep_mode, SLEEPMGR_ACTIVE, sleepmgr_locks, and SLEEPMGR_NR_OF_MODES.
Referenced by sleepmgr_enter_sleep().
|
inlinestatic |
Initialize the lock counts.
Sets all lock counts to 0, except the very last one, which is set to 1. This is done to simplify the algorithm for finding the deepest allowable sleep mode in sleepmgr_enter_sleep.
References sleepmgr_locks, and SLEEPMGR_NR_OF_MODES.
Referenced by main().
|
inlinestatic |
Increase lock count for a sleep mode.
Increases the lock count for mode to ensure that the sleep manager does not put the device to sleep in the deeper sleep modes.
mode | Sleep mode to lock. |
References cpu_irq_restore(), cpu_irq_save(), sleepmgr_locks, and UNUSED.
Referenced by udd_sleep_mode(), and uhd_sleep_mode().
|
inlinestatic |
References Assert, cpu_irq_disable, cpu_irq_enable, SLEEPMGR_ACTIVE, SLEEPMGR_BACKUP, SLEEPMGR_IDLE, SLEEPMGR_OFF, SLEEPMGR_STANDBY, system_set_sleepmode(), system_sleep(), SYSTEM_SLEEPMODE_BACKUP, SYSTEM_SLEEPMODE_IDLE, SYSTEM_SLEEPMODE_OFF, SYSTEM_SLEEPMODE_STANDBY, and UNUSED.
Referenced by sleepmgr_enter_sleep().
|
inlinestatic |
Decrease lock count for a sleep mode.
Decreases the lock count for mode. If the lock count reaches 0, the sleep manager can put the device to sleep in the deeper sleep modes.
mode | Sleep mode to unlock. |
References cpu_irq_restore(), cpu_irq_save(), sleepmgr_locks, and UNUSED.
Referenced by udd_sleep_mode(), and uhd_sleep_mode().
uint8_t sleepmgr_locks[] |
Sleep mode lock counters.
Referenced by sleepmgr_get_sleep_mode(), sleepmgr_init(), sleepmgr_lock_mode(), and sleepmgr_unlock_mode().