@@ -84,7 +84,7 @@ static const struct device *gpio_port1_dev = DEVICE_DT_GET(DT_NODELABEL(gpio1));
8484#endif
8585
8686#if IS_ENABLED (CONFIG_PTT_CLK_OUT )
87- uint8_t ppi_channel ;
87+ nrfx_gppi_handle_t ppi_handle ;
8888uint8_t task_channel ;
8989#endif /* IS_ENABLED(CONFIG_PTT_CLK_OUT) */
9090
@@ -143,6 +143,7 @@ bool ptt_clk_out_ext(uint8_t pin, bool mode)
143143{
144144#if IS_ENABLED (CONFIG_PTT_CLK_OUT )
145145 uint32_t compare_evt_addr ;
146+ uint32_t tep ;
146147 nrfx_err_t err ;
147148 const nrfx_gpiote_t * gpiote = NRF_GPIOTE_FOR_PSEL (pin );
148149
@@ -178,35 +179,30 @@ bool ptt_clk_out_ext(uint8_t pin, bool mode)
178179
179180 compare_evt_addr =
180181 nrfx_timer_event_address_get (& clk_timer , NRF_TIMER_EVENT_COMPARE0 );
181-
182+ tep = nrfx_gpiote_out_task_address_get ( gpiote , pin );
182183 nrfx_gpiote_out_task_enable (gpiote , pin );
183184
184185 /* Allocate a (D)PPI channel. */
185- err = nrfx_gppi_channel_alloc (& ppi_channel );
186-
187- if (err != NRFX_SUCCESS ) {
186+ err = nrfx_gppi_conn_alloc (compare_evt_addr , tep , & ppi_handle );
187+ if (err < 0 ) {
188188 LOG_ERR ("(D)PPI channel allocation error: %08x" , err );
189189 return false;
190190 }
191191
192- nrfx_gppi_channel_endpoints_setup (
193- ppi_channel , compare_evt_addr ,
194- nrf_gpiote_task_address_get (gpiote -> p_reg ,
195- nrfx_gpiote_in_event_get (gpiote , pin )));
196-
197192 /* Enable (D)PPI channel. */
198- nrfx_gppi_channels_enable ( BIT ( ppi_channel ) );
193+ nrfx_gppi_conn_enable ( ppi_handle );
199194
200195 nrfx_timer_enable (& clk_timer );
201196 } else {
202197 nrfx_timer_disable (& clk_timer );
203198 nrfx_gpiote_out_task_disable (gpiote , pin );
204- err = nrfx_gppi_channel_free (ppi_channel );
205199
206- if (err != NRFX_SUCCESS ) {
207- LOG_ERR ("Failed to disable (D)PPI channel, error: %08x" , err );
208- return false;
209- }
200+ compare_evt_addr =
201+ nrfx_timer_event_address_get (& clk_timer , NRF_TIMER_EVENT_COMPARE0 );
202+ tep = nrfx_gpiote_out_task_address_get (gpiote , pin );
203+ nrfx_gppi_conn_disable (ppi_handle );
204+ nrfx_gppi_conn_free (compare_evt_addr , tep , ppi_handle );
205+
210206 nrfx_gpiote_pin_uninit (gpiote , pin );
211207 err = nrfx_gpiote_channel_free (gpiote , task_channel );
212208
0 commit comments