Skip to content

Commit 95fa952

Browse files
committed
mpsl: pin_debug: Adapt to use GPPI API
nrfx_ppi and nrfx_dppi are deprecated and GPPI must be used. Align to the new GPPI API. Signed-off-by: Krzysztof Chruściński <[email protected]>
1 parent c466353 commit 95fa952

File tree

3 files changed

+64
-236
lines changed

3 files changed

+64
-236
lines changed

subsys/mpsl/pin_debug/Kconfig

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,16 +29,13 @@ config MPSL_PIN_DEBUG_RADIO_CORE
2929
depends on MPSL_PIN_DEBUG
3030
select NRFX_GPIOTE
3131
select NRFX_GPPI
32-
select NRFX_PPI if HAS_HW_NRF_PPI
33-
select NRFX_DPPI if HAS_HW_NRF_DPPIC
3432
default y if (SOC_COMPATIBLE_NRF52X || SOC_COMPATIBLE_NRF5340_CPUNET)
3533

3634
config MPSL_PIN_DEBUG_54X_APP_OR_RADIO_CORE
3735
bool
3836
depends on MPSL_PIN_DEBUG
3937
select NRFX_GPIOTE
4038
select NRFX_GPPI
41-
select NRFX_DPPI
4239
default y if SOC_COMPATIBLE_NRF54LX
4340

4441
config MPSL_PIN_DEBUG_RADIO_READY_AND_DISABLED_PIN

subsys/mpsl/pin_debug/mpsl_pin_debug_nrf54.c

Lines changed: 31 additions & 144 deletions
Original file line numberDiff line numberDiff line change
@@ -10,160 +10,47 @@
1010
#include <mpsl_dppi_protocol_api.h>
1111
#include <nrfx_gpiote.h>
1212
#include <helpers/nrfx_gppi.h>
13-
#include <nrfx_dppi.h>
1413
#include <hal/nrf_radio.h>
1514
#include <zephyr/device.h>
1615
#include <zephyr/drivers/gpio.h>
1716

1817
const nrfx_gpiote_t gpiote = NRFX_GPIOTE_INSTANCE(20);
19-
const nrfx_dppi_t dppi_radio_domain = NRFX_DPPI_INSTANCE(10);
20-
const nrfx_dppi_t dppi_gpio_domain = NRFX_DPPI_INSTANCE(20);
2118
LOG_MODULE_REGISTER(mpsl_radio_pin_debug, CONFIG_MPSL_LOG_LEVEL);
2219

