6.2.1 Using PMM in Application
- Include
pmm.hto application. In end-device demo application, PMM is included inmain.c. - Implement a call back function to be invoked after wake up. This function must
have the prototype of
pmmWakeupCallbackfunction pointer defined inPMM_SleepReq_tstructure.PMM_SleepReq_tis available inpmm.h. - Invoke
PMM_Sleepfunction from the application to request the PMM to put the system to sleep. PMM may deny a sleep request if the stack is not ready to sleep. User can supply NULL pointer topmmWakeupCallbackif wake-up callback function is not implemented.
Application sleep request time is configured by the macro DEMO_CONF_DEFAULT_APP_SLEEP_TIME_MS
. It is present in
conf_app.h file. By default, application sleep time is 1 second and
it can be changed to the desired values. But, the sleep duration must fall within the
acceptable range which is given in the following table.
| Parameter | Value | Unit | Description |
|---|---|---|---|
| PMM_SLEEP_TIME_MIN | 100 | milliseconds | Minimum allowed sleep time |
| PMM_SLEEP_TIME_MAX | 0x7CED900 | milliseconds | Maximum allowed sleep time is approximately 36 hours, 26 minutes |
| PMM_WAKEUP_TIME | 10 | milliseconds | Time to account for wake up |
When the end-device is put to sleep, it can wake up from interrupt by either
sleep timer, or transceiver interrupt or GPIO interrupt. When the end-device wakes up,
the PMM_Wakeup() function is called and it returns the elapsed duration
from sleep to application. In case of the application maintaining its own timers, this
slept duration returned from PMM_Wakeup can be used to resume those
timers. MLS automatically calls PMM_Wakeup whenever it receives a sleep
timer interrupt or external interrupt. However, the end-device must also call
PMM_Wakeup for GPIO interrupts. For those GPIO used by the
application that can generate interrupts during sleep, the user must call
PMM_Wakeup in those ISR callbacks. In case of polling, this is not
required since polling code works only after wake up.
