zephyr/boards/arm/nrf52840_pca10059/board.c
Emanuele Di Santo ef935898d0 boards: arm: add nrf52840_pca10059
This commit adds support for the nrf52840_pca10059 board.
The flash partitions are configured to allow migrating from
the stock bootloader to MCUBoot.

Signed-off-by: Emanuele Di Santo <emdi@nordicsemi.no>
2018-07-20 12:00:35 +02:00

47 lines
1.2 KiB
C

/*
* Copyright (c) 2018 Nordic Semiconductor ASA.
*
* SPDX-License-Identifier: Apache-2.0
*/
#include <init.h>
#include <board.h>
#include <nrf_power.h>
static int board_nrf52840_pca10059_init(struct device *dev)
{
ARG_UNUSED(dev);
/* if the nrf52840_pca10059 board is powered from USB
* (high voltage mode), GPIO output voltage is set to 1.8 volts by
* default and that is not enough to turn the green and blue LEDs on.
* Increase GPIO voltage to 3.0 volts.
*/
if ((nrf_power_mainregstatus_get() == NRF_POWER_MAINREGSTATUS_HIGH) &&
((NRF_UICR->REGOUT0 & UICR_REGOUT0_VOUT_Msk) ==
(UICR_REGOUT0_VOUT_DEFAULT << 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 =
(NRF_UICR->REGOUT0 & ~((uint32_t)UICR_REGOUT0_VOUT_Msk)) |
(UICR_REGOUT0_VOUT_3V0 << UICR_REGOUT0_VOUT_Pos);
NRF_NVMC->CONFIG = NVMC_CONFIG_WEN_Ren << NVMC_CONFIG_WEN_Pos;
while (NRF_NVMC->READY == NVMC_READY_READY_Busy) {
;
}
/* a reset is required for changes to take effect */
NVIC_SystemReset();
}
return 0;
}
SYS_INIT(board_nrf52840_pca10059_init, PRE_KERNEL_1,
CONFIG_KERNEL_INIT_PRIORITY_DEFAULT);