1 /*
2 * Copyright (c) 2018 - 2025, Nordic Semiconductor ASA
3 * All rights reserved.
4 *
5 * SPDX-License-Identifier: BSD-3-Clause
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions are met:
9 *
10 * 1. Redistributions of source code must retain the above copyright notice, this
11 * list of conditions and the following disclaimer.
12 *
13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the
15 * documentation and/or other materials provided with the distribution.
16 *
17 * 3. Neither the name of the copyright holder nor the names of its
18 * contributors may be used to endorse or promote products derived from this
19 * software without specific prior written permission.
20 *
21 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
22 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
25 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
26 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
27 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
28 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
29 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
30 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
31 * POSSIBILITY OF SUCH DAMAGE.
32 */
33
34 #include <nrfx.h>
35
36 // Driver for single instance DPPI
37 #if NRFX_CHECK(NRFX_DPPI_ENABLED)
38
39 #include <nrfx_dppi.h>
40 #include <helpers/nrfx_flag32_allocator.h>
41
42 #define NRFX_LOG_MODULE DPPI
43 #include <nrfx_log.h>
44
45 #if !defined(NRFX_DPPI0_CHANNELS_USED) && defined(NRFX_DPPI_CHANNELS_USED)
46 #define NRFX_DPPI0_CHANNELS_USED NRFX_DPPI_CHANNELS_USED
47 #endif
48
49 #if !defined(NRFX_DPPI0_GROUPS_USED) && defined(NRFX_DPPI_GROUPS_USED)
50 #define NRFX_DPPI0_GROUPS_USED NRFX_DPPI_GROUPS_USED
51 #endif
52
53 #if defined(NRF_DPPIC0)
54
55 #if !defined(NRFX_DPPI0_CHANNELS_USED)
56 /* Bitmask that defines DPPI0 channels that are reserved for use outside of the nrfx library. */
57 #define NRFX_DPPI0_CHANNELS_USED 0UL
58 #endif
59
60 #if !defined(NRFX_DPPI0_GROUPS_USED)
61 /* Bitmask that defines DPPI0 groups that are reserved for use outside of the nrfx library. */
62 #define NRFX_DPPI0_GROUPS_USED 0UL
63 #endif
64
65 #endif
66
67 #if defined(NRF_DPPIC1)
68
69 #if !defined(NRFX_DPPI1_CHANNELS_USED)
70 /* Bitmask that defines DPPI1 channels that are reserved for use outside of the nrfx library. */
71 #define NRFX_DPPI1_CHANNELS_USED 0UL
72 #endif
73
74 #if !defined(NRFX_DPPI1_GROUPS_USED)
75 /* Bitmask that defines DPPI1 groups that are reserved for use outside of the nrfx library. */
76 #define NRFX_DPPI1_GROUPS_USED 0UL
77 #endif
78
79 #endif
80
81 #if defined(NRF_DPPIC00)
82
83 #if !defined(NRFX_DPPI00_CHANNELS_USED)
84 /* Bitmask that defines DPPI00 channels that are reserved for use outside of the nrfx library. */
85 #define NRFX_DPPI00_CHANNELS_USED 0UL
86 #endif
87
88 #if !defined(NRFX_DPPI00_GROUPS_USED)
89 /* Bitmask that defines DPPI00 groups that are reserved for use outside of the nrfx library. */
90 #define NRFX_DPPI00_GROUPS_USED 0UL
91 #endif
92
93 #endif
94
95 #if defined(NRF_DPPIC01)
96
97 #if !defined(NRFX_DPPI01_CHANNELS_USED)
98 /* Bitmask that defines DPPI01 channels that are reserved for use outside of the nrfx library. */
99 #define NRFX_DPPI01_CHANNELS_USED 0UL
100 #endif
101
102 #if !defined(NRFX_DPPI01_GROUPS_USED)
103 /* Bitmask that defines DPPI01 groups that are reserved for use outside of the nrfx library. */
104 #define NRFX_DPPI01_GROUPS_USED 0UL
105 #endif
106
107 #endif
108
109 #if defined(NRF_DPPIC10)
110
111 #if !defined(NRFX_DPPI10_CHANNELS_USED)
112 /* Bitmask that defines DPPI10 channels that are reserved for use outside of the nrfx library. */
113 #define NRFX_DPPI10_CHANNELS_USED 0UL
114 #endif
115
116 #if !defined(NRFX_DPPI10_GROUPS_USED)
117 /* Bitmask that defines DPPI10 groups that are reserved for use outside of the nrfx library. */
118 #define NRFX_DPPI10_GROUPS_USED 0UL
119 #endif
120
121 #endif
122
123 #if defined(NRF_DPPIC20)
124
125 #if !defined(NRFX_DPPI20_CHANNELS_USED)
126 /* Bitmask that defines DPPI20 channels that are reserved for use outside of the nrfx library. */
127 #define NRFX_DPPI20_CHANNELS_USED 0UL
128 #endif
129
130 #if !defined(NRFX_DPPI20_GROUPS_USED)
131 /* Bitmask that defines DPPI20 groups that are reserved for use outside of the nrfx library. */
132 #define NRFX_DPPI20_GROUPS_USED 0UL
133 #endif
134
135 #endif
136
137 #if defined(NRF_DPPIC30)
138
139 #if !defined(NRFX_DPPI30_CHANNELS_USED)
140 /* Bitmask that defines DPPI30 channels that are reserved for use outside of the nrfx library. */
141 #define NRFX_DPPI30_CHANNELS_USED 0UL
142 #endif
143
144 #if !defined(NRFX_DPPI30_GROUPS_USED)
145 /* Bitmask that defines DPPI30 groups that are reserved for use outside of the nrfx library. */
146 #define NRFX_DPPI30_GROUPS_USED 0UL
147 #endif
148
149 #endif
150
151 #if defined(NRF_DPPIC020)
152
153 #if !defined(NRFX_DPPI020_CHANNELS_USED)
154 /* Bitmask that defines DPPI020 channels that are reserved for use outside of the nrfx library. */
155 #define NRFX_DPPI020_CHANNELS_USED 0UL
156 #endif
157
158 #if !defined(NRFX_DPPI020_GROUPS_USED)
159 /* Bitmask that defines DPPI020 groups that are reserved for use outside of the nrfx library. */
160 #define NRFX_DPPI020_GROUPS_USED 0UL
161 #endif
162
163 #endif
164
165 #if defined(NRF_DPPIC030)
166
167 #if !defined(NRFX_DPPI030_CHANNELS_USED)
168 /* Bitmask that defines DPPI030 channels that are reserved for use outside of the nrfx library. */
169 #define NRFX_DPPI030_CHANNELS_USED 0UL
170 #endif
171
172 #if !defined(NRFX_DPPI030_GROUPS_USED)
173 /* Bitmask that defines DPPI030 groups that are reserved for use outside of the nrfx library. */
174 #define NRFX_DPPI030_GROUPS_USED 0UL
175 #endif
176
177 #endif
178
179 #if defined(NRF_DPPIC120)
180
181 #if !defined(NRFX_DPPI120_CHANNELS_USED)
182 /* Bitmask that defines DPPI120 channels that are reserved for use outside of the nrfx library. */
183 #define NRFX_DPPI120_CHANNELS_USED 0UL
184 #endif
185
186 #if !defined(NRFX_DPPI120_GROUPS_USED)
187 /* Bitmask that defines DPPI120 groups that are reserved for use outside of the nrfx library. */
188 #define NRFX_DPPI120_GROUPS_USED 0UL
189 #endif
190
191 #endif
192
193 #if defined(NRF_DPPIC130)
194
195 #if !defined(NRFX_DPPI130_CHANNELS_USED)
196 /* Bitmask that defines DPPI130 channels that are reserved for use outside of the nrfx library. */
197 #define NRFX_DPPI130_CHANNELS_USED 0UL
198 #endif
199
200 #if !defined(NRFX_DPPI130_GROUPS_USED)
201 /* Bitmask that defines DPPI130 groups that are reserved for use outside of the nrfx library. */
202 #define NRFX_DPPI130_GROUPS_USED 0UL
203 #endif
204
205 #endif
206
207 #if defined(NRF_DPPIC131)
208
209 #if !defined(NRFX_DPPI131_CHANNELS_USED)
210 /* Bitmask that defines DPPI131 channels that are reserved for use outside of the nrfx library. */
211 #define NRFX_DPPI131_CHANNELS_USED 0UL
212 #endif
213
214 #if !defined(NRFX_DPPI131_GROUPS_USED)
215 /* Bitmask that defines DPPI131 groups that are reserved for use outside of the nrfx library. */
216 #define NRFX_DPPI131_GROUPS_USED 0UL
217 #endif
218
219 #endif
220
221 #if defined(NRF_DPPIC132)
222
223 #if !defined(NRFX_DPPI132_CHANNELS_USED)
224 /* Bitmask that defines DPPI132 channels that are reserved for use outside of the nrfx library. */
225 #define NRFX_DPPI132_CHANNELS_USED 0UL
226 #endif
227
228 #if !defined(NRFX_DPPI132_GROUPS_USED)
229 /* Bitmask that defines DPPI132 groups that are reserved for use outside of the nrfx library. */
230 #define NRFX_DPPI132_GROUPS_USED 0UL
231 #endif
232
233 #endif
234
235 #if defined(NRF_DPPIC133)
236
237 #if !defined(NRFX_DPPI133_CHANNELS_USED)
238 /* Bitmask that defines DPPI133 channels that are reserved for use outside of the nrfx library. */
239 #define NRFX_DPPI133_CHANNELS_USED 0UL
240 #endif
241
242 #if !defined(NRFX_DPPI133_GROUPS_USED)
243 /* Bitmask that defines DPPI133 groups that are reserved for use outside of the nrfx library. */
244 #define NRFX_DPPI133_GROUPS_USED 0UL
245 #endif
246
247 #endif
248
249 #if defined(NRF_DPPIC134)
250
251 #if !defined(NRFX_DPPI134_CHANNELS_USED)
252 /* Bitmask that defines DPPI134 channels that are reserved for use outside of the nrfx library. */
253 #define NRFX_DPPI134_CHANNELS_USED 0UL
254 #endif
255
256 #if !defined(NRFX_DPPI134_GROUPS_USED)
257 /* Bitmask that defines DPPI134 groups that are reserved for use outside of the nrfx library. */
258 #define NRFX_DPPI134_GROUPS_USED 0UL
259 #endif
260
261 #endif
262
263 #if defined(NRF_DPPIC135)
264
265 #if !defined(NRFX_DPPI135_CHANNELS_USED)
266 /* Bitmask that defines DPPI135 channels that are reserved for use outside of the nrfx library. */
267 #define NRFX_DPPI135_CHANNELS_USED 0UL
268 #endif
269
270 #if !defined(NRFX_DPPI135_GROUPS_USED)
271 /* Bitmask that defines DPPI135 groups that are reserved for use outside of the nrfx library. */
272 #define NRFX_DPPI135_GROUPS_USED 0UL
273 #endif
274
275 #endif
276
277 #if defined(NRF_DPPIC136)
278
279 #if !defined(NRFX_DPPI136_CHANNELS_USED)
280 /* Bitmask that defines DPPI136 channels that are reserved for use outside of the nrfx library. */
281 #define NRFX_DPPI136_CHANNELS_USED 0UL
282 #endif
283
284 #if !defined(NRFX_DPPI136_GROUPS_USED)
285 /* Bitmask that defines DPPI136 groups that are reserved for use outside of the nrfx library. */
286 #define NRFX_DPPI136_GROUPS_USED 0UL
287 #endif
288
289 #endif
290
291 #define DPPI_CHANNELS_NUM(idx) NRFX_BIT_MASK(NRFX_CONCAT(DPPIC, idx, _CH_NUM)
292 #define DPPI_CHANNELS_USED(idx) NRFX_CONCAT(NRFX_DPPI, idx, _CHANNELS_USED)
293 #define DPPI_AVAILABLE_CHANNELS_MASK(idx) \
294 ((uint32_t)(DPPI_CHANNELS_NUM(idx)) & ~(DPPI_CHANNELS_USED(idx))))
295
296 #define DPPI_GROUPS_NUM(idx) NRFX_BIT_MASK(NRFX_CONCAT(DPPIC, idx, _GROUP_NUM)
297 #define DPPI_GROUPS_USED(idx) NRFX_CONCAT(NRFX_DPPI, idx, _GROUPS_USED)
298 #define DPPI_AVAILABLE_GROUPS_MASK(idx) \
299 ((uint32_t)(DPPI_GROUPS_NUM(idx)) & ~(DPPI_GROUPS_USED(idx))))
300
301 /* Structure holding state of the pins */
302 typedef struct
303 {
304 /**< Bitmap representing channels availability. */
305 nrfx_atomic_t allocated_channels;
306 /**< Bitmap representing groups availability. */
307 nrfx_atomic_t allocated_groups;
308 /**< Bitmap representing available channels. */
309 const uint32_t available_channels;
310 /**< Bitmap representing available groups. */
311 const uint32_t available_groups;
312 } dppic_control_block_t;
313
314 #define _NRFX_DPPIC_CB_INITIALIZER(periph_name, prefix, idx, _) \
315 [NRFX_CONCAT(NRFX_, periph_name, prefix##idx, _INST_IDX)] = { \
316 .allocated_channels = (nrfx_atomic_t)DPPI_AVAILABLE_CHANNELS_MASK(prefix##idx), \
317 .allocated_groups = (nrfx_atomic_t)DPPI_AVAILABLE_GROUPS_MASK(prefix##idx), \
318 .available_channels = DPPI_AVAILABLE_CHANNELS_MASK(prefix##idx), \
319 .available_groups = DPPI_AVAILABLE_GROUPS_MASK(prefix##idx), \
320 },
321
322 static dppic_control_block_t m_cb[NRFX_DPPI_ENABLED_COUNT] = {
323 NRFX_FOREACH_ENABLED(DPPI, _NRFX_DPPIC_CB_INITIALIZER, (), ())
324 };
325
dppi_free(nrfx_dppi_t const * p_instance)326 static void dppi_free(nrfx_dppi_t const * p_instance)
327 {
328 dppic_control_block_t * p_cb = &m_cb[p_instance->drv_inst_idx];
329 uint32_t mask = p_cb->available_groups & ~p_cb->allocated_groups;
330 uint8_t group_idx = NRF_DPPI_CHANNEL_GROUP0;
331
332 // Disable all channels
333 nrfy_dppi_channels_disable(p_instance->p_reg, p_cb->available_channels & ~p_cb->allocated_channels);
334
335 // Clear all groups configurations
336 while (mask)
337 {
338 nrf_dppi_channel_group_t group = (nrf_dppi_channel_group_t)group_idx;
339 if (mask & NRFX_BIT(group))
340 {
341 nrfy_dppi_group_clear(p_instance->p_reg, group);
342 mask &= ~NRFX_BIT(group);
343 }
344 group_idx++;
345 }
346
347 // Clear all allocated channels.
348 p_cb->allocated_channels = p_cb->available_channels;
349
350 // Clear all allocated groups.
351 p_cb->allocated_groups = p_cb->available_groups;
352 }
353
dppi_channel_alloc(nrfx_dppi_t const * p_instance,uint8_t * p_channel)354 static nrfx_err_t dppi_channel_alloc(nrfx_dppi_t const * p_instance, uint8_t * p_channel)
355 {
356 dppic_control_block_t * p_cb = &m_cb[p_instance->drv_inst_idx];
357
358 return nrfx_flag32_alloc(&p_cb->allocated_channels, p_channel);
359 }
360
dppi_channel_free(nrfx_dppi_t const * p_instance,uint8_t channel)361 static nrfx_err_t dppi_channel_free(nrfx_dppi_t const * p_instance, uint8_t channel)
362 {
363 dppic_control_block_t * p_cb = &m_cb[p_instance->drv_inst_idx];
364
365 nrfy_dppi_channels_disable(p_instance->p_reg, NRFX_BIT(channel));
366 return nrfx_flag32_free(&p_cb->allocated_channels, channel);
367 }
368
dppi_channel_enable(nrfx_dppi_t const * p_instance,uint8_t channel)369 static nrfx_err_t dppi_channel_enable(nrfx_dppi_t const * p_instance, uint8_t channel)
370 {
371 dppic_control_block_t * p_cb = &m_cb[p_instance->drv_inst_idx];
372
373 nrfx_err_t err_code = NRFX_SUCCESS;
374
375 if (!nrfx_flag32_is_allocated(p_cb->allocated_channels, channel))
376 {
377 err_code = NRFX_ERROR_INVALID_PARAM;
378 }
379 else
380 {
381 nrfy_dppi_channels_enable(p_instance->p_reg, NRFX_BIT(channel));
382 }
383 NRFX_LOG_INFO("Function: %s, error code: %s.", __func__, NRFX_LOG_ERROR_STRING_GET(err_code));
384 return err_code;
385 }
386
dppi_channel_disable(nrfx_dppi_t const * p_instance,uint8_t channel)387 static nrfx_err_t dppi_channel_disable(nrfx_dppi_t const * p_instance, uint8_t channel)
388 {
389 dppic_control_block_t * p_cb = &m_cb[p_instance->drv_inst_idx];
390
391 nrfx_err_t err_code = NRFX_SUCCESS;
392
393 if (!nrfx_flag32_is_allocated(p_cb->allocated_channels, channel))
394 {
395 err_code = NRFX_ERROR_INVALID_PARAM;
396 }
397 else
398 {
399 nrfy_dppi_channels_disable(p_instance->p_reg, NRFX_BIT(channel));
400 err_code = NRFX_SUCCESS;
401 }
402 NRFX_LOG_INFO("Function: %s, error code: %s.", __func__, NRFX_LOG_ERROR_STRING_GET(err_code));
403 return err_code;
404 }
405
dppi_group_alloc(nrfx_dppi_t const * p_instance,nrf_dppi_channel_group_t * p_group)406 static nrfx_err_t dppi_group_alloc(nrfx_dppi_t const * p_instance,
407 nrf_dppi_channel_group_t * p_group)
408 {
409 dppic_control_block_t * p_cb = &m_cb[p_instance->drv_inst_idx];
410
411 return nrfx_flag32_alloc(&p_cb->allocated_groups, (uint8_t *)p_group);
412 }
413
dppi_group_free(nrfx_dppi_t const * p_instance,nrf_dppi_channel_group_t group)414 static nrfx_err_t dppi_group_free(nrfx_dppi_t const * p_instance, nrf_dppi_channel_group_t group)
415 {
416 dppic_control_block_t * p_cb = &m_cb[p_instance->drv_inst_idx];
417
418 nrfy_dppi_group_disable(p_instance->p_reg, group);
419 return nrfx_flag32_free(&p_cb->allocated_groups, group);
420 }
421
dppi_channel_include_in_group(nrfx_dppi_t const * p_instance,uint8_t channel,nrf_dppi_channel_group_t group)422 static nrfx_err_t dppi_channel_include_in_group(nrfx_dppi_t const * p_instance,
423 uint8_t channel,
424 nrf_dppi_channel_group_t group)
425 {
426 dppic_control_block_t * p_cb = &m_cb[p_instance->drv_inst_idx];
427 nrfx_err_t err_code = NRFX_SUCCESS;
428
429 if (!nrfx_flag32_is_allocated(p_cb->allocated_groups, group) ||
430 !nrfx_flag32_is_allocated(p_cb->allocated_channels, channel))
431 {
432 err_code = NRFX_ERROR_INVALID_PARAM;
433 }
434 else
435 {
436 NRFY_CRITICAL_SECTION_ENTER();
437 nrfy_dppi_channels_include_in_group(p_instance->p_reg, NRFX_BIT(channel), group);
438 NRFY_CRITICAL_SECTION_EXIT();
439 }
440 NRFX_LOG_INFO("Function: %s, error code: %s.", __func__, NRFX_LOG_ERROR_STRING_GET(err_code));
441 return err_code;
442 }
443
dppi_channel_remove_from_group(nrfx_dppi_t const * p_instance,uint8_t channel,nrf_dppi_channel_group_t group)444 static nrfx_err_t dppi_channel_remove_from_group(nrfx_dppi_t const * p_instance,
445 uint8_t channel,
446 nrf_dppi_channel_group_t group)
447 {
448 dppic_control_block_t * p_cb = &m_cb[p_instance->drv_inst_idx];
449 nrfx_err_t err_code = NRFX_SUCCESS;
450
451 if (!nrfx_flag32_is_allocated(p_cb->allocated_groups, group) ||
452 !nrfx_flag32_is_allocated(p_cb->allocated_channels, channel))
453 {
454 err_code = NRFX_ERROR_INVALID_PARAM;
455 }
456 else
457 {
458 NRFY_CRITICAL_SECTION_ENTER();
459 nrfy_dppi_channels_remove_from_group(p_instance->p_reg, NRFX_BIT(channel), group);
460 NRFY_CRITICAL_SECTION_EXIT();
461 }
462 NRFX_LOG_INFO("Function: %s, error code: %s.", __func__, NRFX_LOG_ERROR_STRING_GET(err_code));
463 return err_code;
464 }
465
dppi_group_clear(nrfx_dppi_t const * p_instance,nrf_dppi_channel_group_t group)466 static nrfx_err_t dppi_group_clear(nrfx_dppi_t const * p_instance,
467 nrf_dppi_channel_group_t group)
468 {
469 dppic_control_block_t * p_cb = &m_cb[p_instance->drv_inst_idx];
470 nrfx_err_t err_code = NRFX_SUCCESS;
471
472 if (!nrfx_flag32_is_allocated(p_cb->allocated_groups, group))
473 {
474 err_code = NRFX_ERROR_INVALID_PARAM;
475 }
476 else
477 {
478 nrfy_dppi_channels_remove_from_group(p_instance->p_reg, p_cb->available_channels, group);
479 }
480 NRFX_LOG_INFO("Function: %s, error code: %s.", __func__, NRFX_LOG_ERROR_STRING_GET(err_code));
481 return err_code;
482 }
483
dppi_group_enable(nrfx_dppi_t const * p_instance,nrf_dppi_channel_group_t group)484 static nrfx_err_t dppi_group_enable(nrfx_dppi_t const * p_instance,
485 nrf_dppi_channel_group_t group)
486 {
487 dppic_control_block_t * p_cb = &m_cb[p_instance->drv_inst_idx];
488 nrfx_err_t err_code = NRFX_SUCCESS;
489
490 if (!nrfx_flag32_is_allocated(p_cb->allocated_groups, group))
491 {
492 err_code = NRFX_ERROR_INVALID_PARAM;
493 }
494 else
495 {
496 nrfy_dppi_group_enable(p_instance->p_reg, group);
497 }
498 NRFX_LOG_INFO("Function: %s, error code: %s.", __func__, NRFX_LOG_ERROR_STRING_GET(err_code));
499 return err_code;
500 }
501
dppi_group_disable(nrfx_dppi_t const * p_instance,nrf_dppi_channel_group_t group)502 static nrfx_err_t dppi_group_disable(nrfx_dppi_t const * p_instance,
503 nrf_dppi_channel_group_t group)
504 {
505 dppic_control_block_t * p_cb = &m_cb[p_instance->drv_inst_idx];
506 nrfx_err_t err_code = NRFX_SUCCESS;
507
508 if (!nrfx_flag32_is_allocated(p_cb->allocated_groups, group))
509 {
510 err_code = NRFX_ERROR_INVALID_PARAM;
511 }
512 else
513 {
514 nrfy_dppi_group_disable(p_instance->p_reg, group);
515 }
516 NRFX_LOG_INFO("Function: %s, error code: %s.", __func__, NRFX_LOG_ERROR_STRING_GET(err_code));
517 return err_code;
518 }
519
520 #if NRFX_API_VER_AT_LEAST(3, 8, 0)
521
nrfx_dppi_free(nrfx_dppi_t const * p_instance)522 void nrfx_dppi_free(nrfx_dppi_t const * p_instance)
523 {
524 dppi_free(p_instance);
525 }
526
nrfx_dppi_channel_alloc(nrfx_dppi_t const * p_instance,uint8_t * p_channel)527 nrfx_err_t nrfx_dppi_channel_alloc(nrfx_dppi_t const * p_instance, uint8_t * p_channel)
528 {
529 return dppi_channel_alloc(p_instance, p_channel);
530 }
531
nrfx_dppi_channel_free(nrfx_dppi_t const * p_instance,uint8_t channel)532 nrfx_err_t nrfx_dppi_channel_free(nrfx_dppi_t const * p_instance, uint8_t channel)
533 {
534 return dppi_channel_free(p_instance, channel);
535 }
536
nrfx_dppi_channel_enable(nrfx_dppi_t const * p_instance,uint8_t channel)537 nrfx_err_t nrfx_dppi_channel_enable(nrfx_dppi_t const * p_instance, uint8_t channel)
538 {
539 return dppi_channel_enable(p_instance, channel);
540 }
541
nrfx_dppi_channel_disable(nrfx_dppi_t const * p_instance,uint8_t channel)542 nrfx_err_t nrfx_dppi_channel_disable(nrfx_dppi_t const * p_instance, uint8_t channel)
543 {
544 return dppi_channel_disable(p_instance, channel);
545 }
546
nrfx_dppi_group_alloc(nrfx_dppi_t const * p_instance,nrf_dppi_channel_group_t * p_group)547 nrfx_err_t nrfx_dppi_group_alloc(nrfx_dppi_t const * p_instance,
548 nrf_dppi_channel_group_t * p_group)
549 {
550 return dppi_group_alloc(p_instance, p_group);
551 }
552
nrfx_dppi_group_free(nrfx_dppi_t const * p_instance,nrf_dppi_channel_group_t group)553 nrfx_err_t nrfx_dppi_group_free(nrfx_dppi_t const * p_instance, nrf_dppi_channel_group_t group)
554 {
555 return dppi_group_free(p_instance, group);
556 }
557
nrfx_dppi_channel_include_in_group(nrfx_dppi_t const * p_instance,uint8_t channel,nrf_dppi_channel_group_t group)558 nrfx_err_t nrfx_dppi_channel_include_in_group(nrfx_dppi_t const * p_instance,
559 uint8_t channel,
560 nrf_dppi_channel_group_t group)
561 {
562 return dppi_channel_include_in_group(p_instance, channel, group);
563 }
564
nrfx_dppi_channel_remove_from_group(nrfx_dppi_t const * p_instance,uint8_t channel,nrf_dppi_channel_group_t group)565 nrfx_err_t nrfx_dppi_channel_remove_from_group(nrfx_dppi_t const * p_instance,
566 uint8_t channel,
567 nrf_dppi_channel_group_t group)
568 {
569 return dppi_channel_remove_from_group(p_instance, channel, group);
570 }
571
nrfx_dppi_group_clear(nrfx_dppi_t const * p_instance,nrf_dppi_channel_group_t group)572 nrfx_err_t nrfx_dppi_group_clear(nrfx_dppi_t const * p_instance, nrf_dppi_channel_group_t group)
573 {
574 return dppi_group_clear(p_instance, group);
575 }
576
nrfx_dppi_group_enable(nrfx_dppi_t const * p_instance,nrf_dppi_channel_group_t group)577 nrfx_err_t nrfx_dppi_group_enable(nrfx_dppi_t const * p_instance, nrf_dppi_channel_group_t group)
578 {
579 return dppi_group_enable(p_instance, group);
580 }
581
nrfx_dppi_group_disable(nrfx_dppi_t const * p_instance,nrf_dppi_channel_group_t group)582 nrfx_err_t nrfx_dppi_group_disable(nrfx_dppi_t const * p_instance,
583 nrf_dppi_channel_group_t group)
584 {
585 return dppi_group_disable(p_instance, group);
586 }
587
588 #else
589
590 nrfx_dppi_t const dppi_instance = NRFX_DPPI_INSTANCE(NRF_DPPIC_INDEX);
591
nrfx_dppi_free(void)592 void nrfx_dppi_free(void)
593 {
594 dppi_free(&dppi_instance);
595 }
596
nrfx_dppi_channel_alloc(uint8_t * p_channel)597 nrfx_err_t nrfx_dppi_channel_alloc(uint8_t * p_channel)
598 {
599 return dppi_channel_alloc(&dppi_instance, p_channel);
600 }
601
nrfx_dppi_channel_free(uint8_t channel)602 nrfx_err_t nrfx_dppi_channel_free(uint8_t channel)
603 {
604 return dppi_channel_free(&dppi_instance, channel);
605 }
606
nrfx_dppi_channel_enable(uint8_t channel)607 nrfx_err_t nrfx_dppi_channel_enable(uint8_t channel)
608 {
609 return dppi_channel_enable(&dppi_instance, channel);
610 }
611
nrfx_dppi_channel_disable(uint8_t channel)612 nrfx_err_t nrfx_dppi_channel_disable(uint8_t channel)
613 {
614 return dppi_channel_disable(&dppi_instance, channel);
615 }
616
nrfx_dppi_group_alloc(nrf_dppi_channel_group_t * p_group)617 nrfx_err_t nrfx_dppi_group_alloc(nrf_dppi_channel_group_t * p_group)
618 {
619 return dppi_group_alloc(&dppi_instance, p_group);
620 }
621
nrfx_dppi_group_free(nrf_dppi_channel_group_t group)622 nrfx_err_t nrfx_dppi_group_free(nrf_dppi_channel_group_t group)
623 {
624 return dppi_group_free(&dppi_instance, group);
625 }
626
nrfx_dppi_channel_include_in_group(uint8_t channel,nrf_dppi_channel_group_t group)627 nrfx_err_t nrfx_dppi_channel_include_in_group(uint8_t channel,
628 nrf_dppi_channel_group_t group)
629 {
630 return dppi_channel_include_in_group(&dppi_instance, channel, group);
631 }
632
nrfx_dppi_channel_remove_from_group(uint8_t channel,nrf_dppi_channel_group_t group)633 nrfx_err_t nrfx_dppi_channel_remove_from_group(uint8_t channel,
634 nrf_dppi_channel_group_t group)
635 {
636 return dppi_channel_remove_from_group(&dppi_instance, channel, group);
637 }
638
nrfx_dppi_group_clear(nrf_dppi_channel_group_t group)639 nrfx_err_t nrfx_dppi_group_clear(nrf_dppi_channel_group_t group)
640 {
641 return dppi_group_clear(&dppi_instance, group);
642 }
643
nrfx_dppi_group_enable(nrf_dppi_channel_group_t group)644 nrfx_err_t nrfx_dppi_group_enable(nrf_dppi_channel_group_t group)
645 {
646 return dppi_group_enable(&dppi_instance, group);
647 }
648
nrfx_dppi_group_disable(nrf_dppi_channel_group_t group)649 nrfx_err_t nrfx_dppi_group_disable(nrf_dppi_channel_group_t group)
650 {
651 return dppi_group_disable(&dppi_instance, group);
652 }
653
654 #endif
655
656 #endif // NRFX_CHECK(NRFX_DPPI_ENABLED)
657