How can I determine the wake source when the EM250 wakes from sleep?
Categories:
After calling halSleep() or halSleepForQuarterSeconds() and having the code execution resume after sleep, an EM250 application can determine the wake source of the last sleep event by using the halGetWakeInfo() API (defined in micro.h in the EM250 HAL). The description of this API is as follows (from micro.h API documentation):
*If bits[16:0] are set, they correspond to GPIO[16:0] as the wake event(s).
Bit 30 is Sleep Timer Compare A event. Bit 31 is SIF activity.*
An example of this usage in code follows below:
int32u sleepDuration = 240; // Sleep for one minute and then check wake sources if( halSleepForQuarterSeconds(&sleepDuration) == EMBER_SLEEP_INTERRUPTED ) { // We woke up early, so check wake source to see if it was GPIO12 if( halGetWakeInfo() == BIT32(12) ) { // Yes, it was GPIO12 that woke us } } else { // We slept for the whole time, so halGetWakeInfo() == BIT32(30) }
- Login to post comments









