77#include <stdlib.h>
88#include <zephyr/logging/log.h>
99#include "feedback.h"
10-
11- #include <nrfx_dppi.h>
1210#include <nrfx_timer.h>
1311#include <helpers/nrfx_gppi.h>
1412
@@ -77,16 +75,22 @@ static struct feedback_ctx {
7775
7876struct feedback_ctx * feedback_init (void )
7977{
78+ int rv ;
8079 nrfx_err_t err ;
81- uint8_t usbd_sof_gppi_channel ;
82- uint8_t i2s_framestart_gppi_channel ;
80+ nrfx_gppi_handle_t usbd_sof_gppi_handle ;
81+ uint8_t i2s_framestart_gppi_handle ;
8382 const nrfx_timer_config_t cfg = {
8483 .frequency = NRFX_MHZ_TO_HZ (16UL ),
8584 .mode = NRF_TIMER_MODE_TIMER ,
8685 .bit_width = NRF_TIMER_BIT_WIDTH_32 ,
8786 .interrupt_priority = NRFX_TIMER_DEFAULT_CONFIG_IRQ_PRIORITY ,
8887 .p_context = NULL ,
8988 };
89+ uint32_t tsk1 = nrfx_timer_capture_task_address_get (& feedback_timer_instance ,
90+ FEEDBACK_TIMER_USBD_SOF_CAPTURE );
91+ uint32_t tsk2 = nrfx_timer_task_address_get (& feedback_timer_instance , NRF_TIMER_TASK_CLEAR );
92+ uint32_t tsk3 = nrfx_timer_capture_task_address_get (& feedback_timer_instance ,
93+ FEEDBACK_TIMER_I2S_FRAMESTART_CAPTURE );
9094
9195 feedback_target_init ();
9296
@@ -99,35 +103,23 @@ struct feedback_ctx *feedback_init(void)
99103 }
100104
101105 /* Subscribe TIMER CAPTURE task to USBD SOF event */
102- err = nrfx_gppi_channel_alloc ( & usbd_sof_gppi_channel );
103- if (err != NRFX_SUCCESS ) {
104- LOG_ERR ("gppi_channel_alloc failed with: %d\n" , err );
106+ rv = nrfx_gppi_conn_alloc ( USB_SOF_EVENT_ADDRESS , tsk1 , & usbd_sof_gppi_handle );
107+ if (rv < 0 ) {
108+ LOG_ERR ("gppi_channel_alloc failed with: %d\n" , rv );
105109 return & fb_ctx ;
106110 }
107111
108- nrfx_gppi_channel_endpoints_setup (usbd_sof_gppi_channel ,
109- USB_SOF_EVENT_ADDRESS ,
110- nrfx_timer_capture_task_address_get (& feedback_timer_instance ,
111- FEEDBACK_TIMER_USBD_SOF_CAPTURE ));
112- nrfx_gppi_fork_endpoint_setup (usbd_sof_gppi_channel ,
113- nrfx_timer_task_address_get (& feedback_timer_instance ,
114- NRF_TIMER_TASK_CLEAR ));
115-
116- nrfx_gppi_channels_enable (BIT (usbd_sof_gppi_channel ));
112+ nrfx_gppi_ep_attach (usbd_sof_gppi_handle , tsk2 );
113+ nrfx_gppi_conn_enable (usbd_sof_gppi_handle );
117114
118115 /* Subscribe TIMER CAPTURE task to I2S FRAMESTART event */
119- err = nrfx_gppi_channel_alloc ( & i2s_framestart_gppi_channel );
120- if (err != NRFX_SUCCESS ) {
121- LOG_ERR ("gppi_channel_alloc failed with: %d\n" , err );
116+ rv = nrfx_gppi_conn_alloc ( I2S_FRAMESTART_EVENT_ADDRESS , tsk3 , & i2s_framestart_gppi_handle );
117+ if (rv < 0 ) {
118+ LOG_ERR ("gppi_conn_alloc failed with: %d\n" , rv );
122119 return & fb_ctx ;
123120 }
124121
125- nrfx_gppi_channel_endpoints_setup (i2s_framestart_gppi_channel ,
126- I2S_FRAMESTART_EVENT_ADDRESS ,
127- nrfx_timer_capture_task_address_get (& feedback_timer_instance ,
128- FEEDBACK_TIMER_I2S_FRAMESTART_CAPTURE ));
129-
130- nrfx_gppi_channels_enable (BIT (i2s_framestart_gppi_channel ));
122+ nrfx_gppi_conn_enable (i2s_framestart_gppi_handle );
131123
132124 /* Enable feedback timer */
133125 nrfx_timer_enable (& feedback_timer_instance );
0 commit comments