Fixes #2790: power on/off lop if big VCC capcitor was used

This commit is contained in:
Damjan Adamic
2015-08-28 18:07:24 +02:00
parent 7befb457f2
commit e4f7fd910c
2 changed files with 40 additions and 25 deletions
+16 -20
View File
@@ -87,29 +87,25 @@ void pwrOff()
// disable interrupts
__disable_irq();
#if defined(REV9E)
// 9E needs watchdog reset because CPU is still running while
// the power key is held pressed by the user.
// The power key should be released by now, but we must make sure
while (pwrPressed()) {
wdt_reset();
}
// Put the CPU into sleep to reduce the consumption,
// it might help with the RTC reset issue
PWR->CR |= PWR_CR_CWUF;
/* Select STANDBY mode */
PWR->CR |= PWR_CR_PDDS;
/* Set SLEEPDEEP bit of Cortex System Control Register */
SCB->SCR |= SCB_SCR_SLEEPDEEP_Msk;
/* Request Wait For Event */
__WFE();
#endif
while(1) {
wdt_reset();
#if defined(REV9E)
// 9E needs watchdog reset because CPU is still running while
// the power key is held pressed by the user.
// The power key should be released by now, but we must make sure
if (!pwrPressed()) {
// Put the CPU into sleep to reduce the consumption,
// it might help with the RTC reset issue
PWR->CR |= PWR_CR_CWUF;
/* Select STANDBY mode */
PWR->CR |= PWR_CR_PDDS;
/* Set SLEEPDEEP bit of Cortex System Control Register */
SCB->SCR |= SCB_SCR_SLEEPDEEP_Msk;
/* Request Wait For Event */
__WFE();
}
#endif
}
//this function must not return!
}