2320
static int m_ppi_config(void)
2421
{
25-
uint8_t gppi_chan_radio_ready;
26-
uint8_t gppi_chan_radio_disabled;
27-
uint8_t gppi_chan_radio_address;
28-
uint8_t gppi_chan_radio_end;
29-
30-
uint8_t dppi_chan_gpio_ready;
31-
uint8_t dppi_chan_gpio_disabled;
32-
uint8_t dppi_chan_gpio_address;
33-
uint8_t dppi_chan_gpio_end;
34-
35-
if (nrfx_gppi_channel_alloc(&gppi_chan_radio_ready) !=
36-
NRFX_SUCCESS) {
37-
LOG_ERR("Failed allocating gppi_chan_radio_ready");
38-
return -ENOMEM;
39-
}
40-
41-
if (nrfx_gppi_channel_alloc(&gppi_chan_radio_disabled) !=
42-
NRFX_SUCCESS) {
43-
LOG_ERR("Failed allocating gppi_chan_radio_disabled");
44-
return -ENOMEM;
45-
}
46-
47-
if (nrfx_gppi_channel_alloc(&gppi_chan_radio_address) !=
48-
NRFX_SUCCESS) {
49-
LOG_ERR("Failed allocating gppi_chan_radio_address");
50-
return -ENOMEM;
51-
}
52-
53-
if (nrfx_gppi_channel_alloc(&gppi_chan_radio_end) !=
54-
NRFX_SUCCESS) {
55-
LOG_ERR("Failed allocating gppi_chan_radio_end");
56-
return -ENOMEM;
57-
}
58-
59-
if (nrfx_dppi_channel_alloc(&dppi_gpio_domain, &dppi_chan_gpio_ready) !=
60-
NRFX_SUCCESS) {
61-
LOG_ERR("Failed allocating dppi_chan_gpio_ready");
62-
return -ENOMEM;
63-
}
64-
65-
if (nrfx_dppi_channel_alloc(&dppi_gpio_domain, &dppi_chan_gpio_disabled) !=
66-
NRFX_SUCCESS) {
67-
LOG_ERR("Failed allocating dppi_chan_gpio_disabled");
68-
return -ENOMEM;
69-
}
70-
71-
if (nrfx_dppi_channel_alloc(&dppi_gpio_domain, &dppi_chan_gpio_address) !=
72-
NRFX_SUCCESS) {
73-
LOG_ERR("Failed allocating dppi_chan_gpio_address");
74-
return -ENOMEM;
75-
}
76-
77-
if (nrfx_dppi_channel_alloc(&dppi_gpio_domain, &dppi_chan_gpio_end) !=
78-
NRFX_SUCCESS) {
79-
LOG_ERR("Failed allocating dppi_chan_gpio_end");
80-
return -ENOMEM;
81-
}
82-
83-
if (nrfx_gppi_edge_connection_setup(gppi_chan_radio_ready,
84-
&dppi_radio_domain,
85-
MPSL_DPPI_RADIO_PUBLISH_READY_CHANNEL_IDX,
86-
&dppi_gpio_domain,
87-
dppi_chan_gpio_ready) != NRFX_SUCCESS) {
88-
LOG_ERR("Failed edge setup chan ready");
89-
return -ENOMEM;
90-
}
91-
92-
if (nrfx_gppi_edge_connection_setup(gppi_chan_radio_disabled,
93-
&dppi_radio_domain,
94-
MPSL_DPPI_RADIO_PUBLISH_DISABLED_CH_IDX,
95-
&dppi_gpio_domain,
96-
dppi_chan_gpio_disabled) != NRFX_SUCCESS) {
97-
LOG_ERR("Failed edge setup chan disabled");
98-
return -ENOMEM;
99-
}
100-
101-
if (nrfx_gppi_edge_connection_setup(gppi_chan_radio_address,
102-
&dppi_radio_domain,
103-
MPSL_DPPI_RADIO_PUBLISH_ADDRESS_CHANNEL_IDX,
104-
&dppi_gpio_domain,
105-
dppi_chan_gpio_address) != NRFX_SUCCESS) {
106-
LOG_ERR("Failed edge setup chan address");
107-
return -ENOMEM;
108-
}
109-
110-
/* Setup a PPI bridge between the radio domain and the domain of the GPIO pin. */
111-
if (nrfx_gppi_edge_connection_setup(gppi_chan_radio_address,
112-
&dppi_radio_domain,
113-
MPSL_DPPI_RADIO_PUBLISH_END_CHANNEL_IDX,
114-
&dppi_gpio_domain,
115-
dppi_chan_gpio_end) != NRFX_SUCCESS) {
116-
LOG_ERR("Failed edge setup chan end");
117-
return -ENOMEM;
118-
}
119-
120-
nrf_gpiote_subscribe_set(
121-
gpiote.p_reg,
122-
nrfx_gpiote_set_task_address_get(
123-
&gpiote, CONFIG_MPSL_PIN_DEBUG_RADIO_READY_AND_DISABLED_PIN),
124-
dppi_chan_gpio_ready);
125-
126-
nrf_gpiote_subscribe_set(
127-
gpiote.p_reg,
128-
nrfx_gpiote_clr_task_address_get(
129-
&gpiote, CONFIG_MPSL_PIN_DEBUG_RADIO_READY_AND_DISABLED_PIN),
130-
dppi_chan_gpio_disabled);
131-
132-
nrf_gpiote_subscribe_set(
133-
gpiote.p_reg,
134-
nrfx_gpiote_set_task_address_get(&gpiote,
135-
CONFIG_MPSL_PIN_DEBUG_RADIO_ADDRESS_AND_END_PIN),
136-
dppi_chan_gpio_address);
137-
138-
nrf_gpiote_subscribe_set(
139-
gpiote.p_reg,
140-
nrfx_gpiote_clr_task_address_get(&gpiote,
141-
CONFIG_MPSL_PIN_DEBUG_RADIO_ADDRESS_AND_END_PIN),
142-
dppi_chan_gpio_end);
143-
144-
nrfx_gppi_channels_enable(NRFX_BIT(gppi_chan_radio_ready) |
145-
NRFX_BIT(gppi_chan_radio_disabled) |
146-
NRFX_BIT(gppi_chan_radio_address) |
147-
NRFX_BIT(gppi_chan_radio_end));
148-
149-
if (nrfx_dppi_channel_enable(&dppi_gpio_domain, dppi_chan_gpio_ready) != NRFX_SUCCESS) {
150-
LOG_ERR("Failed chan enable gpio_ready");
151-
return -ENOMEM;
152-
}
153-
154-
if (nrfx_dppi_channel_enable(&dppi_gpio_domain, dppi_chan_gpio_disabled) != NRFX_SUCCESS) {
155-
LOG_ERR("Failed chan enable gpio_disabled");
156-
return -ENOMEM;
157-
}
158-
159-
if (nrfx_dppi_channel_enable(&dppi_gpio_domain, dppi_chan_gpio_address) != NRFX_SUCCESS) {
160-
LOG_ERR("Failed chan enable gpio_address");
161-
return -ENOMEM;
162-
}
22+
uint32_t rad_domain = nrfx_gppi_domain_id_get(NRF_DPPIC10);
23+
uint32_t dst_domain = nrfx_gppi_domain_id_get(gpiote.p_reg);
24+
nrfx_gppi_resource_t rad_resource;
25+
nrfx_gppi_handle_t handle;
26+
uint32_t tep[4];
27+
int err;
28+
static const uint32_t pub_ch[] = {
29+
MPSL_DPPI_RADIO_PUBLISH_READY_CHANNEL_IDX,
30+
MPSL_DPPI_RADIO_PUBLISH_DISABLED_CH_IDX,
31+
MPSL_DPPI_RADIO_PUBLISH_ADDRESS_CHANNEL_IDX,
32+
MPSL_DPPI_RADIO_PUBLISH_END_CHANNEL_IDX
33+
};
16334

164-
if (nrfx_dppi_channel_enable(&dppi_gpio_domain, dppi_chan_gpio_end) != NRFX_SUCCESS) {
165-
LOG_ERR("Failed chan enable gpio_end");
166-
return -ENOMEM;
35+
tep[0] = nrfx_gpiote_set_task_address_get(&gpiote,
36+
CONFIG_MPSL_PIN_DEBUG_RADIO_READY_AND_DISABLED_PIN);
37+
tep[1] = nrfx_gpiote_clr_task_address_get(&gpiote,
38+
CONFIG_MPSL_PIN_DEBUG_RADIO_READY_AND_DISABLED_PIN);
39+
tep[2] = nrfx_gpiote_set_task_address_get(&gpiote,
40+
CONFIG_MPSL_PIN_DEBUG_RADIO_ADDRESS_AND_END_PIN);
41+
tep[3] = nrfx_gpiote_clr_task_address_get(&gpiote,
42+
CONFIG_MPSL_PIN_DEBUG_RADIO_ADDRESS_AND_END_PIN);
43+
rad_resource.rad_domain = nrfx_gppi_domain_id_get(NRF_DPPIC10);
44+
45+
for (size_t i = 0; i < ARRAY_SIZE(pub_ch); i++) {
46+
rad_resource.channel = pub_ch[i];
47+
err = nrfx_gppi_ext_conn_alloc(rad_domain, dst_domain, &handle, &rad_resource);
48+
if (err < 0) {
49+
return err;
50+
}
51+
nrfx_gppi_ep_attach(handle, tep[i]);
52+
/* Channel in radio domain is not enabled by this function. */
53+
nrfx_gppi_conn_enable(handle);
16754
}
16855

16956
return 0;

subsys/mpsl/pin_debug/mpsl_pin_debug_radio_core.c

Lines changed: 33 additions & 89 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,7 @@
1111
#include <helpers/nrfx_gppi.h>
1212
#include <hal/nrf_radio.h>
1313

14-
#ifdef PPI_PRESENT
15-
#include <nrfx_ppi.h>
1614
#elif defined(DPPI_PRESENT)
17-
#include <nrfx_dppi.h>
1815
#include <mpsl_dppi_protocol_api.h>
1916
#endif
2017

@@ -23,96 +20,43 @@ LOG_MODULE_REGISTER(mpsl_radio_pin_debug, CONFIG_MPSL_LOG_LEVEL);
2320

2421
static int m_ppi_config(void)
2522
{
26-
#if defined(PPI_PRESENT)
27-
uint8_t ppi_chan_radio_ready;
28-
uint8_t ppi_chan_radio_address;
29-
uint8_t ppi_chan_radio_end;
30-
uint8_t ppi_chan_radio_disabled;
31-
32-
if (nrfx_ppi_channel_alloc(&ppi_chan_radio_ready) != NRFX_SUCCESS) {
33-
LOG_ERR("Failed allocating PPI chan");
34-
return -ENOMEM;
35-
}
36-
37-
if (nrfx_ppi_channel_alloc(&ppi_chan_radio_address) != NRFX_SUCCESS) {
38-
LOG_ERR("Failed allocating PPI chan");
39-
return -ENOMEM;
40-
}
41-
42-
if (nrfx_ppi_channel_alloc(&ppi_chan_radio_end) != NRFX_SUCCESS) {
43-
LOG_ERR("Failed allocating PPI chan");
44-
return -ENOMEM;
45-
}
46-
47-
if (nrfx_ppi_channel_alloc(&ppi_chan_radio_disabled) != NRFX_SUCCESS) {
48-
LOG_ERR("Failed allocating PPI chan");
49-
return -ENOMEM;
50-
}
23+
nrfx_gppi_handle_t handle[4];
24+
uint32_t tep[4];
25+
26+
tep[0] = nrfx_gpiote_set_task_address_get(&gpiote,
27+
CONFIG_MPSL_PIN_DEBUG_RADIO_READY_AND_DISABLED_PIN);
28+
tep[1] = nrfx_gpiote_clr_task_address_get(&gpiote,
29+
CONFIG_MPSL_PIN_DEBUG_RADIO_READY_AND_DISABLED_PIN);
30+
tep[2] = nrfx_gpiote_set_task_address_get(&gpiote,
31+
CONFIG_MPSL_PIN_DEBUG_RADIO_ADDRESS_AND_END_PIN);
32+
tep[3] = nrfx_gpiote_clr_task_address_get(&gpiote,
33+
CONFIG_MPSL_PIN_DEBUG_RADIO_ADDRESS_AND_END_PIN);
34+
#if defined(DPPI_PRESENT)
35+
handle[0] = MPSL_DPPI_RADIO_PUBLISH_READY_CHANNEL_IDX;
36+
handle[1] = MPSL_DPPI_RADIO_PUBLISH_DISABLED_CH_IDX;
37+
handle[2] = MPSL_DPPI_RADIO_PUBLISH_ADDRESS_CHANNEL_IDX;
38+
handle[3] = MPSL_DPPI_RADIO_PUBLISH_END_CHANNEL_IDX;
39+
#else
40+
uint32_t eep[4];
5141

52-
nrfx_gppi_channel_endpoints_setup(
53-
ppi_chan_radio_ready, nrf_radio_event_address_get(NRF_RADIO, NRF_RADIO_EVENT_READY),
54-
nrfx_gpiote_set_task_address_get(
55-
&gpiote, CONFIG_MPSL_PIN_DEBUG_RADIO_READY_AND_DISABLED_PIN));
56-
57-
nrfx_gppi_channel_endpoints_setup(
58-
ppi_chan_radio_disabled,
59-
nrf_radio_event_address_get(NRF_RADIO, NRF_RADIO_EVENT_DISABLED),
60-
nrfx_gpiote_clr_task_address_get(
61-
&gpiote, CONFIG_MPSL_PIN_DEBUG_RADIO_READY_AND_DISABLED_PIN));
62-
63-
nrfx_gppi_channel_endpoints_setup(
64-
ppi_chan_radio_address,
65-
nrf_radio_event_address_get(NRF_RADIO, NRF_RADIO_EVENT_ADDRESS),
66-
nrfx_gpiote_set_task_address_get(&gpiote,
67-
CONFIG_MPSL_PIN_DEBUG_RADIO_ADDRESS_AND_END_PIN));
68-
69-
nrfx_gppi_channel_endpoints_setup(
70-
ppi_chan_radio_end, nrf_radio_event_address_get(NRF_RADIO, NRF_RADIO_EVENT_END),
71-
nrfx_gpiote_clr_task_address_get(&gpiote,
72-
CONFIG_MPSL_PIN_DEBUG_RADIO_ADDRESS_AND_END_PIN));
73-
74-
if (nrfx_ppi_channel_enable(ppi_chan_radio_ready) != NRFX_SUCCESS) {
75-
LOG_ERR("Failed enabling channel");
76-
return -ENOMEM;
77-
}
78-
if (nrfx_ppi_channel_enable(ppi_chan_radio_address) != NRFX_SUCCESS) {
79-
LOG_ERR("Failed enabling channel");
80-
return -ENOMEM;
81-
}
82-
if (nrfx_ppi_channel_enable(ppi_chan_radio_end) != NRFX_SUCCESS) {
83-
LOG_ERR("Failed enabling channel");
84-
return -ENOMEM;
85-
}
86-
if (nrfx_ppi_channel_enable(ppi_chan_radio_disabled) != NRFX_SUCCESS) {
87-
LOG_ERR("Failed enabling channel");
88-
return -ENOMEM;
89-
}
42+
eep[0] = nrf_radio_event_address_get(NRF_RADIO, NRF_RADIO_EVENT_READY);
43+
eep[1] = nrf_radio_event_address_get(NRF_RADIO, NRF_RADIO_EVENT_DISABLED);
44+
eep[2] = nrf_radio_event_address_get(NRF_RADIO, NRF_RADIO_EVENT_ADDRESS);
45+
eep[3] = nrf_radio_event_address_get(NRF_RADIO, NRF_RADIO_EVENT_END);
46+
#endif
9047

91-
#elif defined(DPPI_PRESENT)
92-
/* Radio events are published on predefined channels. */
93-
94-
nrfx_gppi_task_endpoint_setup(
95-
MPSL_DPPI_RADIO_PUBLISH_READY_CHANNEL_IDX,
96-
nrfx_gpiote_set_task_address_get(
97-
&gpiote, CONFIG_MPSL_PIN_DEBUG_RADIO_READY_AND_DISABLED_PIN));
98-
99-
nrfx_gppi_task_endpoint_setup(
100-
MPSL_DPPI_RADIO_PUBLISH_DISABLED_CH_IDX,
101-
nrfx_gpiote_clr_task_address_get(
102-
&gpiote, CONFIG_MPSL_PIN_DEBUG_RADIO_READY_AND_DISABLED_PIN));
103-
104-
nrfx_gppi_task_endpoint_setup(
105-
MPSL_DPPI_RADIO_PUBLISH_ADDRESS_CHANNEL_IDX,
106-
nrfx_gpiote_set_task_address_get(&gpiote,
107-
CONFIG_MPSL_PIN_DEBUG_RADIO_ADDRESS_AND_END_PIN));
108-
109-
nrfx_gppi_task_endpoint_setup(
110-
MPSL_DPPI_RADIO_PUBLISH_END_CHANNEL_IDX,
111-
nrfx_gpiote_clr_task_address_get(&gpiote,
112-
CONFIG_MPSL_PIN_DEBUG_RADIO_ADDRESS_AND_END_PIN));
48+
for (size_t i = 0; ARRAY_SIZE(tep); i++) {
49+
#if defined(DPPI_PRESENT)
50+
nrfx_gppi_ep_attach(handle[i], tep[i]);
11351
#else
114-
#error "Expect either PPI or DPPI to be present."
52+
int err = nrfx_gppi_conn_alloc(eep[i], tep[i], &handle[i]);
53+
54+
if (err < 0) {
55+
return err;
56+
}
57+
nrfx_gppi_conn_enable(handle[i]);
11558
#endif
59+
}
11660

11761
return 0;
11862
}

0 commit comments

Comments
 (0)