Skip to content

soc: arm: nordic: provide custom busy_wait implementations #11627

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 26, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions soc/arm/nordic_nrf/nrf51/Kconfig.defconfig.series
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ config SYS_CLOCK_HW_CYCLES_PER_SEC
config SYS_POWER_MANAGEMENT
default y

config ARCH_HAS_CUSTOM_BUSY_WAIT
default y

config NUM_IRQS
int
default 26
Expand Down
14 changes: 14 additions & 0 deletions soc/arm/nordic_nrf/nrf51/soc.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@

#include <kernel.h>
#include <init.h>
#include <nrfx.h>
#include <soc/nrfx_coredep.h>

#ifdef CONFIG_RUNTIME_NMI
extern void _NmiInit(void);
Expand Down Expand Up @@ -48,4 +50,16 @@ static int nordicsemi_nrf51_init(struct device *arg)
return 0;
}

#define DELAY_CALL_OVERHEAD_US 2

void z_arch_busy_wait(u32_t time_us)
{
if (time_us <= DELAY_CALL_OVERHEAD_US) {
return;
}

time_us -= DELAY_CALL_OVERHEAD_US;
nrfx_coredep_delay_us(time_us);
}

SYS_INIT(nordicsemi_nrf51_init, PRE_KERNEL_1, 0);
3 changes: 3 additions & 0 deletions soc/arm/nordic_nrf/nrf52/Kconfig.defconfig.series
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ config SYS_CLOCK_HW_CYCLES_PER_SEC
int
default 32768

config ARCH_HAS_CUSTOM_BUSY_WAIT
default y

config SYS_POWER_MANAGEMENT
default y

Expand Down
7 changes: 7 additions & 0 deletions soc/arm/nordic_nrf/nrf52/soc.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
#include <kernel.h>
#include <init.h>
#include <cortex_m/exc.h>
#include <nrfx.h>
#include <soc/nrfx_coredep.h>

#ifdef CONFIG_RUNTIME_NMI
extern void _NmiInit(void);
Expand Down Expand Up @@ -71,4 +73,9 @@ static int nordicsemi_nrf52_init(struct device *arg)
return 0;
}

void z_arch_busy_wait(u32_t time_us)
{
nrfx_coredep_delay_us(time_us);
}

SYS_INIT(nordicsemi_nrf52_init, PRE_KERNEL_1, 0);