|
5 | 5 | */ |
6 | 6 |
|
7 | 7 | #include <mpsl_dppi.h> |
8 | | -#if defined(DPPI_PRESENT) |
9 | | -#include <nrfx_dppi.h> |
10 | | -#endif |
11 | | -#if defined(LUMOS_XXAA) |
12 | | -#include <nrfx_ppib.h> |
13 | | -#endif |
14 | | - |
15 | | -#if defined(DPPI_PRESENT) |
| 8 | +#include <helpers/nrfx_gppi.h> |
16 | 9 |
|
17 | | -bool mpsl_hwres_dppi_channel_alloc(NRF_DPPIC_Type *p_dppic, uint8_t *p_dppi_ch) |
| 10 | +#if defined(DPPI_PRESENT) || defined(LUMOS_XXAA) |
| 11 | +static bool mpsl_hwres_channel_alloc(uint32_t node_id, uint8_t *p_ch) |
18 | 12 | { |
19 | | - nrfx_dppi_t dppi = {0}; |
20 | | - nrfx_err_t err = nrfx_dppi_periph_get((uintptr_t)p_dppic, &dppi); |
| 13 | + int ch = nrfx_gppi_channel_alloc(node_id, NULL); |
21 | 14 |
|
22 | | - if (err != NRFX_SUCCESS) { |
| 15 | + if (ch < 0) { |
23 | 16 | return false; |
24 | 17 | } |
| 18 | + *p_ch = (uint8_t)ch; |
| 19 | + return true; |
| 20 | +} |
| 21 | +#endif |
25 | 22 |
|
26 | | - return (nrfx_dppi_channel_alloc(&dppi, p_dppi_ch) == NRFX_SUCCESS); |
| 23 | +#if defined(DPPI_PRESENT) |
| 24 | + |
| 25 | +bool mpsl_hwres_dppi_channel_alloc(NRF_DPPIC_Type *p_dppic, uint8_t *p_dppi_ch) |
| 26 | +{ |
| 27 | + return mpsl_hwres_channel_alloc(nrfx_gppi_domain_id_get((uint32_t)p_dppic), p_dppi_ch); |
27 | 28 | } |
28 | 29 |
|
29 | 30 | #endif /* DPPI_PRESENT */ |
30 | 31 |
|
31 | 32 | #if defined(PPIB_PRESENT) |
32 | 33 |
|
33 | 34 | #if defined(LUMOS_XXAA) |
34 | | -static const nrfx_ppib_interconnect_t *nrfx_ppib_interconnect_find_by_ptr(NRF_PPIB_Type *p_ppib) |
| 35 | +#include <helpers/nrfx_gppi_lumos.h> |
| 36 | +static uint32_t ppib_get_domain(NRF_PPIB_Type *p_ppib) |
35 | 37 | { |
36 | | - static const nrfx_ppib_interconnect_t interconnects[] = { |
37 | | -#if NRFX_CHECK(NRFX_PPIB00_ENABLED) && NRFX_CHECK(NRFX_PPIB10_ENABLED) |
38 | | - NRFX_PPIB_INTERCONNECT_INSTANCE(00, 10), |
39 | | -#endif |
40 | | -#if NRFX_CHECK(NRFX_PPIB11_ENABLED) && NRFX_CHECK(NRFX_PPIB21_ENABLED) |
41 | | - NRFX_PPIB_INTERCONNECT_INSTANCE(11, 21), |
42 | | -#endif |
43 | | -#if NRFX_CHECK(NRFX_PPIB22_ENABLED) && NRFX_CHECK(NRFX_PPIB30_ENABLED) |
44 | | - NRFX_PPIB_INTERCONNECT_INSTANCE(22, 30), |
45 | | -#endif |
46 | | -#if NRFX_CHECK(NRFX_PPIB01_ENABLED) && NRFX_CHECK(NRFX_PPIB20_ENABLED) |
47 | | - NRFX_PPIB_INTERCONNECT_INSTANCE(01, 20), |
48 | | -#endif |
49 | | - }; |
50 | | - |
51 | | - for (size_t i = 0U; i < NRFX_ARRAY_SIZE(interconnects); ++i) { |
52 | | - const nrfx_ppib_interconnect_t *ith = &interconnects[i]; |
53 | | - |
54 | | - if ((ith->left.p_reg == p_ppib) || (ith->right.p_reg == p_ppib)) { |
55 | | - return ith; |
56 | | - } |
| 38 | + switch ((uint32_t)p_ppib) { |
| 39 | + case (uint32_t)NRF_PPIB00: |
| 40 | + /* fall through */ |
| 41 | + case (uint32_t)NRF_PPIB10: |
| 42 | + return NRFX_GPPI_NODE_PPIB00_10; |
| 43 | + case (uint32_t)NRF_PPIB11: |
| 44 | + /* fall through */ |
| 45 | + case (uint32_t)NRF_PPIB21: |
| 46 | + return NRFX_GPPI_NODE_PPIB11_21; |
| 47 | + case (uint32_t)NRF_PPIB01: |
| 48 | + /* fall through */ |
| 49 | + case (uint32_t)NRF_PPIB20: |
| 50 | + return NRFX_GPPI_NODE_PPIB01_20; |
| 51 | + case (uint32_t)NRF_PPIB22: |
| 52 | + /* fall through */ |
| 53 | + case (uint32_t)NRF_PPIB30: |
| 54 | + return NRFX_GPPI_NODE_PPIB22_30; |
| 55 | + default: |
| 56 | + __ASSERT_NO_MSG("Unexpected PPIB"); |
| 57 | + return 0; |
57 | 58 | } |
58 | | - |
59 | | - return NULL; |
60 | 59 | } |
61 | 60 | #endif |
62 | 61 |
|
63 | 62 | bool mpsl_hwres_ppib_channel_alloc(NRF_PPIB_Type *p_ppib, uint8_t *p_ppib_ch) |
64 | 63 | { |
65 | 64 | #if defined(LUMOS_XXAA) |
66 | | - const nrfx_ppib_interconnect_t *ppib_interconnect = |
67 | | - nrfx_ppib_interconnect_find_by_ptr(p_ppib); |
68 | | - |
69 | | - if (ppib_interconnect == NULL) { |
70 | | - return false; |
71 | | - } |
72 | | - |
73 | | - return (nrfx_ppib_channel_alloc(ppib_interconnect, p_ppib_ch) == NRFX_SUCCESS); |
| 65 | + return mpsl_hwres_channel_alloc(ppib_get_domain(p_ppib), p_ppib_ch); |
74 | 66 | #else |
75 | 67 | (void)p_ppib; |
76 | 68 | (void)p_ppib_ch; |
|
0 commit comments