@@ -47,7 +47,7 @@ static bool ppi_trace_gpiote_pin_init(
4747 }
4848
4949 if (nrfx_gpiote_channel_alloc (ppi_trace_gpiote_pin -> gpiote ,
50- & ppi_trace_gpiote_pin -> gpiote_channel ) != NRFX_SUCCESS ) {
50+ & ppi_trace_gpiote_pin -> gpiote_channel ) < 0 ) {
5151 LOG_ERR ("Failed to allocate GPIOTE channel." );
5252 return false;
5353 }
@@ -129,7 +129,7 @@ void *ppi_trace_pair_config(uint32_t pin, uint32_t start_evt, uint32_t stop_evt)
129129 /* Address to aligned 32 bit variable will always have 0 on last two bits. Last bit is
130130 * used to indicated that it is a pair.
131131 */
132- return (void * )((uintptr_t )handle1 | 0x1 );
132+ return (void * )((uintptr_t )handle1 | BIT ( 0 ) );
133133#endif
134134}
135135
@@ -150,11 +150,18 @@ int ppi_trace_dppi_ch_trace(uint32_t pin, uint32_t dppi_ch, NRF_DPPIC_Type *p_dp
150150 .domain_id = nrfx_gppi_domain_id_get ((uint32_t )p_dppi ),
151151 .channel = dppi_ch
152152 };
153-
154- if (nrfx_gppi_ext_conn_alloc (resource .domain_id , dst_domain , & handle , & resource ) < 0 ) {
153+ int err ;
154+
155+ err = nrfx_gppi_ext_conn_alloc (resource .domain_id , dst_domain , & handle , & resource );
156+ if (err == - ENOTSUP ) {
157+ /* System with single DPPI instance. Just attach to the channel. */
158+ nrfx_gppi_ep_attach (tep , dppi_ch );
159+ return 0 ;
160+ } else if (err < 0 ) {
155161 LOG_ERR ("Failed to allocate GPPI channel." );
156162 return - ENOMEM ;
157163 }
164+
158165 nrfx_gppi_ep_attach (tep , handle );
159166 nrfx_gppi_conn_enable (handle );
160167
@@ -164,22 +171,22 @@ int ppi_trace_dppi_ch_trace(uint32_t pin, uint32_t dppi_ch, NRF_DPPIC_Type *p_dp
164171
165172void ppi_trace_enable (void * handle )
166173{
167- nrfx_gppi_handle_t * handles = (nrfx_gppi_handle_t * )((uintptr_t )handle & 0x1 );
174+ nrfx_gppi_handle_t * handles = (nrfx_gppi_handle_t * )((uintptr_t )handle & ~ BIT ( 0 ) );
168175
169176 nrfx_gppi_conn_enable (handles [0 ]);
170177 /* If LSB bit is set it indicates that handle is for pair of connections. */
171- if ((uintptr_t )handle & 0x1 ) {
178+ if ((uintptr_t )handle & BIT ( 0 ) ) {
172179 nrfx_gppi_conn_enable (handles [1 ]);
173180 }
174181}
175182
176183void ppi_trace_disable (void * handle )
177184{
178- nrfx_gppi_handle_t * handles = (nrfx_gppi_handle_t * )((uintptr_t )handle & 0x1 );
185+ nrfx_gppi_handle_t * handles = (nrfx_gppi_handle_t * )((uintptr_t )handle & ~ BIT ( 0 ) );
179186
180187 nrfx_gppi_conn_disable (handles [0 ]);
181188 /* If LSB bit is set it indicates that handle is for pair of connections. */
182- if ((uintptr_t )handle & 0x1 ) {
189+ if ((uintptr_t )handle & BIT ( 0 ) ) {
183190 nrfx_gppi_conn_disable (handles [1 ]);
184191 }
185192}
0 commit comments