99#include "feedback.h"
1010
1111#include <nrfx_gpiote.h>
12+ #include <gpiote_nrfx.h>
1213#include <nrfx_timer.h>
1314#include <hal/nrf_gpio.h>
1415#include <helpers/nrfx_gppi.h>
@@ -59,8 +60,7 @@ static inline void feedback_target_init(void)
5960#error "Unsupported target"
6061#endif
6162
62- static const nrfx_gpiote_t gpiote =
63- NRFX_GPIOTE_INSTANCE (FEEDBACK_GPIOTE_INSTANCE_NUMBER );
63+ #define FEEDBACK_GPIOTE_NODE DT_NODELABEL(UTIL_CAT(gpiote, FEEDBACK_GPIOTE_INSTANCE_NUMBER))
6464
6565static nrfx_timer_t feedback_timer_instance =
6666 NRFX_TIMER_INSTANCE (NRF_TIMER_INST_GET (FEEDBACK_TIMER_INSTANCE_NUMBER ));
@@ -117,11 +117,11 @@ static struct feedback_ctx {
117117 };
118118} fb_ctx ;
119119
120- static nrfx_err_t feedback_edge_counter_setup (void )
120+ static int feedback_edge_counter_setup (void )
121121{
122- nrfx_err_t err ;
123122 uint8_t feedback_gpiote_channel ;
124123 nrfx_gppi_handle_t feedback_gppi_handle ;
124+ nrfx_gpiote_t * gpiote = & GPIOTE_NRFX_INST_BY_NODE (FEEDBACK_GPIOTE_NODE );
125125 nrfx_gpiote_trigger_config_t trigger_config = {
126126 .trigger = NRFX_GPIOTE_TRIGGER_TOGGLE ,
127127 .p_in_channel = & feedback_gpiote_channel ,
@@ -133,13 +133,13 @@ static nrfx_err_t feedback_edge_counter_setup(void)
133133 };
134134 int rv ;
135135
136- err = nrfx_gpiote_channel_alloc (& gpiote , & feedback_gpiote_channel );
137- if (err != NRFX_SUCCESS ) {
138- return err ;
136+ rv = nrfx_gpiote_channel_alloc (gpiote , & feedback_gpiote_channel );
137+ if (rv != 0 ) {
138+ return rv ;
139139 }
140140
141- nrfx_gpiote_input_configure (& gpiote , FEEDBACK_PIN , & input_pin_config );
142- nrfx_gpiote_trigger_enable (& gpiote , FEEDBACK_PIN , false);
141+ nrfx_gpiote_input_configure (gpiote , FEEDBACK_PIN , & input_pin_config );
142+ nrfx_gpiote_trigger_enable (gpiote , FEEDBACK_PIN , false);
143143
144144 /* Configure TIMER in COUNTER mode */
145145 const nrfx_timer_config_t cfg = {
@@ -150,14 +150,14 @@ static nrfx_err_t feedback_edge_counter_setup(void)
150150 .p_context = NULL ,
151151 };
152152
153- err = nrfx_timer_init (& feedback_timer_instance , & cfg , NULL );
154- if (err != NRFX_SUCCESS ) {
155- LOG_ERR ("nrfx timer init error (sample clk feedback) - Return value: %d" , err );
156- return err ;
153+ rv = nrfx_timer_init (& feedback_timer_instance , & cfg , NULL );
154+ if (rv != 0 ) {
155+ LOG_ERR ("nrfx timer init error (sample clk feedback) - Return value: %d" , rv );
156+ return rv ;
157157 }
158158
159159 /* Subscribe TIMER COUNT task to GPIOTE IN event */
160- uint32_t eep = nrfx_gpiote_in_event_address_get (& gpiote , FEEDBACK_PIN );
160+ uint32_t eep = nrfx_gpiote_in_event_address_get (gpiote , FEEDBACK_PIN );
161161 uint32_t tep = nrfx_timer_task_address_get (& feedback_timer_instance , NRF_TIMER_TASK_COUNT );
162162
163163 rv = nrfx_gppi_conn_alloc (eep , tep , & feedback_gppi_handle );
@@ -168,12 +168,12 @@ static nrfx_err_t feedback_edge_counter_setup(void)
168168
169169 nrfx_gppi_conn_enable (feedback_gppi_handle );
170170
171- return NRFX_SUCCESS ;
171+ return 0 ;
172172}
173173
174- static nrfx_err_t feedback_relative_timer_setup (void )
174+ static int feedback_relative_timer_setup (void )
175175{
176- nrfx_err_t err ;
176+ int err ;
177177 const nrfx_timer_config_t cfg = {
178178 .frequency = NRFX_MHZ_TO_HZ (16UL ),
179179 .mode = NRF_TIMER_MODE_TIMER ,
@@ -183,7 +183,7 @@ static nrfx_err_t feedback_relative_timer_setup(void)
183183 };
184184
185185 err = nrfx_timer_init (& feedback_timer_instance , & cfg , NULL );
186- if (err != NRFX_SUCCESS ) {
186+ if (err != 0 ) {
187187 LOG_ERR ("nrfx timer init error (relative timer) - Return value: %d" , err );
188188 }
189189
@@ -192,7 +192,6 @@ static nrfx_err_t feedback_relative_timer_setup(void)
192192
193193struct feedback_ctx * feedback_init (void )
194194{
195- nrfx_err_t err ;
196195 nrfx_gppi_handle_t usbd_sof_gppi_handle ;
197196 nrfx_gppi_handle_t i2s_framestart_gppi_handle ;
198197 int rv ;
@@ -202,12 +201,12 @@ struct feedback_ctx *feedback_init(void)
202201 feedback_reset_ctx (& fb_ctx , false);
203202
204203 if (IS_ENABLED (CONFIG_APP_USE_I2S_LRCLK_EDGES_COUNTER )) {
205- err = feedback_edge_counter_setup ();
204+ rv = feedback_edge_counter_setup ();
206205 } else {
207- err = feedback_relative_timer_setup ();
206+ rv = feedback_relative_timer_setup ();
208207 }
209208
210- if (err != NRFX_SUCCESS ) {
209+ if (rv != 0 ) {
211210 return & fb_ctx ;
212211 }
213212
0 commit comments