Skip to content

Commit

Permalink
Merge pull request #177 from mmoskal/power_cfg
Browse files Browse the repository at this point in the history
Allow for power supply configuration
  • Loading branch information
hathach committed Dec 8, 2020
2 parents b39cd8f + 6fc2145 commit eab7e68
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 0 deletions.
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

0 comments on commit eab7e68

Please sign in to comment.