Skip to content

Commit

Permalink
Merge pull request #186 from lyusupov/REGOUT0
Browse files Browse the repository at this point in the history
fix against pollution of REGOUT0 reserved bits
  • Loading branch information
hathach committed Feb 1, 2021
2 parents 15e2661 + f912559 commit 4ba802d
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/boards/boards.c
Original file line number Diff line number Diff line change
Expand Up @@ -94,11 +94,13 @@ void board_init(void)
// #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)
if ((NRF_UICR->REGOUT0 & UICR_REGOUT0_VOUT_Msk) !=
(UICR_REGOUT0_VALUE << UICR_REGOUT0_VOUT_Pos))
{
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_UICR->REGOUT0 = (NRF_UICR->REGOUT0 & ~((uint32_t)UICR_REGOUT0_VOUT_Msk)) |
(UICR_REGOUT0_VALUE << UICR_REGOUT0_VOUT_Pos);

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

0 comments on commit 4ba802d

Please sign in to comment.