|
5 | 5 | */ |
6 | 6 |
|
7 | 7 | #include <mpsl_dppi.h> |
8 | | -#include <helpers/nrfx_gppi.h> |
9 | | - |
10 | | -#if defined(DPPI_PRESENT) || defined(LUMOS_XXAA) |
11 | | -static bool mpsl_hwres_channel_alloc(uint32_t node_id, uint8_t *p_ch) |
12 | | -{ |
13 | | - int ch = nrfx_gppi_channel_alloc(node_id, NULL); |
14 | | - |
15 | | - if (ch < 0) { |
16 | | - return false; |
17 | | - } |
18 | | - *p_ch = (uint8_t)ch; |
19 | | - return true; |
20 | | -} |
| 8 | +#if defined(DPPI_PRESENT) |
| 9 | +#include <nrfx_dppi.h> |
| 10 | +#endif |
| 11 | +#if defined(LUMOS_XXAA) |
| 12 | +#include <nrfx_ppib.h> |
21 | 13 | #endif |
22 | 14 |
|
23 | 15 | #if defined(DPPI_PRESENT) |
24 | 16 |
|
25 | 17 | bool mpsl_hwres_dppi_channel_alloc(NRF_DPPIC_Type *p_dppic, uint8_t *p_dppi_ch) |
26 | 18 | { |
27 | | - return mpsl_hwres_channel_alloc(nrfx_gppi_domain_id_get((uint32_t)p_dppic), p_dppi_ch); |
| 19 | + nrfx_dppi_t dppi = {0}; |
| 20 | + nrfx_err_t err = nrfx_dppi_periph_get((uintptr_t)p_dppic, &dppi); |
| 21 | + |
| 22 | + if (err != NRFX_SUCCESS) { |
| 23 | + return false; |
| 24 | + } |
| 25 | + |
| 26 | + return (nrfx_dppi_channel_alloc(&dppi, p_dppi_ch) == NRFX_SUCCESS); |
28 | 27 | } |
29 | 28 |
|
30 | 29 | #endif /* DPPI_PRESENT */ |
31 | 30 |
|
32 | 31 | #if defined(PPIB_PRESENT) |
33 | 32 |
|
34 | 33 | #if defined(LUMOS_XXAA) |
35 | | -#include <helpers/nrfx_gppi_lumos.h> |
36 | | -static uint32_t ppib_get_domain(NRF_PPIB_Type *p_ppib) |
| 34 | +static const nrfx_ppib_interconnect_t *nrfx_ppib_interconnect_find_by_ptr(NRF_PPIB_Type *p_ppib) |
37 | 35 | { |
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; |
| 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 | + } |
58 | 57 | } |
| 58 | + |
| 59 | + return NULL; |
59 | 60 | } |
60 | 61 | #endif |
61 | 62 |
|
62 | 63 | bool mpsl_hwres_ppib_channel_alloc(NRF_PPIB_Type *p_ppib, uint8_t *p_ppib_ch) |
63 | 64 | { |
64 | 65 | #if defined(LUMOS_XXAA) |
65 | | - return mpsl_hwres_channel_alloc(ppib_get_domain(p_ppib), p_ppib_ch); |
| 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); |
66 | 74 | #else |
67 | 75 | (void)p_ppib; |
68 | 76 | (void)p_ppib_ch; |
|
0 commit comments