Skip to content

Commit ec899cc

Browse files
nordic-krchmasz-nordic
authored andcommitted
[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 f13cddd commit ec899cc

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>
@@ -122,7 +121,7 @@ static nrfx_err_t feedback_edge_counter_setup(void)
122121
{
123122
nrfx_err_t err;
124123
uint8_t feedback_gpiote_channel;
125-
uint8_t feedback_gppi_channel;
124+
nrfx_gppi_handle_t feedback_gppi_handle;
126125
nrfx_gpiote_trigger_config_t trigger_config = {
127126
.trigger = NRFX_GPIOTE_TRIGGER_TOGGLE,
128127
.p_in_channel = &feedback_gpiote_channel,
@@ -132,6 +131,7 @@ static nrfx_err_t feedback_edge_counter_setup(void)
132131
.p_pull_config = &pull,
133132
.p_trigger_config = &trigger_config,
134133
};
134+
int rv;
135135

136136
err = nrfx_gpiote_channel_alloc(&gpiote, &feedback_gpiote_channel);
137137
if (err != NRFX_SUCCESS) {
@@ -157,17 +157,16 @@ static nrfx_err_t feedback_edge_counter_setup(void)
157157
}
158158

159159
/* Subscribe TIMER COUNT task to GPIOTE IN event */
160-
err = nrfx_gppi_channel_alloc(&feedback_gppi_channel);
161-
if (err != NRFX_SUCCESS) {
162-
LOG_ERR("gppi_channel_alloc failed with: %d\n", err);
163-
return err;
164-
}
160+
uint32_t eep = nrfx_gpiote_in_event_address_get(&gpiote, FEEDBACK_PIN);
161+
uint32_t tep = nrfx_timer_task_address_get(&feedback_timer_instance, NRF_TIMER_TASK_COUNT);
165162

166-
nrfx_gppi_channel_endpoints_setup(feedback_gppi_channel,
167-
nrfx_gpiote_in_event_address_get(&gpiote, FEEDBACK_PIN),
168-
nrfx_timer_task_address_get(&feedback_timer_instance, NRF_TIMER_TASK_COUNT));
163+
rv = nrfx_gppi_conn_alloc(eep, tep, &feedback_gppi_handle);
164+
if (rv < 0) {
165+
LOG_ERR("gppi_conn_alloc failed with: %d\n", rv);
166+
return rv;
167+
}
169168

170-
nrfx_gppi_channels_enable(BIT(feedback_gppi_channel));
169+
nrfx_gppi_conn_enable(feedback_gppi_handle);
171170

172171
return NRFX_SUCCESS;
173172
}
@@ -194,8 +193,9 @@ static nrfx_err_t feedback_relative_timer_setup(void)
194193
struct feedback_ctx *feedback_init(void)
195194
{
196195
nrfx_err_t err;
197-
uint8_t usbd_sof_gppi_channel;
198-
uint8_t i2s_framestart_gppi_channel;
196+
nrfx_gppi_handle_t usbd_sof_gppi_handle;
197+
nrfx_gppi_handle_t i2s_framestart_gppi_handle;
198+
int rv;
199199

200200
feedback_target_init();
201201

@@ -212,35 +212,31 @@ struct feedback_ctx *feedback_init(void)
212212
}
213213

214214
/* Subscribe TIMER CAPTURE task to USBD SOF event */
215-
err = nrfx_gppi_channel_alloc(&usbd_sof_gppi_channel);
216-
if (err != NRFX_SUCCESS) {
217-
LOG_ERR("gppi_channel_alloc failed with: %d\n", err);
215+
uint32_t tsk1 = nrfx_timer_capture_task_address_get(&feedback_timer_instance,
216+
FEEDBACK_TIMER_USBD_SOF_CAPTURE);
217+
uint32_t tsk2 = nrfx_timer_capture_task_address_get(&feedback_timer_instance,
218+
FEEDBACK_TIMER_I2S_FRAMESTART_CAPTURE);
219+
220+
rv = nrfx_gppi_conn_alloc(USB_SOF_EVENT_ADDRESS, tsk1, &usbd_sof_gppi_handle);
221+
if (rv < 0) {
222+
LOG_ERR("gppi_conn_alloc failed with: %d\n", rv);
218223
return &fb_ctx;
219224
}
220225

221-
nrfx_gppi_channel_endpoints_setup(usbd_sof_gppi_channel,
222-
USB_SOF_EVENT_ADDRESS,
223-
nrfx_timer_capture_task_address_get(&feedback_timer_instance,
224-
FEEDBACK_TIMER_USBD_SOF_CAPTURE));
225-
nrfx_gppi_fork_endpoint_setup(usbd_sof_gppi_channel,
226-
nrfx_timer_task_address_get(&feedback_timer_instance,
227-
NRF_TIMER_TASK_CLEAR));
226+
nrfx_gppi_ep_attach(usbd_sof_gppi_handle,
227+
nrfx_timer_task_address_get(&feedback_timer_instance,
228+
NRF_TIMER_TASK_CLEAR));
228229

229-
nrfx_gppi_channels_enable(BIT(usbd_sof_gppi_channel));
230+
nrfx_gppi_conn_enable(usbd_sof_gppi_handle);
230231

231232
/* Subscribe TIMER CAPTURE task to I2S FRAMESTART event */
232-
err = nrfx_gppi_channel_alloc(&i2s_framestart_gppi_channel);
233-
if (err != NRFX_SUCCESS) {
234-
LOG_ERR("gppi_channel_alloc failed with: %d\n", err);
233+
rv = nrfx_gppi_conn_alloc(I2S_FRAMESTART_EVENT_ADDRESS, tsk2, &i2s_framestart_gppi_handle);
234+
if (rv < 0) {
235+
LOG_ERR("gppi_conn_alloc failed with: %d\n", rv);
235236
return &fb_ctx;
236237
}
237238

238-
nrfx_gppi_channel_endpoints_setup(i2s_framestart_gppi_channel,
239-
I2S_FRAMESTART_EVENT_ADDRESS,
240-
nrfx_timer_capture_task_address_get(&feedback_timer_instance,
241-
FEEDBACK_TIMER_I2S_FRAMESTART_CAPTURE));
242-
243-
nrfx_gppi_channels_enable(BIT(i2s_framestart_gppi_channel));
239+
nrfx_gppi_conn_enable(i2s_framestart_gppi_handle);
244240

245241
/* Enable feedback timer */
246242
nrfx_timer_enable(&feedback_timer_instance);

0 commit comments

Comments
 (0)