Skip to content
Draft
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
4 changes: 1 addition & 3 deletions drivers/clock_control/clock_control_nrf.c
Original file line number Diff line number Diff line change
Expand Up @@ -800,7 +800,6 @@ static void hfclkaudio_init(void)

static int clk_init(const struct device *dev)
{
nrfx_err_t nrfx_err;
int err;
static const struct onoff_transitions transitions = {
.start = onoff_start,
Expand All @@ -814,8 +813,7 @@ static int clk_init(const struct device *dev)
IRQ_CONNECT(DT_INST_IRQN(0), DT_INST_IRQ(0, priority),
nrfx_isr, nrfx_power_clock_irq_handler, 0);

nrfx_err = nrfx_clock_init(clock_event_handler);
if (nrfx_err != NRFX_SUCCESS) {
if (nrfx_clock_init(clock_event_handler) != 0) {
return -EIO;
}

Expand Down
70 changes: 20 additions & 50 deletions drivers/timer/nrf_grtc_timer.c
Original file line number Diff line number Diff line change
Expand Up @@ -93,16 +93,7 @@ static inline uint64_t counter(void)

static inline int get_comparator(uint32_t chan, uint64_t *cc)
{
nrfx_err_t result;

result = nrfx_grtc_syscounter_cc_value_read(chan, cc);
if (result != NRFX_SUCCESS) {
if (result != NRFX_ERROR_INVALID_PARAM) {
return -EAGAIN;
}
return -EPERM;
}
return 0;
return nrfx_grtc_syscounter_cc_value_read(chan, cc);
}

/*
Expand Down Expand Up @@ -173,14 +164,14 @@ static void sys_clock_timeout_handler(int32_t id, uint64_t cc_val, void *p_conte
int32_t z_nrf_grtc_timer_chan_alloc(void)
{
uint8_t chan;
nrfx_err_t err_code;
int err_code;

/* Prevent allocating all available channels - one must be left for system purposes. */
if (ext_channels_allocated >= EXT_CHAN_COUNT) {
return -ENOMEM;
}
err_code = nrfx_grtc_channel_alloc(&chan);
if (err_code != NRFX_SUCCESS) {
if (err_code < 0) {
return -ENOMEM;
}
ext_channels_allocated++;
Expand All @@ -190,9 +181,9 @@ int32_t z_nrf_grtc_timer_chan_alloc(void)
void z_nrf_grtc_timer_chan_free(int32_t chan)
{
IS_CHANNEL_ALLOWED_ASSERT(chan);
nrfx_err_t err_code = nrfx_grtc_channel_free(chan);
int err_code = nrfx_grtc_channel_free(chan);

if (err_code == NRFX_SUCCESS) {
if (err_code == 0) {
ext_channels_allocated--;
}
}
Expand Down Expand Up @@ -249,19 +240,13 @@ int z_nrf_grtc_timer_compare_read(int32_t chan, uint64_t *val)
static int compare_set_nolocks(int32_t chan, uint64_t target_time,
z_nrf_grtc_timer_compare_handler_t handler, void *user_data)
{
nrfx_err_t result;

__ASSERT_NO_MSG(target_time < COUNTER_SPAN);
nrfx_grtc_channel_t user_channel_data = {
.handler = handler,
.p_context = user_data,
.channel = chan,
};
result = nrfx_grtc_syscounter_cc_absolute_set(&user_channel_data, target_time, true);
if (result != NRFX_SUCCESS) {
return -EPERM;
}
return 0;
return nrfx_grtc_syscounter_cc_absolute_set(&user_channel_data, target_time, true);
}

static int compare_set(int32_t chan, uint64_t target_time,
Expand Down Expand Up @@ -314,31 +299,22 @@ int z_nrf_grtc_timer_capture_prepare(int32_t chan)
.p_context = NULL,
.channel = chan,
};
nrfx_err_t result;

IS_CHANNEL_ALLOWED_ASSERT(chan);

/* Set the CC value to mark channel as not triggered and also to enable it
* (makes CCEN=1). COUNTER_SPAN is used so as not to fire an event unnecessarily
* - it can be assumed that such a large value will never be reached.
*/
result = nrfx_grtc_syscounter_cc_absolute_set(&user_channel_data, COUNTER_SPAN, false);

if (result != NRFX_SUCCESS) {
return -EPERM;
}

return 0;
return nrfx_grtc_syscounter_cc_absolute_set(&user_channel_data, COUNTER_SPAN, false);
}

int z_nrf_grtc_timer_capture_read(int32_t chan, uint64_t *captured_time)
{
/* TODO: The implementation should probably go to nrfx_grtc and this
* should be just a wrapper for some nrfx_grtc_syscounter_capture_read.
*/

uint64_t capt_time;
nrfx_err_t result;
int result;

IS_CHANNEL_ALLOWED_ASSERT(chan);

Expand All @@ -349,14 +325,8 @@ int z_nrf_grtc_timer_capture_read(int32_t chan, uint64_t *captured_time)
*/
return -EBUSY;
}
result = nrfx_grtc_syscounter_cc_value_read(chan, &capt_time);
if (result != NRFX_SUCCESS) {
return -EPERM;
}

__ASSERT_NO_MSG(capt_time < COUNTER_SPAN);

*captured_time = capt_time;
result = nrfx_grtc_syscounter_cc_value_read(chan, captured_time);
__ASSERT_NO_MSG(*captured_time < COUNTER_SPAN);

return 0;
}
Expand All @@ -369,7 +339,7 @@ uint64_t z_nrf_grtc_timer_startup_value_get(void)
#if defined(CONFIG_POWEROFF) && defined(CONFIG_NRF_GRTC_START_SYSCOUNTER)
int z_nrf_grtc_wakeup_prepare(uint64_t wake_time_us)
{
nrfx_err_t err_code;
int err_code;
static uint8_t systemoff_channel;
uint64_t now = counter();
nrfx_grtc_sleep_config_t sleep_cfg;
Expand All @@ -392,9 +362,9 @@ int z_nrf_grtc_wakeup_prepare(uint64_t wake_time_us)
k_spinlock_key_t key = k_spin_lock(&lock);

err_code = nrfx_grtc_channel_alloc(&systemoff_channel);
if (err_code != NRFX_SUCCESS) {
if (err_code < 0) {
k_spin_unlock(&lock, key);
return -ENOMEM;
return err_code;
}
(void)nrfx_grtc_syscounter_cc_int_disable(systemoff_channel);
ret = compare_set(systemoff_channel,
Expand Down Expand Up @@ -459,7 +429,7 @@ uint32_t sys_clock_elapsed(void)

static int sys_clock_driver_init(void)
{
nrfx_err_t err_code;
int err_code;

IRQ_CONNECT(DT_IRQN(GRTC_NODE), DT_IRQ(GRTC_NODE, priority), nrfx_isr,
nrfx_grtc_irq_handler, 0);
Expand All @@ -477,19 +447,19 @@ static int sys_clock_driver_init(void)
#endif

err_code = nrfx_grtc_init(0);
if (err_code != NRFX_SUCCESS) {
return -EPERM;
if (err_code < 0) {
return err_code;
}

#if defined(CONFIG_NRF_GRTC_START_SYSCOUNTER)
err_code = nrfx_grtc_syscounter_start(true, &system_clock_channel_data.channel);
if (err_code != NRFX_SUCCESS) {
return err_code == NRFX_ERROR_NO_MEM ? -ENOMEM : -EPERM;
if (err_code < 0) {
return err_code;
}
#else
err_code = nrfx_grtc_channel_alloc(&system_clock_channel_data.channel);
if (err_code != NRFX_SUCCESS) {
return -ENOMEM;
if (err_code < 0) {
return err_code;
}
#endif /* CONFIG_NRF_GRTC_START_SYSCOUNTER */

Expand Down
12 changes: 5 additions & 7 deletions modules/hal_nordic/nrfx/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -130,22 +130,22 @@ zephyr_library_sources_ifdef(CONFIG_HAS_NORDIC_RAM_CTRL ${HELPERS_DIR}/nrf
if(CONFIG_NRFX_GPPI)
zephyr_library_sources_ifdef(CONFIG_NRFX_GPPI_V1 ${HELPERS_DIR}/internal/nrfx_gppiv1_shim.c)
if(CONFIG_HAS_HW_NRF_PPI)
zephyr_library_sources_ifdef(CONFIG_NRFX_GPPI_V1 ${HELPERS_DIR}/internal/nrfx_gppiv1_ppi.c)
zephyr_library_sources_ifdef(CONFIG_NRFX_GPPI_V1 ${HELPERS_DIR}/internal/nrfx_ppi.c)
zephyr_library_sources_ifndef(CONFIG_NRFX_GPPI_V1 ${HELPERS_DIR}/nrfx_gppi_ppi.c)
else()
zephyr_library_sources_ifdef(CONFIG_NRFX_GPPI_V1 ${HELPERS_DIR}/internal/nrfx_gppiv1_dppi.c)
zephyr_library_sources_ifndef(CONFIG_NRFX_GPPI_V1 ${HELPERS_DIR}/nrfx_gppi_dppi.c)
zephyr_library_sources_ifdef(CONFIG_NRFX_GPPI_V1 ${HELPERS_DIR}/internal/nrfx_dppi.c)
endif()
endif()

zephyr_library_sources_ifdef(CONFIG_NRFX_PRS ${SRC_DIR}/prs/nrfx_prs.c)

zephyr_library_sources_ifdef(CONFIG_NRFX_ADC ${SRC_DIR}/nrfx_adc.c)
zephyr_library_sources_ifdef(CONFIG_NRFX_CLOCK ${SRC_DIR}/nrfx_clock.c)
zephyr_library_sources_ifdef(CONFIG_NRFX_CLOCK ${SRC_DIR}/nrfx_clock_lfclk.c)
zephyr_library_sources_ifdef(CONFIG_NRFX_CLOCK ${SRC_DIR}/nrfx_clock_hfclk.c)
zephyr_library_sources_ifdef(CONFIG_NRFX_CLOCK ${SRC_DIR}/nrfx_clock_xo.c)
zephyr_library_sources_ifdef(CONFIG_NRFX_CLOCK ${SRC_DIR}/nrfx_clock_lfclk.c)
zephyr_library_sources_ifdef(CONFIG_NRFX_CLOCK ${SRC_DIR}/nrfx_clock_hfclk192m.c)
zephyr_library_sources_ifdef(CONFIG_NRFX_CLOCK ${SRC_DIR}/nrfx_clock_hfclkaudio.c)
zephyr_library_sources_ifdef(CONFIG_NRFX_COMP ${SRC_DIR}/nrfx_comp.c)
zephyr_library_sources_ifdef(CONFIG_NRFX_CRACEN ${SRC_DIR}/nrfx_cracen.c)
zephyr_library_sources_ifdef(CONFIG_NRFX_EGU ${SRC_DIR}/nrfx_egu.c)
Expand Down Expand Up @@ -220,9 +220,7 @@ zephyr_compile_definitions_ifdef(CONFIG_SOC_NRF54LX_SKIP_GLITCHDETECTOR_DISABLE
zephyr_compile_definitions_ifndef(CONFIG_SOC_NRF54L_ANOMALY_56_WORKAROUND NRF54L_CONFIGURATION_56_ENABLE=0)

if(CONFIG_SOC_COMPATIBLE_NRF54LX AND CONFIG_NRFX_GPPI)
zephyr_library_sources_ifdef(CONFIG_NRFX_GPPI_V1 ${HELPERS_DIR}/internal/nrfx_gppiv1_ppib.c)
zephyr_library_sources_ifdef(CONFIG_NRFX_GPPI_V1 ${HELPERS_DIR}/internal/nrfx_ppib.c)
zephyr_library_sources_ifndef(CONFIG_NRFX_GPPI_V1 ${HELPERS_DIR}/nrfx_gppi_lumos.c)
zephyr_library_sources_ifndef(CONFIG_NRFX_GPPI_V1 ${BSP_DIR}/soc/interconnect/nrfx_gppi_lumos.c)
endif()

if(CONFIG_SOC_SERIES_NRF54HX AND CONFIG_NRFX_GPPI_V1)
Expand Down
4 changes: 2 additions & 2 deletions modules/hal_nordic/nrfx/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -417,10 +417,10 @@ config NRFX_SPI2
select NRFX_SPI

config NRFX_SPIM
bool
bool "SPIM driver"

config NRFX_SPIS
bool
bool "SPIS driver"

config NRFX_SYSTICK
bool "SYSTICK driver"
Expand Down
2 changes: 1 addition & 1 deletion modules/hal_nordic/nrfx/nrfx_glue.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

void nrfx_isr(const void *irq_handler)
{
((nrfx_irq_handler_t)irq_handler)();
((nrfx_irq_handler_t)irq_handler)(NULL);
}

void nrfx_busy_wait(uint32_t usec_to_wait)
Expand Down
1 change: 0 additions & 1 deletion samples/net/zperf/src/nrf5340_cpu_boost.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ static int nrf53_cpu_boost(void)

/* For optimal performance, the CPU frequency should be set to 128 MHz */
err = nrfx_clock_divider_set(NRF_CLOCK_DOMAIN_HFCLK, NRF_CLOCK_HFCLK_DIV_1);
err -= NRFX_ERROR_BASE_NUM;
if (err != 0) {
LOG_WRN("Failed to set 128 MHz: %d", err);
}
Expand Down
5 changes: 1 addition & 4 deletions scripts/pylib/twister/twisterlib/coverage.py
Original file line number Diff line number Diff line change
Expand Up @@ -413,10 +413,9 @@ def collect_coverage(self, outdir, coverage_file, ztest_file, coveragelog):
# We want to remove tests/* and tests/ztest/test/* but save tests/ztest
cmd = ["gcovr", "-r", self.base_dir,
"--gcov-ignore-parse-errors=negative_hits.warn_once_per_file",
"--gcov-ignore-parse-errors=suspicious_hits.warn_once_per_file",
"--gcov-executable", self.gcov_tool,
"-e", "tests/*"]
if self.version >= "7.0":
cmd += ["--gcov-object-directory", outdir]
cmd += excludes + self.options + ["--json", "-o", coverage_file, outdir]
cmd_str = " ".join(cmd)
logger.debug(f"Running: {cmd_str}")
Expand All @@ -431,8 +430,6 @@ def collect_coverage(self, outdir, coverage_file, ztest_file, coveragelog):
cmd += ["--gcov-executable", self.gcov_tool,
"-f", "tests/ztest", "-e", "tests/ztest/test/*",
"--json", "-o", ztest_file, outdir]
if self.version >= "7.0":
cmd += ["--gcov-object-directory", outdir]

cmd_str = " ".join(cmd)
logger.debug(f"Running: {cmd_str}")
Expand Down
2 changes: 1 addition & 1 deletion soc/nordic/nrf54l/soc.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
#include <lib/nrfx_coredep.h>
#include <soc.h>
#include <helpers/nrfx_gppi.h>
#include <helpers/nrfx_gppi_lumos.h>
#include "../../../../nrfx/bsp/stable/soc/interconnect/nrfx_gppi_lumos.h"
LOG_MODULE_REGISTER(soc, CONFIG_SOC_LOG_LEVEL);

#if (defined(NRF_APPLICATION) && !defined(CONFIG_TRUSTED_EXECUTION_NONSECURE)) || \
Expand Down
1 change: 0 additions & 1 deletion subsys/bluetooth/audio/shell/bap_usb.c
Original file line number Diff line number Diff line change
Expand Up @@ -738,7 +738,6 @@ int bap_usb_init(void)
*/
err = nrfx_clock_divider_set(NRF_CLOCK_DOMAIN_HFCLK, NRF_CLOCK_HFCLK_DIV_1);

err -= NRFX_ERROR_BASE_NUM;
if (err != 0) {
LOG_WRN("Failed to set 128 MHz: %d", err);
}
Expand Down
6 changes: 3 additions & 3 deletions west.yml
Original file line number Diff line number Diff line change
Expand Up @@ -199,9 +199,9 @@ manifest:
path: modules/hal/microchip
groups:
- hal
- name: hal_nordic
url: https://github.com/nrfconnect/sdk-hal_nordic
revision: a74256b731c022fbe7576a76b6bb62815ec1f08f
- name: sdk-hal_nordic
url: https://github.com/mib1-nordic/sdk-hal_nordic
revision: align_nrfx_examples
path: modules/hal/nordic
groups:
- hal
Expand Down