summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRadomir Dopieralski <openstack@sheep.art.pl>2020-07-08 20:59:00 +0200
committerRadomir Dopieralski <openstack@sheep.art.pl>2020-07-09 12:17:07 +0200
commite0733d153ee159fd235794825fada7d455828007 (patch)
tree405ecc9c815d9d2fce0edac9143bc2bed18eaace
parent83a27edd20de293927e8070da8585b11cb2f8ef7 (diff)
SAMD: configurable brownout, separate the variables
-rw-r--r--ports/atmel-samd/boards/pewpew10/mpconfigboard.h2
-rw-r--r--ports/atmel-samd/boards/pewpew_m4/mpconfigboard.h3
-rw-r--r--ports/atmel-samd/mpconfigport.h14
-rw-r--r--ports/atmel-samd/supervisor/port.c10
4 files changed, 16 insertions, 13 deletions
diff --git a/ports/atmel-samd/boards/pewpew10/mpconfigboard.h b/ports/atmel-samd/boards/pewpew10/mpconfigboard.h
index 940e250b4..2cb097e8d 100644
--- a/ports/atmel-samd/boards/pewpew10/mpconfigboard.h
+++ b/ports/atmel-samd/boards/pewpew10/mpconfigboard.h
@@ -44,4 +44,4 @@
#define DEFAULT_UART_BUS_RX (&pin_PA01)
#define DEFAULT_UART_BUS_TX (&pin_PA00)
-#define BOARD_BROWNOUT_LEVEL (6)
+#define SAMD21_BOD33_LEVEL (6)
diff --git a/ports/atmel-samd/boards/pewpew_m4/mpconfigboard.h b/ports/atmel-samd/boards/pewpew_m4/mpconfigboard.h
index 7da5cf14c..4b88c89f2 100644
--- a/ports/atmel-samd/boards/pewpew_m4/mpconfigboard.h
+++ b/ports/atmel-samd/boards/pewpew_m4/mpconfigboard.h
@@ -41,5 +41,4 @@
#define IGNORE_PIN_PB10 1
#define IGNORE_PIN_PB11 1
-#define BOARD_BROWNOUT_LEVEL (6)
-// 1.6V
+#define SAMD5x_E5x_BOD33_LEVEL (100)
diff --git a/ports/atmel-samd/mpconfigport.h b/ports/atmel-samd/mpconfigport.h
index 3a5d4e1a2..540a2f77c 100644
--- a/ports/atmel-samd/mpconfigport.h
+++ b/ports/atmel-samd/mpconfigport.h
@@ -112,8 +112,11 @@
#define CIRCUITPY_DEFAULT_STACK_SIZE 4096
#endif
-#ifndef BOARD_BROWNOUT_LEVEL (
-#define BOARD_BROWNLOUT_LEVEL (39)
+#ifndef SAMD21_BOD33_LEVEL
+// Set brownout detection to ~2.7V. Default from factory is 1.7V,
+// which is too low for proper operation of external SPI flash chips
+// (they are 2.7-3.6V).
+#define SAMD21_BOD33_LEVEL (39)
// 2.77V with hysteresis off. Table 37.20 in datasheet.
#endif
@@ -134,8 +137,11 @@
#define CIRCUITPY_DEFAULT_STACK_SIZE (24*1024)
#endif
-#ifndef BOARD_BROWNOUT_LEVEL (
-#define BOARD_BROWNLOUT_LEVEL (200)
+#ifndef SAMD5x_E5x_BOD33_LEVEL
+// Set brownout detection to ~2.7V. Default from factory is 1.7V,
+// which is too low for proper operation of external SPI flash chips
+// (they are 2.7-3.6V).
+#define SAMD5x_E5x_BOD33_LEVEL (200)
// 2.7V: 1.5V + LEVEL * 6mV.
#endif
diff --git a/ports/atmel-samd/supervisor/port.c b/ports/atmel-samd/supervisor/port.c
index 5b085dc81..65501861e 100644
--- a/ports/atmel-samd/supervisor/port.c
+++ b/ports/atmel-samd/supervisor/port.c
@@ -206,11 +206,10 @@ static void rtc_init(void) {
safe_mode_t port_init(void) {
#if defined(SAMD21)
- // Set brownout detection. Default from factory is 1.7V,
- // which is too low for proper operation of external SPI flash chips (they are 2.7-3.6V).
+ // Set brownout detection.
// Disable while changing level.
SYSCTRL->BOD33.bit.ENABLE = 0;
- SYSCTRL->BOD33.bit.LEVEL = BOARD_BROWNOUT_LEVEL;
+ SYSCTRL->BOD33.bit.LEVEL = SAMD21_BOD33_LEVEL;
SYSCTRL->BOD33.bit.ENABLE = 1;
#ifdef ENABLE_MICRO_TRACE_BUFFER
@@ -225,11 +224,10 @@ safe_mode_t port_init(void) {
#endif
#if defined(SAM_D5X_E5X)
- // Set brownout detection to ~2.7V. Default from factory is 1.7V,
- // which is too low for proper operation of external SPI flash chips (they are 2.7-3.6V).
+ // Set brownout detection.
// Disable while changing level.
SUPC->BOD33.bit.ENABLE = 0;
- SUPC->BOD33.bit.LEVEL = BOARD_BROWNOUT_LEVEL;
+ SUPC->BOD33.bit.LEVEL = SAMD5x_E5x_BOD33_LEVEL;
SUPC->BOD33.bit.ENABLE = 1;
// MPU (Memory Protection Unit) setup.