55 */
66#include <debug/cpu_load.h>
77#include <zephyr/shell/shell.h>
8- #ifdef DPPI_PRESENT
9- #include <nrfx_dppi.h>
10- #else
11- #include <nrfx_ppi.h>
12- #endif
138#include <helpers/nrfx_gppi.h>
149#include <nrfx_timer.h>
1510#include <hal/nrf_rtc.h>
@@ -46,10 +41,7 @@ static uint32_t shared_ch_mask;
4641/** @brief Allocate (D)PPI channel. */
4742static nrfx_err_t ppi_alloc (uint8_t * ch , uint32_t evt )
4843{
49- nrfx_err_t err ;
5044#ifdef DPPI_PRESENT
51- nrfx_dppi_t dppi = NRFX_DPPI_INSTANCE (0 );
52-
5345 if (* PUBLISH_ADDR (evt ) != 0 ) {
5446 if (!IS_ENABLED (CONFIG_NRF_CPU_LOAD_USE_SHARED_DPPI_CHANNELS )) {
5547 return NRFX_ERROR_BUSY ;
@@ -59,31 +51,22 @@ static nrfx_err_t ppi_alloc(uint8_t *ch, uint32_t evt)
5951 * channel id.
6052 */
6153 * ch = * PUBLISH_ADDR (evt ) & DPPIC_SUBSCRIBE_CHG_EN_CHIDX_Msk ;
62- err = NRFX_SUCCESS ;
6354 shared_ch_mask |= BIT (* ch );
64- } else {
65- err = nrfx_dppi_channel_alloc (& dppi , ch );
55+ return NRFX_SUCCESS ;
6656 }
67- #else
68- err = nrfx_ppi_channel_alloc ((nrf_ppi_channel_t * )ch );
6957#endif
70- return err ;
58+ return nrfx_gppi_channel_alloc ( ch ) ;
7159}
7260
7361static nrfx_err_t ppi_free (uint8_t ch )
7462{
7563#ifdef DPPI_PRESENT
76- nrfx_dppi_t dppi = NRFX_DPPI_INSTANCE (0 );
77-
78- if (!IS_ENABLED (CONFIG_NRF_CPU_LOAD_USE_SHARED_DPPI_CHANNELS )
79- || ((BIT (ch ) & shared_ch_mask ) == 0 )) {
80- return nrfx_dppi_channel_free (& dppi , ch );
81- } else {
64+ if (IS_CH_SHARED (ch )) {
65+ shared_ch_mask &= ~BIT (ch );
8266 return NRFX_SUCCESS ;
8367 }
84- #else
85- return nrfx_ppi_channel_free ((nrf_ppi_channel_t )ch );
8668#endif
69+ return nrfx_gppi_channel_free (ch );
8770}
8871
8972static void ppi_cleanup (uint8_t ch_tick , uint8_t ch_sleep , uint8_t ch_wakeup )
0 commit comments