Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow for power supply configuration #177

Merged
merged 1 commit into from
Dec 8, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions src/boards/boards.c
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,31 @@ void board_init(void)
neopixel_init();
#endif

#if ENABLE_DCDC_0 == 1
NRF_POWER->DCDCEN0 = 1;
#endif
#if ENABLE_DCDC_1 == 1
NRF_POWER->DCDCEN = 1;
#endif

// When board is supplied on VDDH (and not VDD), this specifies what voltage the GPIO should run at
// and what voltage is output at VDD. The default (0xffffffff) is 1.8V; typically you'll want
// #define UICR_REGOUT0_VALUE UICR_REGOUT0_VOUT_3V3
// in board.h when using that power configuration.
#ifdef UICR_REGOUT0_VALUE
if (NRF_UICR->REGOUT0 != UICR_REGOUT0_VALUE)
{
NRF_NVMC->CONFIG = NVMC_CONFIG_WEN_Wen << NVMC_CONFIG_WEN_Pos;
while (NRF_NVMC->READY == NVMC_READY_READY_Busy){}
NRF_UICR->REGOUT0 = UICR_REGOUT0_VALUE;

NRF_NVMC->CONFIG = NVMC_CONFIG_WEN_Ren << NVMC_CONFIG_WEN_Pos;
while (NRF_NVMC->READY == NVMC_READY_READY_Busy){}

NVIC_SystemReset();
}
#endif

// Init scheduler
APP_SCHED_INIT(SCHED_MAX_EVENT_DATA_SIZE, SCHED_QUEUE_SIZE);

Expand Down
8 changes: 8 additions & 0 deletions src/boards/boards.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,14 @@
#define BOARD_RGB_BRIGHTNESS 0x101010
#endif

// Power configuration - should we enable DC/DC converters? (requires inductors on board)
#ifndef ENABLE_DCDC_0
#define ENABLE_DCDC_0 0
#endif
#ifndef ENABLE_DCDC_1
#define ENABLE_DCDC_1 0
#endif

// Helper function
#define memclr(buffer, size) memset(buffer, 0, size)
#define varclr(_var) memclr(_var, sizeof(*(_var)))
Expand Down