Skip to content

Commit c565d39

Browse files
ankunsrlubos
authored andcommitted
mpsl: add mpsl_hwres.h implementation
Added the implementation of the MPSL hardware resources API defined by `mpsl_hwres.h` file. The implementation covers nRF5340 and nRF54L Series. Signed-off-by: Andrzej Kuros <[email protected]>
1 parent e0ace55 commit c565d39

File tree

3 files changed

+84
-0
lines changed

3 files changed

+84
-0
lines changed

doc/nrf/releases_and_maturity/releases/release-notes-changelog.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -612,6 +612,8 @@ Multiprotocol Service Layer libraries
612612
Invoking kernel APIs or triggering the kernel scheduler from Zero Latency Interrupts is considered undefined behavior.
613613
Users of MPSL timeslots should not assume that thread rescheduling will occur automatically at the end of a timeslot.
614614

615+
* Added an implementation of the API required by the MPSL (defined by :file:`mpsl_hwres.h`) for the nRF53 and nRF54L Series devices.
616+
615617
Libraries for networking
616618
------------------------
617619

subsys/mpsl/init/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,4 @@
77
zephyr_library()
88

99
zephyr_library_sources(mpsl_init.c)
10+
zephyr_library_sources(mpsl_hwres.c)

subsys/mpsl/init/mpsl_hwres.c

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
/*
2+
* Copyright (c) 2025 Nordic Semiconductor ASA
3+
*
4+
* SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
5+
*/
6+
7+
#include <mpsl_hwres.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)
16+
17+
bool mpsl_fem_hwres_dppi_channel_alloc(NRF_DPPIC_Type *p_dppic, uint8_t *p_dppi_ch)
18+
{
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);
27+
}
28+
29+
#endif /* DPPI_PRESENT */
30+
31+
#if defined(PPIB_PRESENT)
32+
33+
#if defined(LUMOS_XXAA)
34+
static const nrfx_ppib_interconnect_t *nrfx_ppib_interconnect_find_by_ptr(NRF_PPIB_Type *p_ppib)
35+
{
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+
}
57+
}
58+
59+
return NULL;
60+
}
61+
#endif
62+
63+
bool mpsl_hwres_ppib_channel_alloc(NRF_PPIB_Type *p_ppib, uint8_t *p_ppib_ch)
64+
{
65+
#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);
74+
#else
75+
(void)p_ppib;
76+
(void)p_ppib_ch;
77+
return false;
78+
#endif
79+
}
80+
81+
#endif /* PPIB_PRESENT */

0 commit comments

Comments
 (0)