Enter power-down mode, but couldn't wake it up using an interrupt from a real time clock (RTC) interrupt

Dependencies:   PowerControl RTC mbed

main.cpp

Committer:
weidongguo
Date:
2016-02-18
Revision:
0:35c76e921818
Child:
1:635eaebcd13f

File content as of revision 0:35c76e921818:

#include "mbed.h"
#include "PowerControl.h"
#include "RTC.h"

DigitalOut leds[] = {DigitalOut(LED1), DigitalOut(LED2), DigitalOut(LED3), DigitalOut(LED4)}; // put each LED object into an array, easier to access

void ISR(void){
    DigitalOut led = DigitalOut(LED4);
    led = 1;
    
    leds[2] = !leds[2];
    if(! (LPC_SC->PCON & 0x400) )
        leds[1] = !leds[1];
 }
 
 
int main() {
    set_time(1455622440); // Tue, 16 Feb 2016 11:34:00 GMT
    //set up real-time clock(RTC) interrupt
    tm t = RTC::getDefaultTM();
    t.tm_sec = 3; //when the second is 3 for the real time, once every minute
 
    RTC::alarm(&ISR, t);

    while (true) {
       leds[0] = !leds[0];
       wait_ms(1000);
       PowerDown();
    }
}