5
5
*/
6
6
#include <debug/cpu_load.h>
7
7
#include <zephyr/shell/shell.h>
8
- #ifdef DPPI_PRESENT
9
- #include <nrfx_dppi.h>
10
- #else
11
- #include <nrfx_ppi.h>
12
- #endif
13
8
#include <helpers/nrfx_gppi.h>
14
9
#include <nrfx_timer.h>
15
10
#include <hal/nrf_rtc.h>
@@ -46,10 +41,7 @@ static uint32_t shared_ch_mask;
46
41
/** @brief Allocate (D)PPI channel. */
47
42
static nrfx_err_t ppi_alloc (uint8_t * ch , uint32_t evt )
48
43
{
49
- nrfx_err_t err ;
50
44
#ifdef DPPI_PRESENT
51
- nrfx_dppi_t dppi = NRFX_DPPI_INSTANCE (0 );
52
-
53
45
if (* PUBLISH_ADDR (evt ) != 0 ) {
54
46
if (!IS_ENABLED (CONFIG_NRF_CPU_LOAD_USE_SHARED_DPPI_CHANNELS )) {
55
47
return NRFX_ERROR_BUSY ;
@@ -59,31 +51,23 @@ static nrfx_err_t ppi_alloc(uint8_t *ch, uint32_t evt)
59
51
* channel id.
60
52
*/
61
53
* ch = * PUBLISH_ADDR (evt ) & DPPIC_SUBSCRIBE_CHG_EN_CHIDX_Msk ;
62
- err = NRFX_SUCCESS ;
63
54
shared_ch_mask |= BIT (* ch );
64
- } else {
65
- err = nrfx_dppi_channel_alloc (& dppi , ch );
55
+ return NRFX_SUCCESS ;
66
56
}
67
- #else
68
- err = nrfx_ppi_channel_alloc ((nrf_ppi_channel_t * )ch );
69
57
#endif
70
- return err ;
58
+ return nrfx_gppi_channel_alloc ( ch ) ;
71
59
}
72
60
73
61
static nrfx_err_t ppi_free (uint8_t ch )
74
62
{
75
63
#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_ENABLED (CONFIG_NRF_CPU_LOAD_USE_SHARED_DPPI_CHANNELS )
65
+ && ((BIT (ch ) & shared_ch_mask ) == 0 )) {
66
+ shared_ch_mask &= ~BIT (ch );
82
67
return NRFX_SUCCESS ;
83
68
}
84
- #else
85
- return nrfx_ppi_channel_free ((nrf_ppi_channel_t )ch );
86
69
#endif
70
+ return nrfx_gppi_channel_free (ch );
87
71
}
88
72
89
73
static void ppi_cleanup (uint8_t ch_tick , uint8_t ch_sleep , uint8_t ch_wakeup )
0 commit comments