2016-08-26 02:38:53 +08:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2016 Nordic Semiconductor ASA
|
|
|
|
* Copyright (c) 2016 Linaro Limited
|
|
|
|
*
|
2017-01-19 09:01:01 +08:00
|
|
|
* SPDX-License-Identifier: Apache-2.0
|
2016-08-26 02:38:53 +08:00
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @file
|
|
|
|
* @brief System/hardware module for Nordic Semiconductor nRF51 family processor
|
|
|
|
*
|
|
|
|
* This module provides routines to initialize and support board-level hardware
|
|
|
|
* for the Nordic Semiconductor nRF51 family processor.
|
|
|
|
*/
|
|
|
|
|
2016-12-23 21:35:34 +08:00
|
|
|
#include <kernel.h>
|
2016-08-26 02:38:53 +08:00
|
|
|
#include <init.h>
|
2018-11-24 00:40:29 +08:00
|
|
|
#include <nrfx.h>
|
2019-01-09 20:51:36 +08:00
|
|
|
#include <nrf_power.h>
|
2018-11-24 00:40:29 +08:00
|
|
|
#include <soc/nrfx_coredep.h>
|
2019-01-18 22:53:06 +08:00
|
|
|
#include <logging/log.h>
|
2016-08-26 02:38:53 +08:00
|
|
|
|
|
|
|
#ifdef CONFIG_RUNTIME_NMI
|
2019-03-09 05:19:05 +08:00
|
|
|
extern void z_NmiInit(void);
|
|
|
|
#define NMI_INIT() z_NmiInit()
|
2016-08-26 02:38:53 +08:00
|
|
|
#else
|
|
|
|
#define NMI_INIT()
|
|
|
|
#endif
|
|
|
|
|
2018-06-18 16:35:43 +08:00
|
|
|
#include <system_nrf51.h>
|
2018-09-17 23:39:56 +08:00
|
|
|
#define LOG_LEVEL CONFIG_SOC_LOG_LEVEL
|
|
|
|
LOG_MODULE_REGISTER(soc);
|
2016-08-26 02:38:53 +08:00
|
|
|
|
2019-01-09 20:51:36 +08:00
|
|
|
/* Overrides the weak ARM implementation:
|
|
|
|
Set general purpose retention register and reboot */
|
|
|
|
void sys_arch_reboot(int type)
|
|
|
|
{
|
|
|
|
nrf_power_gpregret_set((uint8_t)type);
|
|
|
|
NVIC_SystemReset();
|
|
|
|
}
|
|
|
|
|
2016-08-26 02:38:53 +08:00
|
|
|
static int nordicsemi_nrf51_init(struct device *arg)
|
|
|
|
{
|
2017-04-21 02:30:33 +08:00
|
|
|
u32_t key;
|
2016-08-26 02:38:53 +08:00
|
|
|
|
|
|
|
ARG_UNUSED(arg);
|
|
|
|
|
|
|
|
key = irq_lock();
|
|
|
|
|
2018-06-18 16:35:43 +08:00
|
|
|
SystemInit();
|
2016-08-26 02:38:53 +08:00
|
|
|
|
|
|
|
/* Install default handler that simply resets the CPU
|
|
|
|
* if configured in the kernel, NOP otherwise
|
|
|
|
*/
|
|
|
|
NMI_INIT();
|
|
|
|
|
|
|
|
irq_unlock(key);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2016-11-09 03:06:55 +08:00
|
|
|
SYS_INIT(nordicsemi_nrf51_init, PRE_KERNEL_1, 0);
|