Low-powered blinky example

Dependencies:   mbed

Blinks an LED using a low-power ticker.

Uses the asynchronous APIs and improved sleep API.

Information

All examples in this repo are considered EXPERIMENTAL QUALITY, meaning this code has been created as one-off proof-of-concept and is suitable as a demonstration for experimental purposes only. This code will not be regularly maintained by Silicon Labs and there is no guarantee that these projects will work across all environments, SDK versions and hardware.

main.cpp

Committer:
stevew817
Date:
2015-08-10
Revision:
3:c950338a014e
Parent:
0:b0927d62ef70

File content as of revision 3:c950338a014e:

#include "mbed.h"
 
DigitalOut myled(LED1);
LowPowerTicker toggleTicker;

/**
* This is a callback! Do not call frequency-dependent operations here.
*
* For a more thorough explanation, go here: 
* https://developer.mbed.org/teams/SiliconLabs/wiki/Using-the-improved-mbed-sleep-API#mixing-sleep-with-synchronous-code
**/
void ledToggler(void) {
    myled = !myled;
}
 
int main() {
    toggleTicker.attach(&ledToggler, 0.2f);
    while(1) {
        sleep();
    }
}