Skip to content

Commit bfac099

Browse files
committed
Revert "mpsl: hwres: dppi: Align to use NRFX_GPPI"
This reverts commit ab754742e5ecce54dd4fadcf2ef07aa0c933adfb.
1 parent f91695e commit bfac099

File tree

1 file changed

+45
-37
lines changed

1 file changed

+45
-37
lines changed

subsys/mpsl/hwres/mpsl_dppi.c

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

77
#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>
2113
#endif
2214

2315
#if defined(DPPI_PRESENT)
2416

2517
bool mpsl_hwres_dppi_channel_alloc(NRF_DPPIC_Type *p_dppic, uint8_t *p_dppi_ch)
2618
{
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);
2827
}
2928

3029
#endif /* DPPI_PRESENT */
3130

3231
#if defined(PPIB_PRESENT)
3332

3433
#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)
3735
{
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+
}
5857
}
58+
59+
return NULL;
5960
}
6061
#endif
6162

6263
bool mpsl_hwres_ppib_channel_alloc(NRF_PPIB_Type *p_ppib, uint8_t *p_ppib_ch)
6364
{
6465
#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);
6674
#else
6775
(void)p_ppib;
6876
(void)p_ppib_ch;

0 commit comments

Comments
 (0)