Skip to content

Commit 0ae69d0

Browse files
committed
[nrf fromlist] samples: subsys: usb: explicit_feedback: Use new GPPI API
Convert to use the new GPPI API. Upstream PR #: 98327 Signed-off-by: Krzysztof Chruściński <[email protected]>
1 parent 870b50d commit 0ae69d0

File tree

1 file changed

+29
-33
lines changed

1 file changed

+29
-33
lines changed

samples/subsys/usb/uac2_explicit_feedback/src/feedback_nrf.c

Lines changed: 29 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
#include <zephyr/logging/log.h>
99
#include "feedback.h"
1010

11-
#include <nrfx_dppi.h>
1211
#include <nrfx_gpiote.h>
1312
#include <nrfx_timer.h>
1413
#include <hal/nrf_gpio.h>
@@ -113,7 +112,7 @@ static nrfx_err_t feedback_edge_counter_setup(void)
113112
{
114113
nrfx_err_t err;
115114
uint8_t feedback_gpiote_channel;
116-
uint8_t feedback_gppi_channel;
115+
nrfx_gppi_handle_t feedback_gppi_handle;
117116
nrfx_gpiote_trigger_config_t trigger_config = {
118117
.trigger = NRFX_GPIOTE_TRIGGER_TOGGLE,
119118
.p_in_channel = &feedback_gpiote_channel,
@@ -123,6 +122,7 @@ static nrfx_err_t feedback_edge_counter_setup(void)
123122
.p_pull_config = &pull,
124123
.p_trigger_config = &trigger_config,
125124
};
125+
int rv;
126126

127127
err = nrfx_gpiote_channel_alloc(&gpiote, &feedback_gpiote_channel);
128128
if (err != NRFX_SUCCESS) {
@@ -148,17 +148,16 @@ static nrfx_err_t feedback_edge_counter_setup(void)
148148
}
149149

150150
/* Subscribe TIMER COUNT task to GPIOTE IN event */
151-
err = nrfx_gppi_channel_alloc(&feedback_gppi_channel);
152-
if (err != NRFX_SUCCESS) {
153-
LOG_ERR("gppi_channel_alloc failed with: %d\n", err);
154-
return err;
155-
}
151+
uint32_t eep = nrfx_gpiote_in_event_address_get(&gpiote, FEEDBACK_PIN);
152+
uint32_t tep = nrfx_timer_task_address_get(&feedback_timer_instance, NRF_TIMER_TASK_COUNT);
156153

157-
nrfx_gppi_channel_endpoints_setup(feedback_gppi_channel,
158-
nrfx_gpiote_in_event_address_get(&gpiote, FEEDBACK_PIN),
159-
nrfx_timer_task_address_get(&feedback_timer_instance, NRF_TIMER_TASK_COUNT));
154+
rv = nrfx_gppi_conn_alloc(eep, tep, &feedback_gppi_handle);
155+
if (rv < 0) {
156+
LOG_ERR("gppi_conn_alloc failed with: %d\n", rv);
157+
return rv;
158+
}
160159

161-
nrfx_gppi_channels_enable(BIT(feedback_gppi_channel));
160+
nrfx_gppi_conn_enable(feedback_gppi_handle);
162161

163162
return NRFX_SUCCESS;
164163
}
@@ -185,8 +184,9 @@ static nrfx_err_t feedback_relative_timer_setup(void)
185184
struct feedback_ctx *feedback_init(void)
186185
{
187186
nrfx_err_t err;
188-
uint8_t usbd_sof_gppi_channel;
189-
uint8_t i2s_framestart_gppi_channel;
187+
nrfx_gppi_handle_t usbd_sof_gppi_handle;
188+
nrfx_gppi_handle_t i2s_framestart_gppi_handle;
189+
int rv;
190190

191191
feedback_target_init();
192192

@@ -203,35 +203,31 @@ struct feedback_ctx *feedback_init(void)
203203
}
204204

205205
/* Subscribe TIMER CAPTURE task to USBD SOF event */
206-
err = nrfx_gppi_channel_alloc(&usbd_sof_gppi_channel);
207-
if (err != NRFX_SUCCESS) {
208-
LOG_ERR("gppi_channel_alloc failed with: %d\n", err);
206+
uint32_t tsk1 = nrfx_timer_capture_task_address_get(&feedback_timer_instance,
207+
FEEDBACK_TIMER_USBD_SOF_CAPTURE);
208+
uint32_t tsk2 = nrfx_timer_capture_task_address_get(&feedback_timer_instance,
209+
FEEDBACK_TIMER_I2S_FRAMESTART_CAPTURE),
210+
211+
rv = nrfx_gppi_conn_alloc(USB_SOF_EVENT_ADDRESS, tsk1, &usbd_sof_gppi_handle);
212+
if (rv < 0) {
213+
LOG_ERR("gppi_conn_alloc failed with: %d\n", err);
209214
return &fb_ctx;
210215
}
211216

212-
nrfx_gppi_channel_endpoints_setup(usbd_sof_gppi_channel,
213-
USB_SOF_EVENT_ADDRESS,
214-
nrfx_timer_capture_task_address_get(&feedback_timer_instance,
215-
FEEDBACK_TIMER_USBD_SOF_CAPTURE));
216-
nrfx_gppi_fork_endpoint_setup(usbd_sof_gppi_channel,
217-
nrfx_timer_task_address_get(&feedback_timer_instance,
218-
NRF_TIMER_TASK_CLEAR));
217+
nrfx_gppi_ep_attach(usbd_sof_gppi_handle,
218+
nrfx_timer_task_address_get(&feedback_timer_instance,
219+
NRF_TIMER_TASK_CLEAR));
219220

220-
nrfx_gppi_channels_enable(BIT(usbd_sof_gppi_channel));
221+
nrfx_gppi_conn_enable(usbd_sof_gppi_handle);
221222

222223
/* Subscribe TIMER CAPTURE task to I2S FRAMESTART event */
223-
err = nrfx_gppi_channel_alloc(&i2s_framestart_gppi_channel);
224-
if (err != NRFX_SUCCESS) {
225-
LOG_ERR("gppi_channel_alloc failed with: %d\n", err);
224+
rv = nrfx_gppi_conn_alloc(I2S_FRAMESTART_EVENT_ADDRESS, tsk2, &i2s_framestart_gppi_handle);
225+
if (rv < 0) {
226+
LOG_ERR("gppi_conn_alloc failed with: %d\n", rv);
226227
return &fb_ctx;
227228
}
228229

229-
nrfx_gppi_channel_endpoints_setup(i2s_framestart_gppi_channel,
230-
I2S_FRAMESTART_EVENT_ADDRESS,
231-
nrfx_timer_capture_task_address_get(&feedback_timer_instance,
232-
FEEDBACK_TIMER_I2S_FRAMESTART_CAPTURE));
233-
234-
nrfx_gppi_channels_enable(BIT(i2s_framestart_gppi_channel));
230+
nrfx_gppi_conn_enable(i2s_framestart_gppi_handle);
235231

236232
/* Enable feedback timer */
237233
nrfx_timer_enable(&feedback_timer_instance);

0 commit comments

Comments
 (0)