Skip to content

Commit 95247f9

Browse files
committed
mpsl: hwres: dppi: Align to use NRFX_GPPI
nrfx_dppi is deprecated and gppi shall be used. Signed-off-by: Krzysztof Chruściński <[email protected]>
1 parent 28d1108 commit 95247f9

File tree

1 file changed

+37
-45
lines changed

1 file changed

+37
-45
lines changed

subsys/mpsl/hwres/mpsl_dppi.c

Lines changed: 37 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -5,72 +5,64 @@
55
*/
66

77
#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>
169

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)
1812
{
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);
2114

22-
if (err != NRFX_SUCCESS) {
15+
if (ch < 0) {
2316
return false;
2417
}
18+
*p_ch = (uint8_t)ch;
19+
return true;
20+
}
21+
#endif
2522

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);
2728
}
2829

2930
#endif /* DPPI_PRESENT */
3031

3132
#if defined(PPIB_PRESENT)
3233

3334
#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)
3537
{
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;
5758
}
58-
59-
return NULL;
6059
}
6160
#endif
6261

6362
bool mpsl_hwres_ppib_channel_alloc(NRF_PPIB_Type *p_ppib, uint8_t *p_ppib_ch)
6463
{
6564
#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);
7466
#else
7567
(void)p_ppib;
7668
(void)p_ppib_ch;

0 commit comments

Comments
 (0)