deep sleep and wake-up. GPIO group interrupt, start logic sample see: http://mbed.org/users/okini3939/notebook/low-power-m0/
Diff: main.cpp
- Revision:
- 1:d676ec86101e
- Parent:
- 0:ae90ac40c518
- Child:
- 2:5412d5b8242c
--- a/main.cpp Mon Oct 15 05:07:10 2012 +0000 +++ b/main.cpp Mon Oct 15 15:06:04 2012 +0000 @@ -4,6 +4,13 @@ Serial pc(p9, p10); + +extern "C" +void GINT1_IRQHandler(void) { + LPC_GPIO_GROUP_INT1->CTRL |= (1<<0); + NVIC_ClearPendingIRQ(GINT0_IRQn); +} + void initStartLogic (unsigned int p0, unsigned int p1) { LPC_SYSCON->SYSAHBCLKCTRL |= (1<<24); LPC_GPIO_GROUP_INT1->PORT_POL[0] = 0; @@ -53,15 +60,10 @@ } void Sleep () { + SCB->SCR &= ~(1<<2); __WFI(); } -extern "C" -void GINT1_IRQHandler(void) { - LPC_GPIO_GROUP_INT1->CTRL |= (1<<0); - NVIC_ClearPendingIRQ(GINT0_IRQn); -} - int main() { int i; @@ -75,23 +77,23 @@ wait(0.5); } - initStartLogic((1<<8), 0); + initStartLogic((1<<8)|(1<<1), 0); -loop: - pc.printf("enter sleep\r\n"); - wait_ms(10); - setSystemMainClock(0); + for (;;) { + + pc.printf("enter sleep\r\n"); + wait_ms(10); + setSystemMainClock(0); - DeepSleep(); + DeepSleep(); - setSystemMainClock(3); + setSystemMainClock(3); - pc.printf("wake up\r\n"); - for (i = 0; i < 6; i ++) { - myled = !myled; - wait(0.5); + pc.printf("wake up\r\n"); + for (i = 0; i < 6; i ++) { + myled = !myled; + wait(0.5); + } + } - - goto loop; - }