Skip to content

Commit

Permalink
modules: hal_nordic: align to multi-instance DPPI API
Browse files Browse the repository at this point in the history
The nrfx_dppi driver now supports multiple instances. Align all uses of
the API to the new version.

Signed-off-by: Rafał Kuźnia <[email protected]>
  • Loading branch information
e-rk committed Oct 15, 2024
1 parent 7af7de8 commit 1a6b18b
Show file tree
Hide file tree
Showing 5 changed files with 127 additions and 10 deletions.
12 changes: 8 additions & 4 deletions drivers/counter/counter_nrfx_rtc.c
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,10 @@ LOG_MODULE_REGISTER(LOG_MODULE_NAME, CONFIG_COUNTER_LOG_LEVEL);
#define MAYBE_CONST_CONFIG const
#endif

#if defined(CONFIG_COUNTER_RTC_WITH_PPI_WRAP) && defined(DPPI_PRESENT)
static nrfx_dppi_t dppi = NRFX_DPPI_INSTANCE(0);
#endif

struct counter_nrfx_data {
counter_top_callback_t top_cb;
void *top_user_data;
Expand Down Expand Up @@ -387,15 +391,15 @@ static int ppi_setup(const struct device *dev, uint8_t chan)

nrfy_rtc_event_enable(rtc, NRF_RTC_CHANNEL_INT_MASK(chan));
#ifdef DPPI_PRESENT
result = nrfx_dppi_channel_alloc(&data->ppi_ch);
result = nrfx_dppi_channel_alloc(&dppi, &data->ppi_ch);
if (result != NRFX_SUCCESS) {
ERR("Failed to allocate PPI channel.");
return -ENODEV;
}

nrfy_rtc_subscribe_set(rtc, NRF_RTC_TASK_CLEAR, data->ppi_ch);
nrfy_rtc_publish_set(rtc, evt, data->ppi_ch);
(void)nrfx_dppi_channel_enable(data->ppi_ch);
(void)nrfx_dppi_channel_enable(&dppi, data->ppi_ch);
#else /* DPPI_PRESENT */
uint32_t evt_addr;
uint32_t task_addr;
Expand Down Expand Up @@ -430,10 +434,10 @@ static void ppi_free(const struct device *dev, uint8_t chan)
#ifdef DPPI_PRESENT
nrf_rtc_event_t evt = NRF_RTC_CHANNEL_EVENT_ADDR(chan);

(void)nrfx_dppi_channel_disable(ppi_ch);
(void)nrfx_dppi_channel_disable(&dppi, ppi_ch);
nrfy_rtc_subscribe_clear(rtc, NRF_RTC_TASK_CLEAR);
nrfy_rtc_publish_clear(rtc, evt);
(void)nrfx_dppi_channel_free(ppi_ch);
(void)nrfx_dppi_channel_free(&dppi, ppi_ch);
#else /* DPPI_PRESENT */
(void)nrfx_ppi_channel_disable(ppi_ch);
(void)nrfx_ppi_channel_free(ppi_ch);
Expand Down
74 changes: 72 additions & 2 deletions modules/hal_nordic/nrfx/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,78 @@ config NRFX_COMP
depends on $(dt_has_compat,$(DT_COMPAT_NORDIC_NRF_COMP))

config NRFX_DPPI
bool "DPPI allocator"
depends on $(dt_has_compat,$(DT_COMPAT_NORDIC_NRF_DPPIC))
bool

config NRFX_DPPI0
bool "DPPI0 driver instance"
default y
depends on $(dt_nodelabel_has_compat,dppic,$(DT_COMPAT_NORDIC_NRF_DPPIC))
select NRFX_DPPI

config NRFX_DPPI00
bool "DPPI00 driver instance"
depends on $(dt_nodelabel_has_compat,dppic00,$(DT_COMPAT_NORDIC_NRF_DPPIC))
select NRFX_DPPI

config NRFX_DPPI10
bool "DPPI10 driver instance"
depends on $(dt_nodelabel_has_compat,dppic10,$(DT_COMPAT_NORDIC_NRF_DPPIC))
select NRFX_DPPI

config NRFX_DPPI20
bool "DPPI20 driver instance"
depends on $(dt_nodelabel_has_compat,dppic20,$(DT_COMPAT_NORDIC_NRF_DPPIC))
select NRFX_DPPI

config NRFX_DPPI30
bool "DPPI30 driver instance"
depends on $(dt_nodelabel_has_compat,dppic30,$(DT_COMPAT_NORDIC_NRF_DPPIC))
select NRFX_DPPI

config NRFX_DPPI020
bool "DPPI020 driver instance"
depends on $(dt_nodelabel_has_compat,dppic020,$(DT_COMPAT_NORDIC_NRF_DPPIC))
select NRFX_DPPI

config NRFX_DPPI120
bool "DPPI120 driver instance"
depends on $(dt_nodelabel_has_compat,dppic120,$(DT_COMPAT_NORDIC_NRF_DPPIC))
select NRFX_DPPI

config NRFX_DPPI130
bool "DPPI130 driver instance"
depends on $(dt_nodelabel_has_compat,dppic130,$(DT_COMPAT_NORDIC_NRF_DPPIC))
select NRFX_DPPI

config NRFX_DPPI131
bool "DPPI131 driver instance"
depends on $(dt_nodelabel_has_compat,dppic131,$(DT_COMPAT_NORDIC_NRF_DPPIC))
select NRFX_DPPI

config NRFX_DPPI132
bool "DPPI132 driver instance"
depends on $(dt_nodelabel_has_compat,dppic132,$(DT_COMPAT_NORDIC_NRF_DPPIC))
select NRFX_DPPI

config NRFX_DPPI133
bool "DPPI133 driver instance"
depends on $(dt_nodelabel_has_compat,dppic133,$(DT_COMPAT_NORDIC_NRF_DPPIC))
select NRFX_DPPI

config NRFX_DPPI134
bool "DPPI134 driver instance"
depends on $(dt_nodelabel_has_compat,dppic134,$(DT_COMPAT_NORDIC_NRF_DPPIC))
select NRFX_DPPI

config NRFX_DPPI135
bool "DPPI135 driver instance"
depends on $(dt_nodelabel_has_compat,dppic135,$(DT_COMPAT_NORDIC_NRF_DPPIC))
select NRFX_DPPI

config NRFX_DPPI136
bool "DPPI136 driver instance"
depends on $(dt_nodelabel_has_compat,dppic136,$(DT_COMPAT_NORDIC_NRF_DPPIC))
select NRFX_DPPI

config NRFX_EGU
bool
Expand Down
42 changes: 42 additions & 0 deletions modules/hal_nordic/nrfx/nrfx_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,48 @@
#ifdef CONFIG_NRFX_DPPI_LOG
#define NRFX_DPPI_CONFIG_LOG_ENABLED 1
#endif
#ifdef CONFIG_NRFX_DPPI0
#define NRFX_DPPI0_ENABLED 1
#endif
#ifdef CONFIG_NRFX_DPPI00
#define NRFX_DPPI00_ENABLED 1
#endif
#ifdef CONFIG_NRFX_DPPI10
#define NRFX_DPPI10_ENABLED 1
#endif
#ifdef CONFIG_NRFX_DPPI20
#define NRFX_DPPI20_ENABLED 1
#endif
#ifdef CONFIG_NRFX_DPPI30
#define NRFX_DPPI30_ENABLED 1
#endif
#ifdef CONFIG_NRFX_DPPI020
#define NRFX_DPPI020_ENABLED 1
#endif
#ifdef CONFIG_NRFX_DPPI120
#define NRFX_DPPI120_ENABLED 1
#endif
#ifdef CONFIG_NRFX_DPPI130
#define NRFX_DPPI130_ENABLED 1
#endif
#ifdef CONFIG_NRFX_DPPI131
#define NRFX_DPPI131_ENABLED 1
#endif
#ifdef CONFIG_NRFX_DPPI132
#define NRFX_DPPI132_ENABLED 1
#endif
#ifdef CONFIG_NRFX_DPPI133
#define NRFX_DPPI133_ENABLED 1
#endif
#ifdef CONFIG_NRFX_DPPI134
#define NRFX_DPPI134_ENABLED 1
#endif
#ifdef CONFIG_NRFX_DPPI135
#define NRFX_DPPI135_ENABLED 1
#endif
#ifdef CONFIG_NRFX_DPPI136
#define NRFX_DPPI136_ENABLED 1
#endif

#ifdef CONFIG_NRFX_EGU
#define NRFX_EGU_ENABLED 1
Expand Down
2 changes: 1 addition & 1 deletion modules/hal_nordic/nrfx/nrfx_config_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

/** @brief Symbol specifying minor version of the nrfx API to be used. */
#ifndef NRFX_CONFIG_API_VER_MINOR
#define NRFX_CONFIG_API_VER_MINOR 6
#define NRFX_CONFIG_API_VER_MINOR 8
#endif

/** @brief Symbol specifying micro version of the nrfx API to be used. */
Expand Down
7 changes: 4 additions & 3 deletions soc/nordic/nrf53/sync_rtc.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ LOG_MODULE_REGISTER(sync_rtc, CONFIG_SYNC_RTC_LOG_LEVEL);

static uint32_t sync_cc;
static int32_t nrf53_sync_offset = -EBUSY;
static nrfx_dppi_t dppi = NRFX_DPPI_INSTANCE(0);

union rtc_sync_channels {
uint32_t raw;
Expand Down Expand Up @@ -113,7 +114,7 @@ static void free_resources(union rtc_sync_channels channels)

z_nrf_rtc_timer_chan_free(channels.ch.rtc);

err = nrfx_dppi_channel_free(channels.ch.ppi);
err = nrfx_dppi_channel_free(&dppi, channels.ch.ppi);
__ASSERT_NO_MSG(err == NRFX_SUCCESS);
}

Expand Down Expand Up @@ -229,15 +230,15 @@ static int sync_rtc_setup(void)
int32_t sync_rtc_ch;
int rv;

err = nrfx_dppi_channel_alloc(&channels.ch.ppi);
err = nrfx_dppi_channel_alloc(&dppi, &channels.ch.ppi);
if (err != NRFX_SUCCESS) {
rv = -ENODEV;
goto bail;
}

sync_rtc_ch = z_nrf_rtc_timer_chan_alloc();
if (sync_rtc_ch < 0) {
nrfx_dppi_channel_free(channels.ch.ppi);
nrfx_dppi_channel_free(&dppi, channels.ch.ppi);
rv = sync_rtc_ch;
goto bail;
}
Expand Down

0 comments on commit 1a6b18b

Please sign in to comment.