|
| 1 | +/* mbed Microcontroller Library |
| 2 | + * Copyright (c) 2021 ARM Limited |
| 3 | + * Copyright (c) 2021 Embedded Planet, Inc. |
| 4 | + * SPDX-License-Identifier: Apache-2.0 |
| 5 | + * |
| 6 | + * Licensed under the Apache License, Version 2.0 (the "License"); |
| 7 | + * you may not use this file except in compliance with the License. |
| 8 | + * You may obtain a copy of the License at |
| 9 | + * |
| 10 | + * http://www.apache.org/licenses/LICENSE-2.0 |
| 11 | + * |
| 12 | + * Unless required by applicable law or agreed to in writing, software |
| 13 | + * distributed under the License is distributed on an "AS IS" BASIS, |
| 14 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 15 | + * See the License for the specific language governing permissions and |
| 16 | + * limitations under the License. |
| 17 | + */ |
| 18 | + |
| 19 | +#include "mbed_boot.h" |
| 20 | + |
| 21 | +#include "nrf.h" |
| 22 | + |
| 23 | +/** |
| 24 | + * Override the mbed sdk init startup hook |
| 25 | + * This will configure the internal regulator to operate at 3.3V |
| 26 | + * It also configures the nRF to use the on-board DC/DC for |
| 27 | + * lower power consumption |
| 28 | + */ |
| 29 | +void mbed_sdk_init(void) { |
| 30 | + |
| 31 | + if (NRF_UICR->REGOUT0 != UICR_REGOUT0_VOUT_3V3) |
| 32 | + { |
| 33 | + NRF_NVMC->CONFIG = NVMC_CONFIG_WEN_Wen << NVMC_CONFIG_WEN_Pos; |
| 34 | + while (NRF_NVMC->READY == NVMC_READY_READY_Busy){} |
| 35 | + NRF_UICR->REGOUT0 = UICR_REGOUT0_VOUT_3V3; |
| 36 | + NRF_NVMC->CONFIG = NVMC_CONFIG_WEN_Ren << NVMC_CONFIG_WEN_Pos; |
| 37 | + while (NRF_NVMC->READY == NVMC_READY_READY_Busy){} |
| 38 | + |
| 39 | + // Trigger a soft reset so that the settings take effect |
| 40 | + NVIC_SystemReset(); |
| 41 | + } |
| 42 | + |
| 43 | + /* Set to use DC/DC */ |
| 44 | + NRF_POWER->DCDCEN = 1; |
| 45 | + |
| 46 | +} |
| 47 | + |
| 48 | + |
0 commit comments