Werner Terreblanche
/
mBuino_low_power_led_flasher
mBuino low current/ deep sleep LED flasher to be used as key finder.
main.cpp
- Committer:
- wernert
- Date:
- 2014-09-06
- Revision:
- 0:346c8150ca74
- Child:
- 1:c0cfd1b0f4ef
File content as of revision 0:346c8150ca74:
#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; } }