1 /* 2 * Copyright (c) 2018 Nordic Semiconductor ASA. 3 * Copyright (c) 2025 Raytac Corporation. 4 * 5 * SPDX-License-Identifier: Apache-2.0 6 */ 7 8 #include <zephyr/init.h> 9 #include <hal/nrf_power.h> 10 board_early_init_hook(void)11void board_early_init_hook(void) 12 { 13 /* if the raytac_mdbt50q_cx_40_dongle 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 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 __NOP(); 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 __NOP(); 35 } 36 37 /* a reset is required for changes to take effect */ 38 NVIC_SystemReset(); 39 } 40 } 41