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
@@ -78,16 +76,22 @@ static struct feedback_ctx {
7876
7977struct feedback_ctx * feedback_init (void )
8078{
79+ int rv ;
8180 nrfx_err_t err ;
82- uint8_t usbd_sof_gppi_channel ;
83- uint8_t i2s_framestart_gppi_channel ;
81+ nrfx_gppi_handle_t usbd_sof_gppi_handle ;
82+ nrfx_gppi_handle_t i2s_framestart_gppi_handle ;
8483 const nrfx_timer_config_t cfg = {
8584 .frequency = NRFX_MHZ_TO_HZ (16UL ),
8685 .mode = NRF_TIMER_MODE_TIMER ,
8786 .bit_width = NRF_TIMER_BIT_WIDTH_32 ,
8887 .interrupt_priority = NRFX_TIMER_DEFAULT_CONFIG_IRQ_PRIORITY ,
8988 .p_context = NULL ,
9089 };
90+ uint32_t tsk1 = nrfx_timer_capture_task_address_get (& feedback_timer_instance ,
91+ FEEDBACK_TIMER_USBD_SOF_CAPTURE );
92+ uint32_t tsk2 = nrfx_timer_task_address_get (& feedback_timer_instance , NRF_TIMER_TASK_CLEAR );
93+ uint32_t tsk3 = nrfx_timer_capture_task_address_get (& feedback_timer_instance ,
94+ FEEDBACK_TIMER_I2S_FRAMESTART_CAPTURE );
9195
9296 feedback_target_init ();
9397
@@ -100,35 +104,23 @@ struct feedback_ctx *feedback_init(void)
100104 }
101105
102106 /* Subscribe TIMER CAPTURE task to USBD SOF event */
103- err = nrfx_gppi_channel_alloc ( & usbd_sof_gppi_channel );
104- if (err != NRFX_SUCCESS ) {
105- LOG_ERR ("gppi_channel_alloc failed with: %d\n" , err );
107+ rv = nrfx_gppi_conn_alloc ( USB_SOF_EVENT_ADDRESS , tsk1 , & usbd_sof_gppi_handle );
108+ if (rv < 0 ) {
109+ LOG_ERR ("gppi_channel_alloc failed with: %d\n" , rv );
106110 return & fb_ctx ;
107111 }
108112
109- nrfx_gppi_channel_endpoints_setup (usbd_sof_gppi_channel ,
110- USB_SOF_EVENT_ADDRESS ,
111- nrfx_timer_capture_task_address_get (& feedback_timer_instance ,
112- FEEDBACK_TIMER_USBD_SOF_CAPTURE ));
113- nrfx_gppi_fork_endpoint_setup (usbd_sof_gppi_channel ,
114- nrfx_timer_task_address_get (& feedback_timer_instance ,
115- NRF_TIMER_TASK_CLEAR ));
116-
117- nrfx_gppi_channels_enable (BIT (usbd_sof_gppi_channel ));
113+ nrfx_gppi_ep_attach (usbd_sof_gppi_handle , tsk2 );
114+ nrfx_gppi_conn_enable (usbd_sof_gppi_handle );
118115
119116 /* Subscribe TIMER CAPTURE task to I2S FRAMESTART event */
120- err = nrfx_gppi_channel_alloc ( & i2s_framestart_gppi_channel );
121- if (err != NRFX_SUCCESS ) {
122- LOG_ERR ("gppi_channel_alloc failed with: %d\n" , err );
117+ rv = nrfx_gppi_conn_alloc ( I2S_FRAMESTART_EVENT_ADDRESS , tsk3 , & i2s_framestart_gppi_handle );
118+ if (rv < 0 ) {
119+ LOG_ERR ("gppi_conn_alloc failed with: %d\n" , rv );
123120 return & fb_ctx ;
124121 }
125122
126- nrfx_gppi_channel_endpoints_setup (i2s_framestart_gppi_channel ,
127- I2S_FRAMESTART_EVENT_ADDRESS ,
128- nrfx_timer_capture_task_address_get (& feedback_timer_instance ,
129- FEEDBACK_TIMER_I2S_FRAMESTART_CAPTURE ));
130-
131- nrfx_gppi_channels_enable (BIT (i2s_framestart_gppi_channel ));
123+ nrfx_gppi_conn_enable (i2s_framestart_gppi_handle );
132124
133125 /* Enable feedback timer */
134126 nrfx_timer_enable (& feedback_timer_instance );
0 commit comments