Skip to content

Commit 88ca7ff

Browse files
committed
stmhal/modmachine: Fix clearing of reset-cause flags.
To reset the flags we should write to the single bit only, not the entire register (otherwise all other settings in the register are cleared). Fixes adafruit#2457.
1 parent 7385b01 commit 88ca7ff

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

stmhal/modmachine.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ void machine_init(void) {
6868
if (PWR->CSR & PWR_CSR_SBF) {
6969
// came out of standby
7070
reset_cause = PYB_RESET_DEEPSLEEP;
71-
PWR->CR = PWR_CR_CSBF;
71+
PWR->CR |= PWR_CR_CSBF;
7272
} else
7373
#endif
7474
{
@@ -86,7 +86,7 @@ void machine_init(void) {
8686
}
8787
}
8888
// clear RCC reset flags
89-
RCC->CSR = RCC_CSR_RMVF;
89+
RCC->CSR |= RCC_CSR_RMVF;
9090
}
9191

9292
// machine.info([dump_alloc_table])

0 commit comments

Comments
 (0)