Skip to content

Commit eab7e68

Browse files
authored
Merge pull request #177 from mmoskal/power_cfg
Allow for power supply configuration
2 parents b39cd8f + 6fc2145 commit eab7e68

File tree

2 files changed

+33
-0
lines changed

2 files changed

+33
-0
lines changed

src/boards/boards.c

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,31 @@ void board_init(void)
8282
neopixel_init();
8383
#endif
8484

85+
#if ENABLE_DCDC_0 == 1
86+
NRF_POWER->DCDCEN0 = 1;
87+
#endif
88+
#if ENABLE_DCDC_1 == 1
89+
NRF_POWER->DCDCEN = 1;
90+
#endif
91+
92+
// When board is supplied on VDDH (and not VDD), this specifies what voltage the GPIO should run at
93+
// and what voltage is output at VDD. The default (0xffffffff) is 1.8V; typically you'll want
94+
// #define UICR_REGOUT0_VALUE UICR_REGOUT0_VOUT_3V3
95+
// in board.h when using that power configuration.
96+
#ifdef UICR_REGOUT0_VALUE
97+
if (NRF_UICR->REGOUT0 != UICR_REGOUT0_VALUE)
98+
{
99+
NRF_NVMC->CONFIG = NVMC_CONFIG_WEN_Wen << NVMC_CONFIG_WEN_Pos;
100+
while (NRF_NVMC->READY == NVMC_READY_READY_Busy){}
101+
NRF_UICR->REGOUT0 = UICR_REGOUT0_VALUE;
102+
103+
NRF_NVMC->CONFIG = NVMC_CONFIG_WEN_Ren << NVMC_CONFIG_WEN_Pos;
104+
while (NRF_NVMC->READY == NVMC_READY_READY_Busy){}
105+
106+
NVIC_SystemReset();
107+
}
108+
#endif
109+
85110
// Init scheduler
86111
APP_SCHED_INIT(SCHED_MAX_EVENT_DATA_SIZE, SCHED_QUEUE_SIZE);
87112

src/boards/boards.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,14 @@
6161
#define BOARD_RGB_BRIGHTNESS 0x101010
6262
#endif
6363

64+
// Power configuration - should we enable DC/DC converters? (requires inductors on board)
65+
#ifndef ENABLE_DCDC_0
66+
#define ENABLE_DCDC_0 0
67+
#endif
68+
#ifndef ENABLE_DCDC_1
69+
#define ENABLE_DCDC_1 0
70+
#endif
71+
6472
// Helper function
6573
#define memclr(buffer, size) memset(buffer, 0, size)
6674
#define varclr(_var) memclr(_var, sizeof(*(_var)))

0 commit comments

Comments
 (0)