Skip to content

Commit e0733d1

Browse files
committed
SAMD: configurable brownout, separate the variables
1 parent 83a27ed commit e0733d1

File tree

4 files changed

+16
-13
lines changed

4 files changed

+16
-13
lines changed

ports/atmel-samd/boards/pewpew10/mpconfigboard.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,4 +44,4 @@
4444
#define DEFAULT_UART_BUS_RX (&pin_PA01)
4545
#define DEFAULT_UART_BUS_TX (&pin_PA00)
4646

47-
#define BOARD_BROWNOUT_LEVEL (6)
47+
#define SAMD21_BOD33_LEVEL (6)

ports/atmel-samd/boards/pewpew_m4/mpconfigboard.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,5 +41,4 @@
4141
#define IGNORE_PIN_PB10 1
4242
#define IGNORE_PIN_PB11 1
4343

44-
#define BOARD_BROWNOUT_LEVEL (6)
45-
// 1.6V
44+
#define SAMD5x_E5x_BOD33_LEVEL (100)

ports/atmel-samd/mpconfigport.h

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -112,8 +112,11 @@
112112
#define CIRCUITPY_DEFAULT_STACK_SIZE 4096
113113
#endif
114114

115-
#ifndef BOARD_BROWNOUT_LEVEL (
116-
#define BOARD_BROWNLOUT_LEVEL (39)
115+
#ifndef SAMD21_BOD33_LEVEL
116+
// Set brownout detection to ~2.7V. Default from factory is 1.7V,
117+
// which is too low for proper operation of external SPI flash chips
118+
// (they are 2.7-3.6V).
119+
#define SAMD21_BOD33_LEVEL (39)
117120
// 2.77V with hysteresis off. Table 37.20 in datasheet.
118121
#endif
119122

@@ -134,8 +137,11 @@
134137
#define CIRCUITPY_DEFAULT_STACK_SIZE (24*1024)
135138
#endif
136139

137-
#ifndef BOARD_BROWNOUT_LEVEL (
138-
#define BOARD_BROWNLOUT_LEVEL (200)
140+
#ifndef SAMD5x_E5x_BOD33_LEVEL
141+
// Set brownout detection to ~2.7V. Default from factory is 1.7V,
142+
// which is too low for proper operation of external SPI flash chips
143+
// (they are 2.7-3.6V).
144+
#define SAMD5x_E5x_BOD33_LEVEL (200)
139145
// 2.7V: 1.5V + LEVEL * 6mV.
140146
#endif
141147

ports/atmel-samd/supervisor/port.c

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -206,11 +206,10 @@ static void rtc_init(void) {
206206
safe_mode_t port_init(void) {
207207
#if defined(SAMD21)
208208

209-
// Set brownout detection. Default from factory is 1.7V,
210-
// which is too low for proper operation of external SPI flash chips (they are 2.7-3.6V).
209+
// Set brownout detection.
211210
// Disable while changing level.
212211
SYSCTRL->BOD33.bit.ENABLE = 0;
213-
SYSCTRL->BOD33.bit.LEVEL = BOARD_BROWNOUT_LEVEL;
212+
SYSCTRL->BOD33.bit.LEVEL = SAMD21_BOD33_LEVEL;
214213
SYSCTRL->BOD33.bit.ENABLE = 1;
215214

216215
#ifdef ENABLE_MICRO_TRACE_BUFFER
@@ -225,11 +224,10 @@ safe_mode_t port_init(void) {
225224
#endif
226225

227226
#if defined(SAM_D5X_E5X)
228-
// Set brownout detection to ~2.7V. Default from factory is 1.7V,
229-
// which is too low for proper operation of external SPI flash chips (they are 2.7-3.6V).
227+
// Set brownout detection.
230228
// Disable while changing level.
231229
SUPC->BOD33.bit.ENABLE = 0;
232-
SUPC->BOD33.bit.LEVEL = BOARD_BROWNOUT_LEVEL;
230+
SUPC->BOD33.bit.LEVEL = SAMD5x_E5x_BOD33_LEVEL;
233231
SUPC->BOD33.bit.ENABLE = 1;
234232

235233
// MPU (Memory Protection Unit) setup.

0 commit comments

Comments
 (0)