1 /* 2 * Copyright (c) 2018 Nordic Semiconductor ASA. 3 * 4 * SPDX-License-Identifier: Apache-2.0 5 */ 6 7 #include <zephyr/init.h> 8 #include <hal/nrf_power.h> 9 board_nrf52840dongle_nrf52840_init(void)10static int board_nrf52840dongle_nrf52840_init(void) 11 { 12 13 /* if the nrf52840dongle_nrf52840 board is powered from USB 14 * (high voltage mode), GPIO output voltage is set to 1.8 volts by 15 * default and that is not enough to turn the green and blue LEDs on. 16 * Increase GPIO voltage to 3.0 volts. 17 */ 18 if ((nrf_power_mainregstatus_get(NRF_POWER) == 19 NRF_POWER_MAINREGSTATUS_HIGH) && 20 ((NRF_UICR->REGOUT0 & UICR_REGOUT0_VOUT_Msk) == 21 (UICR_REGOUT0_VOUT_DEFAULT << UICR_REGOUT0_VOUT_Pos))) { 22 23 NRF_NVMC->CONFIG = NVMC_CONFIG_WEN_Wen << NVMC_CONFIG_WEN_Pos; 24 while (NRF_NVMC->READY == NVMC_READY_READY_Busy) { 25 ; 26 } 27 28 NRF_UICR->REGOUT0 = 29 (NRF_UICR->REGOUT0 & ~((uint32_t)UICR_REGOUT0_VOUT_Msk)) | 30 (UICR_REGOUT0_VOUT_3V0 << UICR_REGOUT0_VOUT_Pos); 31 32 NRF_NVMC->CONFIG = NVMC_CONFIG_WEN_Ren << NVMC_CONFIG_WEN_Pos; 33 while (NRF_NVMC->READY == NVMC_READY_READY_Busy) { 34 ; 35 } 36 37 /* a reset is required for changes to take effect */ 38 NVIC_SystemReset(); 39 } 40 41 return 0; 42 } 43 44 SYS_INIT(board_nrf52840dongle_nrf52840_init, PRE_KERNEL_1, 45 CONFIG_KERNEL_INIT_PRIORITY_DEFAULT); 46