diff options
| author | Dan Halbert <halbert@adafruit.com> | 2020-07-13 16:26:11 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-07-13 16:26:11 -0400 |
| commit | 3fcd999130fcd87ccbabb65dbe6a6a6cadc08d90 (patch) | |
| tree | f14e29514c48a9b0b30dec9d32a08916d3d059b2 | |
| parent | b81195d1d576ad5536ff3a2fcdf538a83d099f54 (diff) | |
| parent | e0733d153ee159fd235794825fada7d455828007 (diff) | |
Merge pull request #3130 from pewpew-game/brownout-level
SAMD: make the brownout detection level configurable per board
| -rw-r--r-- | ports/atmel-samd/boards/pewpew10/mpconfigboard.h | 2 | ||||
| -rw-r--r-- | ports/atmel-samd/boards/pewpew_m4/mpconfigboard.h | 2 | ||||
| -rw-r--r-- | ports/atmel-samd/mpconfigport.h | 16 | ||||
| -rw-r--r-- | ports/atmel-samd/supervisor/port.c | 10 |
4 files changed, 24 insertions, 6 deletions
diff --git a/ports/atmel-samd/boards/pewpew10/mpconfigboard.h b/ports/atmel-samd/boards/pewpew10/mpconfigboard.h index 6b3b4aa15..2cb097e8d 100644 --- a/ports/atmel-samd/boards/pewpew10/mpconfigboard.h +++ b/ports/atmel-samd/boards/pewpew10/mpconfigboard.h @@ -43,3 +43,5 @@ #define DEFAULT_UART_BUS_RX (&pin_PA01) #define DEFAULT_UART_BUS_TX (&pin_PA00) + +#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 60cd8d754..4b88c89f2 100644 --- a/ports/atmel-samd/boards/pewpew_m4/mpconfigboard.h +++ b/ports/atmel-samd/boards/pewpew_m4/mpconfigboard.h @@ -40,3 +40,5 @@ #define IGNORE_PIN_PB09 1 #define IGNORE_PIN_PB10 1 #define IGNORE_PIN_PB11 1 + +#define SAMD5x_E5x_BOD33_LEVEL (100) diff --git a/ports/atmel-samd/mpconfigport.h b/ports/atmel-samd/mpconfigport.h index 354097ce4..540a2f77c 100644 --- a/ports/atmel-samd/mpconfigport.h +++ b/ports/atmel-samd/mpconfigport.h @@ -112,6 +112,14 @@ #define CIRCUITPY_DEFAULT_STACK_SIZE 4096 #endif +#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 + // Smallest unit of flash that can be erased. #define FLASH_ERASE_SIZE NVMCTRL_ROW_SIZE @@ -129,6 +137,14 @@ #define CIRCUITPY_DEFAULT_STACK_SIZE (24*1024) #endif +#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 + // Smallest unit of flash that can be erased. #define FLASH_ERASE_SIZE NVMCTRL_BLOCK_SIZE diff --git a/ports/atmel-samd/supervisor/port.c b/ports/atmel-samd/supervisor/port.c index e892e6cde..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 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. SYSCTRL->BOD33.bit.ENABLE = 0; - SYSCTRL->BOD33.bit.LEVEL = 39; // 2.77V with hysteresis off. Table 37.20 in datasheet. + 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 = 200; // 2.7V: 1.5V + LEVEL * 6mV. + SUPC->BOD33.bit.LEVEL = SAMD5x_E5x_BOD33_LEVEL; SUPC->BOD33.bit.ENABLE = 1; // MPU (Memory Protection Unit) setup. |
