Werner Terreblanche
/
mBuino_low_power_led_flasher
mBuino low current/ deep sleep LED flasher to be used as key finder.
Diff: main.cpp
- Revision:
- 0:346c8150ca74
- Child:
- 1:c0cfd1b0f4ef
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Sat Sep 06 09:30:35 2014 +0000 @@ -0,0 +1,34 @@ +#include "mbed.h" +#include "WakeUp.h" + +DigitalOut LED[] = {(P0_7), (P0_8), (P0_2), (P0_20), (P1_19), (P0_17), (P0_23)};// declare 7 LEDs + +void myDeepSleep() { + LPC_PMU->PCON = 0x1; + SCB->SCR |= SCB_SCR_SLEEPDEEP_Msk; + LPC_SYSCON->PDAWAKECFG &= 0xFFFFF800; + __WFI(); +} + +int main() { + + int i = 0; + + //The low-power oscillator can be quite inaccurate on some targets + //this function calibrates it against the main clock + WakeUp::calibrate(); + while(1) + { + LED[i] = 1; // turn on + wait(.01); // delay + LED[i] = 0; // turn off + + //Set wakeup time for second + WakeUp::set_ms(1000); + //Enter deepsleep, the program won't go beyond this point until it is woken up + myDeepSleep(); + i++; + if (i >= 7) + i = 0; + } +} \ No newline at end of file