AIROC™ BTSDK v4.9 - Documentation | ||||
Device level low power management. More...
Data Structures | |
struct | DeviceLpmQueriableRegistration |
The structure to hold a notification registration. More... | |
struct | DeviceLpmState |
Typedefs | |
typedef enum LowPowerModePollType | LowPowerModePollType |
This provides a concrete implementation for hid-off and sleep routines for the application. More... | |
typedef UINT32(* | DeviceLpmQueriableMethodCallback )(LowPowerModePollType type, UINT32 context) |
This typedef is what is expected when registering a function as a callback. More... | |
typedef struct DeviceLpmQueriableRegistration | DeviceLpmQueriableRegistration |
The structure to hold a notification registration. | |
Enumerations | |
enum | LowPowerModePollType { LOW_POWER_MODE_POLL_TYPE_SLEEP, LOW_POWER_MODE_POLL_TYPE_POWER_OFF } |
This provides a concrete implementation for hid-off and sleep routines for the application. More... | |
enum | { DEV_LPM_DISC_LOW_POWER_MODES_SLEEP, DEV_LPM_DISC_LOW_POWER_MODES_HID_OFF } |
enum | { DEV_LPM_WAKE_SOURCE_GPIO = (1 << 0x08), DEV_LPM_WAKE_SOURCE_LHL = (1 << 0x08), DEV_LPM_WAKE_SOURCE_KEYSCAN = (1 << 0x09), DEV_LPM_WAKE_SOURCE_QUAD = (1 << 0x0A), DEV_LPM_WAKE_SOURCE_MASK = (DEV_LPM_WAKE_SOURCE_GPIO | DEV_LPM_WAKE_SOURCE_KEYSCAN | DEV_LPM_WAKE_SOURCE_QUAD) } |
Functions | |
void | devlpm_init (void) |
Initialize device Low Power Manager. Internal, invoked before the application is created. | |
BOOLEAN | devlpm_registerForLowPowerQueries (DeviceLpmQueriableMethodCallback callback, UINT32 context) |
Add the given object to the list of objects that need to be queried for time to sleep and low power queries. More... | |
void | devlpm_registerForEarlyWakeNotification (INT32(*fn)(void *), void *data) |
Register for an early wake notification. More... | |
void | devlpm_enterLowPowerMode (void) |
Enters the configured low power mode (deep sleep). More... | |
void | devlpm_checkForDiscLowPowerCondition (void) |
Check for disconnected low power mode. Internal, not for application use. | |
BOOLEAN | devlpm_registeredObjectsApproveHidOff (void) |
Check if deep sleep is allowed. Internal, not for application use. | |
UINT32 | devlpm_timeToSleep (void) |
Check for sleep. Internal, not for application use. | |
void | devlpm_handleEarlyWakeNotification (void) |
Early wake dispatch function. Internal, not for application use. | |
void | devlpm_enableWakeFrom (UINT16 sources) |
Enable early wake sources. More... | |
void | devlpm_disableWakeFrom (UINT16 sources) |
Disable early wake sources. More... | |
Device level low power management.
typedef UINT32(* DeviceLpmQueriableMethodCallback)(LowPowerModePollType type, UINT32 context) |
This typedef is what is expected when registering a function as a callback.
This callback function is expected to respond with time to sleep or if it is ok to enter hid off or not. A 0 value indicates do not sleep or do not go hid-off and a non-zero value for sleep is the sleep time or ok to go hid-off
typedef enum LowPowerModePollType LowPowerModePollType |
This provides a concrete implementation for hid-off and sleep routines for the application.
The key features of the DeviceLpm include:
anonymous enum |
anonymous enum |
enum LowPowerModePollType |
This provides a concrete implementation for hid-off and sleep routines for the application.
The key features of the DeviceLpm include:
void devlpm_disableWakeFrom | ( | UINT16 | sources | ) |
Disable early wake sources.
There are three sources - Keyscan, Quadrature sensor and GPIOs.
sources | Bitwise OR of the sources to disable. Valid sources are: DEV_LPM_WAKE_SOURCE_GPIO, DEV_LPM_WAKE_SOURCE_KEYSCAN and DEV_LPM_WAKE_SOURCE_QUAD, |
void devlpm_enableWakeFrom | ( | UINT16 | sources | ) |
Enable early wake sources.
There are three sources - Keyscan, Quadrature sensor and GPIOs.
sources | Bitwise OR of the sources to enable. Valid sources are: DEV_LPM_WAKE_SOURCE_GPIO, DEV_LPM_WAKE_SOURCE_KEYSCAN and DEV_LPM_WAKE_SOURCE_QUAD, |
void devlpm_enterLowPowerMode | ( | void | ) |
Enters the configured low power mode (deep sleep).
When deep sleep is enabled, this function will never return. NOTE: This has to be invoked inside an OS context lock.
void devlpm_registerForEarlyWakeNotification | ( | INT32(*)(void *) | fn, |
void * | data | ||
) |
Register for an early wake notification.
Typically, when connected, the device will wake just in time to service the connection event and send out any data in its buffers. In cases where the application has to service an external interrupt between connection events (which may happen often), and have the data ready in time for the TX, the app may want to register a callback for any non-scheduled wake event so it can take action as quickly as possible.
fn | Pointer to a function that will serialized to the application thread. See bleappevent.h |
data | An application context that will be passed back when invoking the callback. |
BOOLEAN devlpm_registerForLowPowerQueries | ( | DeviceLpmQueriableMethodCallback | callback, |
UINT32 | context | ||
) |
Add the given object to the list of objects that need to be queried for time to sleep and low power queries.
An application can participate in sleep and deep sleep decisions if required by registering a callback as in the sample below. NOTE: This callback is always called in a different (lower priority) thread context. So the call may get preempted by the application thread any time, use caution when accessing memory shared with the application thread. Use bleapputils_cpuIntDisable/Enable if appropriate.
/// UINT32 application_time_to_sleep_callback(LowPowerModePollType type, UINT32 context) /// { /// switch(type) /// { /// case LOW_POWER_MODE_POLL_TYPE_SLEEP: /// // System wants to sleep. Return how long the system can sleep in microseconds. /// // Sleep times under ~3.75mS may be ignored. Guaranteed to sleep for not more /// // than the time returned by this function. May sleep for less than this if /// // other subsystems in the FW return a time less than this return value. /// // To disable sleep, return 0; to leave the decision to some other subsystem /// // (typically when advertising/connected, the Bluetooth sub-system will ensure wake /// // at the right time), return ~0 (this is the default if the app does not register /// // for this callback). /// return ~0; // Let some other sub-system decide sleep time (default). /// case LOW_POWER_MODE_POLL_TYPE_POWER_OFF: /// // System wants to enter deep sleep. Return 0 to disable deep sleep or any non-zero /// // value to indicate OK to enter deep sleep. Returning 0 will guarantee that deep /// // sleep is not entered. Device may not enter deep sleep even when the application /// // allows deep sleep because some other subsystem disabled it. /// return 1; // Let some other sub-system decide deep sleep time (default). /// default: /// return ~0; /// } /// } /// void application_create(void) /// { /// // .... All other application initialization. /// devlpm_registerForLowPowerQueries(application_time_to_sleep_callback, 0); /// } ///
callback | Pointer to function that will be called for time-to-sleep decision. |
context | Any application context that needs to be passed back to the callback. |