From f38ce1060ca231e4542619d5401e46d22a92c009 Mon Sep 17 00:00:00 2001 From: Scott Shawcroft Date: Fri, 1 Jun 2018 13:45:28 -0700 Subject: [PATCH] Support brownout to safe mode. Fixes #870 --- ports/atmel-samd/supervisor/port.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/ports/atmel-samd/supervisor/port.c b/ports/atmel-samd/supervisor/port.c index a92ab2913f..63c143c2a8 100644 --- a/ports/atmel-samd/supervisor/port.c +++ b/ports/atmel-samd/supervisor/port.c @@ -203,9 +203,16 @@ safe_mode_t port_init(void) { } #endif - // if (PM->RCAUSE.bit.BOD33 == 1 || PM->RCAUSE.bit.BOD12 == 1) { - // return BROWNOUT; - // } + #ifdef SAMD21 + if (PM->RCAUSE.bit.BOD33 == 1 || PM->RCAUSE.bit.BOD12 == 1) { + return BROWNOUT; + } + #endif + #ifdef SAMD51 + if (RSTC->RCAUSE.bit.BODVDD == 1 || RSTC->RCAUSE.bit.BODCORE == 1) { + return BROWNOUT; + } + #endif if (board_requests_safe_mode()) { return USER_SAFE_MODE;