1 /*
2  * Copyright (c) 2016 Nordic Semiconductor ASA
3  * Copyright (c) 2016 Linaro Limited
4  *
5  * SPDX-License-Identifier: Apache-2.0
6  */
7 
8 /**
9  * @file
10  * @brief System/hardware module for Nordic Semiconductor nRF51 family processor
11  *
12  * This module provides routines to initialize and support board-level hardware
13  * for the Nordic Semiconductor nRF51 family processor.
14  */
15 
16 #include <zephyr/kernel.h>
17 #include <hal/nrf_power.h>
18 #include <soc/nrfx_coredep.h>
19 #include <zephyr/logging/log.h>
20 
21 #define LOG_LEVEL CONFIG_SOC_LOG_LEVEL
22 LOG_MODULE_REGISTER(soc);
23 
24 #ifdef CONFIG_NRF_STORE_REBOOT_TYPE_GPREGRET
25 /* Overrides the weak ARM implementation:
26  * Set general purpose retention register and reboot
27  * This is deprecated and has been replaced with the boot mode retention
28  * subsystem
29  */
sys_arch_reboot(int type)30 void sys_arch_reboot(int type)
31 {
32 	nrf_power_gpregret_set(NRF_POWER, (uint8_t)type);
33 	NVIC_SystemReset();
34 }
35 #endif
36 
37 #define DELAY_CALL_OVERHEAD_US 2
38 
arch_busy_wait(uint32_t time_us)39 void arch_busy_wait(uint32_t time_us)
40 {
41 	if (time_us <= DELAY_CALL_OVERHEAD_US) {
42 		return;
43 	}
44 
45 	time_us -= DELAY_CALL_OVERHEAD_US;
46 	nrfx_coredep_delay_us(time_us);
47 }
48