Skip to content

Commit 60f3993

Browse files
committed
Add POWER_SWITCH pin to CPB
1 parent 2379cd9 commit 60f3993

File tree

3 files changed

+21
-2
lines changed

3 files changed

+21
-2
lines changed

ports/nrf/boards/circuitplayground_bluefruit/board.c

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,11 @@
2525
*/
2626

2727
#include "boards/board.h"
28+
#include "mpconfigboard.h"
29+
#include "py/obj.h"
30+
#include "peripherals/nrf/pins.h"
31+
32+
#include "nrf_gpio.h"
2833

2934
void board_init(void) {
3035
}
@@ -34,5 +39,12 @@ bool board_requests_safe_mode(void) {
3439
}
3540

3641
void reset_board(void) {
37-
42+
// Turn off board.POWER_SWITCH (power-saving switch) on each soft reload, to prevent confusion.
43+
nrf_gpio_cfg(POWER_SWITCH_PIN->number,
44+
NRF_GPIO_PIN_DIR_OUTPUT,
45+
NRF_GPIO_PIN_INPUT_DISCONNECT,
46+
NRF_GPIO_PIN_NOPULL,
47+
NRF_GPIO_PIN_S0S1,
48+
NRF_GPIO_PIN_NOSENSE);
49+
nrf_gpio_pin_write(POWER_SWITCH_PIN->number, false);
3850
}

ports/nrf/boards/circuitplayground_bluefruit/mpconfigboard.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,9 @@
5454
#define SPI_FLASH_CS_PIN &pin_P0_15
5555
#endif
5656

57+
// Disables onboard peripherals and neopixels to save power.
58+
#define POWER_SWITCH_PIN (&pin_P0_06)
59+
5760
#define CIRCUITPY_AUTORELOAD_DELAY_MS 500
5861

5962
#define CIRCUITPY_INTERNAL_NVM_SIZE (4096)

ports/nrf/boards/circuitplayground_bluefruit/pins.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,12 @@ STATIC const mp_rom_map_elem_t board_module_globals_table[] = {
4848
{ MP_ROM_QSTR(MP_QSTR_SLIDE_SWITCH), MP_ROM_PTR(&pin_P1_06) },
4949
{ MP_ROM_QSTR(MP_QSTR_D7), MP_ROM_PTR(&pin_P1_06) },
5050

51-
{ MP_ROM_QSTR(MP_QSTR_D13), MP_ROM_PTR(&pin_P1_14) },
51+
// If high, turns off NeoPixels, LIS3DH, sound sensor, light sensor, temp sensor.
52+
{ MP_ROM_QSTR(MP_QSTR_POWER_SWITCH), MP_ROM_PTR(&pin_P0_06) },
53+
{ MP_ROM_QSTR(MP_QSTR_D35), MP_ROM_PTR(&pin_P0_06) },
54+
5255
{ MP_ROM_QSTR(MP_QSTR_L), MP_ROM_PTR(&pin_P1_14) },
56+
{ MP_ROM_QSTR(MP_QSTR_D13), MP_ROM_PTR(&pin_P1_14) },
5357

5458
{ MP_ROM_QSTR(MP_QSTR_NEOPIXEL), MP_ROM_PTR(&pin_P0_13) },
5559
{ MP_ROM_QSTR(MP_QSTR_D8), MP_ROM_PTR(&pin_P0_13) },

0 commit comments

Comments
 (0)