Modified WakeUp program to run on STM32L152RE
Dependencies: mbed LPC1114_WakeInterruptIn
Fork of WakeUp by
main.cpp@25:5147cde086fd, 2017-11-24 (annotated)
- Committer:
- mx300
- Date:
- Fri Nov 24 00:04:03 2017 +0000
- Revision:
- 25:5147cde086fd
Modified for use on STM32L152RE
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
mx300 | 25:5147cde086fd | 1 | |
mx300 | 25:5147cde086fd | 2 | // Depending on the LED connections either the LED is off the 2 seconds |
mx300 | 25:5147cde086fd | 3 | // the target spends in deepsleep(), and on for the other second. Or it is inverted |
mx300 | 25:5147cde086fd | 4 | |
mx300 | 25:5147cde086fd | 5 | #include "mbed.h" |
mx300 | 25:5147cde086fd | 6 | #include "WakeUp.h" |
mx300 | 25:5147cde086fd | 7 | |
mx300 | 25:5147cde086fd | 8 | DigitalOut myled(LED1); |
mx300 | 25:5147cde086fd | 9 | |
mx300 | 25:5147cde086fd | 10 | int main() { |
mx300 | 25:5147cde086fd | 11 | //The low-power oscillator can be quite inaccurate on some targets |
mx300 | 25:5147cde086fd | 12 | //this function calibrates it against the main clock |
mx300 | 25:5147cde086fd | 13 | WakeUp::calibrate(); |
mx300 | 25:5147cde086fd | 14 | |
mx300 | 25:5147cde086fd | 15 | while(1) { |
mx300 | 25:5147cde086fd | 16 | //Set LED to zero |
mx300 | 25:5147cde086fd | 17 | myled = 0; |
mx300 | 25:5147cde086fd | 18 | |
mx300 | 25:5147cde086fd | 19 | //Set wakeup time for 2 seconds |
mx300 | 25:5147cde086fd | 20 | WakeUp::set_ms(2000); |
mx300 | 25:5147cde086fd | 21 | |
mx300 | 25:5147cde086fd | 22 | //Enter deepsleep, the program won't go beyond this point until it is woken up |
mx300 | 25:5147cde086fd | 23 | sleep(); |
mx300 | 25:5147cde086fd | 24 | |
mx300 | 25:5147cde086fd | 25 | //Set LED for 1 second to one |
mx300 | 25:5147cde086fd | 26 | myled = 1; |
mx300 | 25:5147cde086fd | 27 | wait(1); |
mx300 | 25:5147cde086fd | 28 | } |
mx300 | 25:5147cde086fd | 29 | } |