2016-05-07 06:05:38 -07:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2016 Nordic Semiconductor ASA
|
|
|
|
*
|
2017-01-18 17:01:01 -08:00
|
|
|
* SPDX-License-Identifier: Apache-2.0
|
2016-05-07 06:05:38 -07:00
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @file
|
|
|
|
* @brief System/hardware module for Nordic Semiconductor nRF52 family processor
|
|
|
|
*
|
|
|
|
* This module provides routines to initialize and support board-level hardware
|
|
|
|
* for the Nordic Semiconductor nRF52 family processor.
|
|
|
|
*/
|
|
|
|
|
2016-12-23 08:35:34 -05:00
|
|
|
#include <kernel.h>
|
2016-05-07 06:05:38 -07:00
|
|
|
#include <init.h>
|
2017-01-25 09:12:00 -06:00
|
|
|
#include <cortex_m/exc.h>
|
2018-11-23 10:40:29 -06:00
|
|
|
#include <nrfx.h>
|
|
|
|
#include <soc/nrfx_coredep.h>
|
2016-05-07 06:05:38 -07:00
|
|
|
|
|
|
|
#ifdef CONFIG_RUNTIME_NMI
|
|
|
|
extern void _NmiInit(void);
|
|
|
|
#define NMI_INIT() _NmiInit()
|
|
|
|
#else
|
|
|
|
#define NMI_INIT()
|
|
|
|
#endif
|
|
|
|
|
2018-05-23 22:55:40 +02:00
|
|
|
#if defined(CONFIG_SOC_NRF52810)
|
|
|
|
#include <system_nrf52810.h>
|
|
|
|
#elif defined(CONFIG_SOC_NRF52832)
|
2018-06-18 10:35:43 +02:00
|
|
|
#include <system_nrf52.h>
|
|
|
|
#elif defined(CONFIG_SOC_NRF52840)
|
|
|
|
#include <system_nrf52840.h>
|
|
|
|
#else
|
|
|
|
#error "Unknown SoC."
|
2016-12-07 15:24:51 +01:00
|
|
|
#endif
|
|
|
|
|
2018-06-18 10:35:43 +02:00
|
|
|
#include <nrf.h>
|
|
|
|
#include <hal/nrf_power.h>
|
2016-12-07 15:10:51 +01:00
|
|
|
|
2018-09-17 10:39:56 -05:00
|
|
|
#define LOG_LEVEL CONFIG_SOC_LOG_LEVEL
|
|
|
|
#include <logging/log.h>
|
|
|
|
LOG_MODULE_REGISTER(soc);
|
|
|
|
|
2016-12-07 15:10:51 +01:00
|
|
|
static int nordicsemi_nrf52_init(struct device *arg)
|
|
|
|
{
|
2017-04-20 13:30:33 -05:00
|
|
|
u32_t key;
|
2016-12-07 15:10:51 +01:00
|
|
|
|
|
|
|
ARG_UNUSED(arg);
|
|
|
|
|
|
|
|
key = irq_lock();
|
|
|
|
|
2018-06-18 10:35:43 +02:00
|
|
|
SystemInit();
|
2018-05-28 16:14:01 +02:00
|
|
|
|
|
|
|
#ifdef CONFIG_NRF_ENABLE_ICACHE
|
|
|
|
/* Enable the instruction cache */
|
|
|
|
NRF_NVMC->ICACHECNF = NVMC_ICACHECNF_CACHEEN_Msk;
|
2016-12-07 15:24:51 +01:00
|
|
|
#endif
|
2016-12-07 15:10:51 +01:00
|
|
|
|
2018-05-24 23:19:58 +05:30
|
|
|
#if defined(CONFIG_SOC_DCDC_NRF52X)
|
|
|
|
nrf_power_dcdcen_set(true);
|
|
|
|
#endif
|
|
|
|
|
2017-01-25 09:12:00 -06:00
|
|
|
_ClearFaults();
|
2016-05-07 06:05:38 -07:00
|
|
|
|
|
|
|
/* Install default handler that simply resets the CPU
|
|
|
|
* if configured in the kernel, NOP otherwise
|
|
|
|
*/
|
|
|
|
NMI_INIT();
|
|
|
|
|
|
|
|
irq_unlock(key);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2018-11-23 10:40:29 -06:00
|
|
|
void z_arch_busy_wait(u32_t time_us)
|
|
|
|
{
|
|
|
|
nrfx_coredep_delay_us(time_us);
|
|
|
|
}
|
|
|
|
|
2016-11-08 11:06:55 -08:00
|
|
|
SYS_INIT(nordicsemi_nrf52_init, PRE_KERNEL_1, 0);
|