Skip to content

Commit d4b4b99

Browse files
pabigotcarlescufi
authored andcommitted
soc: arm: nordic: provide custom busy_wait implementations
Implementation taken from Nordic nrfx version 1.3.1 soc/nrfx_coredep.h, modified to remove material from other series and to conform to Zephyr coding standards. Note that unlike standard k_busy_wait this is susceptible to longer-than-intended delays due to the impact of interrupt handling. Fixes #11626 Signed-off-by: Peter A. Bigot <[email protected]>
1 parent 575bd0b commit d4b4b99

File tree

4 files changed

+27
-0
lines changed

4 files changed

+27
-0
lines changed

soc/arm/nordic_nrf/nrf51/Kconfig.defconfig.series

+3
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@ config SYS_CLOCK_HW_CYCLES_PER_SEC
2020
config SYS_POWER_MANAGEMENT
2121
default y
2222

23+
config ARCH_HAS_CUSTOM_BUSY_WAIT
24+
default y
25+
2326
config NUM_IRQS
2427
int
2528
default 26

soc/arm/nordic_nrf/nrf51/soc.c

+14
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515

1616
#include <kernel.h>
1717
#include <init.h>
18+
#include <nrfx.h>
19+
#include <soc/nrfx_coredep.h>
1820

1921
#ifdef CONFIG_RUNTIME_NMI
2022
extern void _NmiInit(void);
@@ -48,4 +50,16 @@ static int nordicsemi_nrf51_init(struct device *arg)
4850
return 0;
4951
}
5052

53+
#define DELAY_CALL_OVERHEAD_US 2
54+
55+
void z_arch_busy_wait(u32_t time_us)
56+
{
57+
if (time_us <= DELAY_CALL_OVERHEAD_US) {
58+
return;
59+
}
60+
61+
time_us -= DELAY_CALL_OVERHEAD_US;
62+
nrfx_coredep_delay_us(time_us);
63+
}
64+
5165
SYS_INIT(nordicsemi_nrf51_init, PRE_KERNEL_1, 0);

soc/arm/nordic_nrf/nrf52/Kconfig.defconfig.series

+3
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@ config SYS_CLOCK_HW_CYCLES_PER_SEC
1616
int
1717
default 32768
1818

19+
config ARCH_HAS_CUSTOM_BUSY_WAIT
20+
default y
21+
1922
config SYS_POWER_MANAGEMENT
2023
default y
2124

soc/arm/nordic_nrf/nrf52/soc.c

+7
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
#include <kernel.h>
1616
#include <init.h>
1717
#include <cortex_m/exc.h>
18+
#include <nrfx.h>
19+
#include <soc/nrfx_coredep.h>
1820

1921
#ifdef CONFIG_RUNTIME_NMI
2022
extern void _NmiInit(void);
@@ -71,4 +73,9 @@ static int nordicsemi_nrf52_init(struct device *arg)
7173
return 0;
7274
}
7375

76+
void z_arch_busy_wait(u32_t time_us)
77+
{
78+
nrfx_coredep_delay_us(time_us);
79+
}
80+
7481
SYS_INIT(nordicsemi_nrf52_init, PRE_KERNEL_1, 0);

0 commit comments

Comments
 (0)