1313#include <hal/nrf_pwm.h>
1414#endif
1515#include <nrfx_gpiote.h>
16- #ifdef PPI_PRESENT
17- #include <nrfx_ppi.h>
18- #endif
16+ #include <helpers/nrfx_gppi.h>
1917#include <nrf_peripherals.h>
2018#include <zephyr/logging/log.h>
2119#include <zephyr/irq.h>
@@ -438,21 +436,12 @@ static int instance_init(const struct device *dev)
438436 nrf_pwm_shorts_set (dev_config -> pwm , NRF_PWM_SHORT_SEQEND0_STOP_MASK );
439437#else
440438 nrfx_err_t err ;
441- nrf_ppi_channel_t ppi_ch ;
439+ nrfx_gppi_handle_t ppi_handle ;
440+ int rv ;
442441
443442 for (int i = 0 ; i < GROUP_SIZE ; ++ i ) {
444443 uint8_t * gpiote_ch = & dev_data -> gpiote_ch [i ];
445444
446- err = nrfx_ppi_channel_alloc (& ppi_ch );
447- if (err != NRFX_SUCCESS ) {
448- LOG_ERR ("Failed to allocate PPI channel." );
449- /* Do not bother with freeing resources allocated
450- * so far. The application needs to be reconfigured
451- * anyway.
452- */
453- return - ENOMEM ;
454- }
455-
456445 err = nrfx_gpiote_channel_alloc (& dev_config -> gpiote , gpiote_ch );
457446 if (err != NRFX_SUCCESS ) {
458447 LOG_ERR ("Failed to allocate GPIOTE channel." );
@@ -463,12 +452,21 @@ static int instance_init(const struct device *dev)
463452 return - ENOMEM ;
464453 }
465454
466- nrf_ppi_channel_endpoint_setup ( NRF_PPI , ppi_ch ,
455+ rv = nrfx_gppi_conn_alloc (
467456 nrf_timer_event_address_get (dev_config -> timer ,
468457 nrf_timer_compare_event_get (1 + i )),
469458 nrf_gpiote_event_address_get (dev_config -> gpiote .p_reg ,
470- nrf_gpiote_out_task_get (* gpiote_ch )));
471- nrf_ppi_channel_enable (NRF_PPI , ppi_ch );
459+ nrf_gpiote_out_task_get (* gpiote_ch )),
460+ & ppi_handle );
461+ if (rv < 0 ) {
462+ LOG_ERR ("Failed to allocate PPI channel." );
463+ /* Do not bother with freeing resources allocated
464+ * so far. The application needs to be reconfigured
465+ * anyway.
466+ */
467+ return rv ;
468+ }
469+ nrfx_gppi_conn_enable (ppi_handle );
472470 }
473471#endif /* USE_PWM */
474472
0 commit comments