application: fix backup writing
This commit is contained in:
parent
73bbb7974d
commit
4fa37f4957
|
@ -1638,7 +1638,7 @@ void main(void)
|
|||
DBGMCU_CR |= DBGMCU_CR_SLEEP; // allow debug also in sleep mode (keep clock powered)
|
||||
#else
|
||||
RCC_APB1ENR |= RCC_APB1ENR_BKPEN | RCC_APB1ENR_PWREN; // enable access to power register
|
||||
if (RCC_CSR & RCC_CSR_IWDGRSTF && 0x22 == BKP_DR1) { // we have been woken up by independent watchdog but actually want to stay in standby mode
|
||||
if (RCC_CSR & RCC_CSR_IWDGRSTF && 0x00ff == BKP_DR1) { // we have been woken up by independent watchdog but actually want to stay in standby mode
|
||||
RCC_CSR |= RCC_CSR_RMVF; // clear reset flags
|
||||
// the reset will have clearer the software set watchdog
|
||||
standby(); // go to standby (e.g. shut down)
|
||||
|
@ -1646,7 +1646,9 @@ void main(void)
|
|||
// setup watchdog to reset in case we get stuck (i.e. when an error occurred)
|
||||
iwdg_set_period_ms(WATCHDOG_PERIOD); // set independent watchdog period
|
||||
iwdg_start(); // start independent watchdog
|
||||
PWR_CR |= PWR_CR_DBP; // disable backup domain write protection
|
||||
BKP_DR1 = 0; // clear backup register to not indicate we want to stay in stand by
|
||||
PWR_CR &= ~PWR_CR_DBP; // enable backup domain write protection
|
||||
#endif
|
||||
|
||||
board_setup(); // setup board
|
||||
|
@ -1954,7 +1956,8 @@ test_end:
|
|||
} // !interactive
|
||||
while (!interactive && rtc_get_counter_val() >= last_connect_time + SHUTDOWN_TIMEOUT) { // time to shut down
|
||||
#if !DEBUG
|
||||
BKP_DR1 = 0x22; // indicate we want to stay in standby mode (it's not possible to disable the independent watchdog and it will reset the system even in standby mode
|
||||
PWR_CR |= PWR_CR_DBP; // disable backup domain write protection
|
||||
BKP_DR1 = 0x00ff; // indicate we want to stay in standby mode (it's not possible to disable the independent watchdog and it will reset the system even in standby mode
|
||||
#endif
|
||||
display_off(); // cut power to displays (at stop D+ pull-up to indicate disconnect)
|
||||
standby(); // go into standby mode (shut down)
|
||||
|
|
Loading…
Reference in New Issue