implement LP1768 power mode
Fork of steven_powercontrol by
powercontrol.h@1:2976b5aa967b, 2014-08-01 (annotated)
- Committer:
- steniu01
- Date:
- Fri Aug 01 17:04:39 2014 +0000
- Revision:
- 1:2976b5aa967b
- Parent:
- steven_powercontrol.h@0:fc6cd61e7460
this is the first release version
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
steniu01 | 0:fc6cd61e7460 | 1 | //sleep mode |
steniu01 | 0:fc6cd61e7460 | 2 | void steven_Sleep(void) { |
steniu01 | 0:fc6cd61e7460 | 3 | |
steniu01 | 0:fc6cd61e7460 | 4 | LPC_SC->PCON=0x0; |
steniu01 | 0:fc6cd61e7460 | 5 | // SRC[SLEEPDEEP] set to 0 = sleep, this bit control whether the processor uses sleep or deep sleep as its low power mode |
steniu01 | 0:fc6cd61e7460 | 6 | SCB->SCR &= ~SCB_SCR_SLEEPDEEP_Msk; |
steniu01 | 0:fc6cd61e7460 | 7 | |
steniu01 | 0:fc6cd61e7460 | 8 | // wait for interrupt |
steniu01 | 0:fc6cd61e7460 | 9 | __WFI(); |
steniu01 | 0:fc6cd61e7460 | 10 | } |
steniu01 | 0:fc6cd61e7460 | 11 | // "Deep Sleep" mode |
steniu01 | 0:fc6cd61e7460 | 12 | void steven_DeepSleep(void) { |
steniu01 | 0:fc6cd61e7460 | 13 | |
steniu01 | 0:fc6cd61e7460 | 14 | |
steniu01 | 0:fc6cd61e7460 | 15 | // PCON[PD] set to DeepSleep |
steniu01 | 0:fc6cd61e7460 | 16 | LPC_SC->PCON = 0x0; |
steniu01 | 0:fc6cd61e7460 | 17 | |
steniu01 | 0:fc6cd61e7460 | 18 | // SRC[SLEEPDEEP] set to 0 = DeepSleep |
steniu01 | 0:fc6cd61e7460 | 19 | SCB->SCR |= SCB_SCR_SLEEPDEEP_Msk; |
steniu01 | 0:fc6cd61e7460 | 20 | |
steniu01 | 0:fc6cd61e7460 | 21 | // wait for interrupt |
steniu01 | 0:fc6cd61e7460 | 22 | __WFI(); |
steniu01 | 0:fc6cd61e7460 | 23 | } |
steniu01 | 0:fc6cd61e7460 | 24 | |
steniu01 | 0:fc6cd61e7460 | 25 | //"Power-Down" Mode |
steniu01 | 0:fc6cd61e7460 | 26 | void steven_PowerDown(void) |
steniu01 | 0:fc6cd61e7460 | 27 | { |
steniu01 | 0:fc6cd61e7460 | 28 | SCB->SCR |= SCB_SCR_SLEEPDEEP_Msk; |
steniu01 | 0:fc6cd61e7460 | 29 | LPC_SC->PCON=0x1; // PM1=0, PM0=1, enter power down mode if the SLEEPDEEP bit in SCR is 1 |
steniu01 | 0:fc6cd61e7460 | 30 | __WFI(); |
steniu01 | 0:fc6cd61e7460 | 31 | //reset back to normal |
steniu01 | 0:fc6cd61e7460 | 32 | LPC_SC->PCON = 0x1; |
steniu01 | 0:fc6cd61e7460 | 33 | } |
steniu01 | 0:fc6cd61e7460 | 34 | |
steniu01 | 0:fc6cd61e7460 | 35 | //"Deep Power-Down" Mode |
steniu01 | 0:fc6cd61e7460 | 36 | void steven_DeepPowerDown(void) |
steniu01 | 0:fc6cd61e7460 | 37 | { |
steniu01 | 0:fc6cd61e7460 | 38 | SCB->SCR |= SCB_SCR_SLEEPDEEP_Msk; |
steniu01 | 0:fc6cd61e7460 | 39 | LPC_SC->PCON = 0x3;//// PM1=1, PM0=1, enter deep power down mode if the SLEEPDEEP bit in SCR is 1 |
steniu01 | 0:fc6cd61e7460 | 40 | __WFI(); |
steniu01 | 0:fc6cd61e7460 | 41 | //reset back to normal |
steniu01 | 0:fc6cd61e7460 | 42 | LPC_SC->PCON =0x0; |
steniu01 | 0:fc6cd61e7460 | 43 | } |
steniu01 | 0:fc6cd61e7460 | 44 | |
steniu01 | 0:fc6cd61e7460 | 45 | // "Brown-out Reduced Power mode" |
steniu01 | 0:fc6cd61e7460 | 46 | void steven_BOGD_PowerDown(void) |
steniu01 | 0:fc6cd61e7460 | 47 | { |
steniu01 | 0:fc6cd61e7460 | 48 | LPC_SC->PCON=0x1d; // PM1=0, PM0=1, enter power down mode if the SLEEPDEEP bit in SCR is 1; BOGD |
steniu01 | 0:fc6cd61e7460 | 49 | SCB->SCR |= SCB_SCR_SLEEPDEEP_Msk; |
steniu01 | 0:fc6cd61e7460 | 50 | __WFI(); |
steniu01 | 0:fc6cd61e7460 | 51 | } |
steniu01 | 0:fc6cd61e7460 | 52 |