Jose Rios
/
Nucleo_BlinkLowPower
Blinking a LED in low power mode (Replacing the active wait() function to a low power wait function).
Revision 0:f1ecec258a2c, committed 2014-10-29
- Comitter:
- jose_23991
- Date:
- Wed Oct 29 20:53:20 2014 +0000
- Commit message:
- Version 1.0
Changed in this revision
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
mbed.bld | Show annotated file Show diff for this revision Revisions of this file |
diff -r 000000000000 -r f1ecec258a2c main.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Wed Oct 29 20:53:20 2014 +0000 @@ -0,0 +1,28 @@ +#include "mbed.h" + +DigitalOut led(LED1, 0); // Create the LED object and setup OFF +Timeout timeout; // Create the Timeout object + +void wait_LowPow(unsigned long time); // Wait in low power mode function prototype + +void timer_interrupt() // The Timer interrupt service routine +{ + // Nothing to do, just for wakeup the system +} + +int main() +{ + while(1) + { + led = 1; // Turn LED ON + wait_LowPow(1); // Wait 1s in low power mode + led = 0; // Turn LED OFF + wait_LowPow(1); // Wait 1s in low power mode + } +} + +void wait_LowPow(unsigned long time) // Wait in low power mode function implementation +{ + timeout.attach(&timer_interrupt, time); // Set the timer interrupt service rutine (ISR) and the time for the timeout (in seconds) + sleep(); // Enter Low Power Mode (It cant be used deep_sleep() mode, because that mode disable the timer) +}
diff -r 000000000000 -r f1ecec258a2c mbed.bld --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Wed Oct 29 20:53:20 2014 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/mbed_official/code/mbed/builds/031413cf7a89 \ No newline at end of file