Skip to content

Commit

Permalink
Fix for Isse microsoft#88: check BOD as well as POR when checking for…
Browse files Browse the repository at this point in the history
… double-click reset to invoke boot loader. Works for SAMD21, not sure about SAMD51.
  • Loading branch information
JetForMe committed Mar 14, 2020
1 parent df89a1f commit 45c6e94
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -119,12 +119,15 @@ static void check_start_application(void) {
}
#endif

if (RESET_CONTROLLER->RCAUSE.bit.POR) {
if (RESET_CONTROLLER->RCAUSE.bit.POR // If power-on reset
|| RESET_CONTROLLER->RCAUSE.bit.BOD12 // or either brown-out
|| RESET_CONTROLLER->RCAUSE.bit.BOD33 ) { // reset, clear *DBL_TAP_PTR
*DBL_TAP_PTR = 0;
} else if (*DBL_TAP_PTR == DBL_TAP_MAGIC) {
} else if (RESET_CONTROLLER->RCAUSE.bit.EXT // If user pressed reset button
&& *DBL_TAP_PTR == DBL_TAP_MAGIC) { // AND it’s the second time through
*DBL_TAP_PTR = 0;
return; // stay in bootloader
} else {
} else { // This should probably check RESET_CONTROLLER->RCAUSE.bit.EXT, too
if (*DBL_TAP_PTR != DBL_TAP_MAGIC_QUICK_BOOT) {
*DBL_TAP_PTR = DBL_TAP_MAGIC;
delay(500);
Expand Down

0 comments on commit 45c6e94

Please sign in to comment.