Skip to content

Commit 4007b3a

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 fd104cd commit 4007b3a

File tree

1 file changed

+26
-30
lines changed

1 file changed

+26
-30
lines changed

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

Lines changed: 26 additions & 30 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,15 @@ 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);
151+
err = nrfx_gppi_conn_alloc(nrfx_gpiote_in_event_address_get(&gpiote, FEEDBACK_PIN),
152+
nrfx_timer_task_address_get(&feedback_timer_instance, NRF_TIMER_TASK_COUNT),
153+
&feedback_gppi_handle);
154+
if (err < 0) {
155+
LOG_ERR("gppi_conn_alloc failed with: %d\n", err);
154156
return err;
155157
}
156158

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));
160-
161-
nrfx_gppi_channels_enable(BIT(feedback_gppi_channel));
159+
nrfx_gppi_conn_enable(feedback_gppi_handle);
162160

163161
return NRFX_SUCCESS;
164162
}
@@ -185,8 +183,9 @@ static nrfx_err_t feedback_relative_timer_setup(void)
185183
struct feedback_ctx *feedback_init(void)
186184
{
187185
nrfx_err_t err;
188-
uint8_t usbd_sof_gppi_channel;
189-
uint8_t i2s_framestart_gppi_channel;
186+
nrfx_gppi_handle_t usbd_sof_gppi_handle;
187+
nrfx_gppi_handle_t i2s_framestart_gppi_handle;
188+
int rv;
190189

191190
feedback_target_init();
192191

@@ -203,35 +202,32 @@ struct feedback_ctx *feedback_init(void)
203202
}
204203

205204
/* 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);
205+
rv = nrfx_gppi_conn_alloc(USB_SOF_EVENT_ADDRESS,
206+
nrfx_timer_capture_task_address_get(&feedback_timer_instance,
207+
FEEDBACK_TIMER_USBD_SOF_CAPTURE),
208+
&usbd_sof_gppi_handle);
209+
if (rv < 0) {
210+
LOG_ERR("gppi_conn_alloc failed with: %d\n", err);
209211
return &fb_ctx;
210212
}
211213

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,
214+
nrfx_gppi_ep_attach(usbd_sof_gppi_handle,
217215
nrfx_timer_task_address_get(&feedback_timer_instance,
218216
NRF_TIMER_TASK_CLEAR));
219217

220-
nrfx_gppi_channels_enable(BIT(usbd_sof_gppi_channel));
218+
nrfx_gppi_conn_enable(usbd_sof_gppi_handle);
221219

222220
/* 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);
221+
rv = nrfx_gppi_conn_alloc(I2S_FRAMESTART_EVENT_ADDRESS,
222+
nrfx_timer_capture_task_address_get(&feedback_timer_instance,
223+
FEEDBACK_TIMER_I2S_FRAMESTART_CAPTURE),
224+
&i2s_framestart_gppi_handle);
225+
if (ev < 0) {
226+
LOG_ERR("gppi_conn_alloc failed with: %d\n", err);
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)