2525static const nrfx_rtc_t app_rtc_instance = NRFX_RTC_INSTANCE (0 );
2626static const nrfx_timer_t app_timer_instance = NRFX_TIMER_INSTANCE (0 );
2727
28- static uint8_t ppi_chan_on_rtc_match ;
28+ static nrfx_gppi_handle_t ppi_on_rtc_match ;
2929static volatile uint32_t num_rtc_overflows ;
3030
3131static void rtc_isr_handler (nrfx_rtc_int_type_t int_type )
@@ -44,7 +44,7 @@ static void unused_timer_isr_handler(nrf_timer_event_t event_type, void *ctx)
4444static int rtc_config (void )
4545{
4646 int ret ;
47- uint8_t dppi_channel_rtc_start ;
47+ nrfx_gppi_handle_t dppi_channel_rtc_start ;
4848 const nrfx_rtc_config_t rtc_cfg = NRFX_RTC_DEFAULT_CONFIG ;
4949
5050 ret = nrfx_rtc_init (& app_rtc_instance , & rtc_cfg , rtc_isr_handler );
@@ -65,60 +65,48 @@ static int rtc_config(void)
6565 nrfx_rtc_tick_enable (& app_rtc_instance , false);
6666 nrfx_rtc_enable (& app_rtc_instance );
6767
68-
68+ nrf_ipc_receive_config_set ( NRF_IPC , 4 , NRF_IPC_CHANNEL_4 );
6969 /* The application core RTC is started synchronously with the controller
7070 * RTC using PPI over IPC.
7171 */
72- ret = nrfx_gppi_channel_alloc (& dppi_channel_rtc_start );
73- if (ret != NRFX_SUCCESS ) {
72+ ret = nrfx_gppi_conn_alloc (nrfx_rtc_task_address_get (& app_rtc_instance , NRF_RTC_TASK_CLEAR ),
73+ nrf_ipc_event_address_get (NRF_IPC , NRF_IPC_EVENT_RECEIVE_4 ),
74+ & dppi_rtc_start );
75+ if (ret < 0 ) {
7476 printk ("nrfx DPPI channel alloc error for starting RTC: %d" , ret );
75- return - ENODEV ;
77+ return ret ;
7678 }
77-
78- nrf_ipc_receive_config_set (NRF_IPC , 4 , NRF_IPC_CHANNEL_4 );
79-
80- nrfx_gppi_channel_endpoints_setup (dppi_channel_rtc_start ,
81- nrfx_rtc_task_address_get (& app_rtc_instance ,
82- NRF_RTC_TASK_CLEAR ),
83- nrf_ipc_event_address_get (NRF_IPC ,
84- NRF_IPC_EVENT_RECEIVE_4 ));
85-
86- nrfx_gppi_channels_enable (BIT (dppi_channel_rtc_start ));
79+ nrfx_gppi_conn_enable (dppi_rtc_start );
8780
8881 return 0 ;
8982}
9083
9184static int timer_config (void )
9285{
9386 int ret ;
94- uint8_t ppi_chan_timer_clear_on_rtc_tick ;
87+ nrfx_gppi_handle_t ppi_timer_clear_on_rtc_tick ;
9588 const nrfx_timer_config_t timer_cfg = {
9689 .frequency = NRFX_MHZ_TO_HZ (1UL ),
9790 .mode = NRF_TIMER_MODE_TIMER ,
9891 .bit_width = NRF_TIMER_BIT_WIDTH_8 ,
9992 .interrupt_priority = NRFX_TIMER_DEFAULT_CONFIG_IRQ_PRIORITY ,
10093 .p_context = NULL };
94+ uint32_t eep = nrfx_rtc_event_address_get (& app_rtc_instance , NRF_RTC_EVENT_TICK );
95+ uint32_t tep = nrfx_timer_task_address_get (& app_timer_instance , NRF_TIMER_TASK_CLEAR );
10196
10297 ret = nrfx_timer_init (& app_timer_instance , & timer_cfg , unused_timer_isr_handler );
10398 if (ret != NRFX_SUCCESS ) {
10499 printk ("Failed initializing timer (ret: %d)\n" , ret - NRFX_ERROR_BASE_NUM );
105100 return - ENODEV ;
106101 }
107102
108- /* Clear the TIMER every RTC tick. */
109- if (nrfx_gppi_channel_alloc ( & ppi_chan_timer_clear_on_rtc_tick ) != NRFX_SUCCESS ) {
103+ ret = nrfx_gppi_conn_alloc ( eep , tep , & ppi_timer_clear_on_rtc_tick );
104+ if (ret < 0 ) {
110105 printk ("Failed allocating for clearing TIMER on RTC TICK\n" );
111- return - ENOMEM ;
106+ return ret ;
112107 }
113108
114- nrfx_gppi_channel_endpoints_setup (ppi_chan_timer_clear_on_rtc_tick ,
115- nrfx_rtc_event_address_get (& app_rtc_instance ,
116- NRF_RTC_EVENT_TICK ),
117- nrfx_timer_task_address_get (& app_timer_instance ,
118- NRF_TIMER_TASK_CLEAR ));
119-
120- nrfx_gppi_channels_enable (BIT (ppi_chan_timer_clear_on_rtc_tick ));
121-
109+ nrfx_gppi_conn_enable (ppi_timer_clear_on_rtc_tick );
122110 nrfx_timer_enable (& app_timer_instance );
123111
124112 return 0 ;
@@ -135,34 +123,31 @@ static int timer_config(void)
135123 */
136124int config_egu_trigger_on_rtc_and_timer_match (void )
137125{
138- uint8_t ppi_chan_on_timer_match ;
126+ nrfx_gppi_handle_t ppi_on_timer_match ;
127+ nrfx_gppi_group_handle_t group ;
128+ uint32_t eep0 = nrfx_rtc_event_address_get (& app_rtc_instance , NRF_RTC_EVENT_COMPARE_0 );
129+ uint32_t eep1 = nrfx_timer_event_address_get (& app_timer_instance , NRF_TIMER_EVENT_COMPARE0 ),
130+ uint32_t tep1 = nrf_egu_task_address_get (NRF_EGU0 , NRF_EGU_TASK_TRIGGER0 );
131+ int ret ;
139132
140- if (nrfx_gppi_channel_alloc (& ppi_chan_on_rtc_match ) != NRFX_SUCCESS ) {
141- printk ("Failed allocating for RTC match\n" );
142- return - ENOMEM ;
133+ ret = nrfx_gppi_group_alloc (& eep0 , 1 , & group );
134+ if (ret < 0 ) {
135+ printk ("Failed allocating group\n" );
136+ return ret ;
143137 }
144138
145- if (nrfx_gppi_channel_alloc (& ppi_chan_on_timer_match ) != NRFX_SUCCESS ) {
146- printk ("Failed allocating for TIMER match\n" );
147- return - ENOMEM ;
139+ ret = nrfx_gppi_conn_alloc (eep0 , nrfx_gppi_group_task_en_addr (group ), & ppi_on_rtc_match );
140+ if (ret < 0 ) {
141+ printk ("Failed allocating for RTC match\n" );
142+ return ret ;
148143 }
149144
150- nrfx_gppi_group_clear (NRFX_GPPI_CHANNEL_GROUP0 );
151- nrfx_gppi_group_disable (NRFX_GPPI_CHANNEL_GROUP0 );
152- nrfx_gppi_channels_include_in_group (
153- BIT (ppi_chan_on_timer_match ) | BIT (ppi_chan_on_rtc_match ),
154- NRFX_GPPI_CHANNEL_GROUP0 );
155-
156- nrfx_gppi_channel_endpoints_setup (ppi_chan_on_rtc_match ,
157- nrfx_rtc_event_address_get (& app_rtc_instance ,
158- NRF_RTC_EVENT_COMPARE_0 ),
159- nrfx_gppi_task_address_get (NRFX_GPPI_TASK_CHG0_EN ));
160- nrfx_gppi_channel_endpoints_setup (ppi_chan_on_timer_match ,
161- nrfx_timer_event_address_get (& app_timer_instance ,
162- NRF_TIMER_EVENT_COMPARE0 ),
163- nrfx_gppi_task_address_get (NRFX_GPPI_TASK_CHG0_DIS ));
164- nrfx_gppi_fork_endpoint_setup (ppi_chan_on_timer_match ,
165- nrf_egu_task_address_get (NRF_EGU0 , NRF_EGU_TASK_TRIGGER0 ));
145+ ret = nrfx_gppi_conn_alloc (eep1 , tep1 , & ppi_on_timer_match );
146+ if (ret < 0 ) {
147+ printk ("Failed allocating for RTC match\n" );
148+ return ret ;
149+ }
150+ (void )nrfx_gppi_ep_attach (ppi_on_timer_match , nrfx_gppi_group_task_dis_addr (group ));
166151
167152 return 0 ;
168153}
@@ -253,7 +238,7 @@ void controller_time_trigger_set(uint64_t timestamp_us)
253238 }
254239
255240 nrfx_timer_compare (& app_timer_instance , 0 , timer_val , false);
256- nrfx_gppi_channels_enable ( BIT ( ppi_chan_on_rtc_match ) );
241+ nrfx_gppi_conn_enable ( ppi_on_rtc_match );
257242}
258243
259244uint32_t controller_time_trigger_event_addr_get (void )
0 commit comments