Skip to content
This repository was archived by the owner on Oct 23, 2025. It is now read-only.

Commit 0025012

Browse files
nordic-krchaescolar
authored andcommitted
nrfx: Allow use of drivers from original nrfx
Import some more stuff from original nrfx_common.h and change the order of include directories, to make it possible to override only certain nrfx files (in particular, HAL and MDK) with their modified versions from this repository while using other ones (like drivers) in their original form, directly from the hal_nordic module. Signed-off-by: Krzysztof Chruscinski <[email protected]> Signed-off-by: Andrzej Głąbek <[email protected]>
1 parent 469782a commit 0025012

File tree

3 files changed

+56
-5
lines changed

3 files changed

+56
-5
lines changed

CMakeLists.txt

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,17 @@ if(CONFIG_BOARD_NRF52_BSIM)
1818
https://babblesim.github.io/folder_structure_and_env.html")
1919
endif()
2020

21+
# These include directories must be added before those from the hal_nordic
22+
# module, so that the local modified versions of nrfx files are used instead
23+
# of those from the original nrfx.
24+
target_include_directories(zephyr_interface BEFORE INTERFACE
25+
${CMAKE_CURRENT_SOURCE_DIR}/src/
26+
${CMAKE_CURRENT_SOURCE_DIR}/src/nrfx/
27+
${CMAKE_CURRENT_SOURCE_DIR}/src/nrfx/hal/
28+
${CMAKE_CURRENT_SOURCE_DIR}/src/nrfx/mdk/
29+
)
30+
2131
zephyr_include_directories(
22-
src/
23-
src/nrfx/hal/
24-
src/nrfx/mdk
25-
src/nrfx/
2632
src/HW_models/
2733
)
2834

src/nrfx/drivers/nrfx_common.h

Lines changed: 44 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,21 @@
5050
extern "C" {
5151
#endif
5252

53+
/*
54+
* Suppress use of anomaly workarounds in nrfx drivers that would directly
55+
* access hardware registers.
56+
*/
57+
#define USE_WORKAROUND_FOR_ANOMALY_132 0
58+
59+
/*
60+
* When nrfx drivers are compiled for a real SoC, this macro is inherited from
61+
* CMSIS. The below definition is needed when those drivers are compiled for
62+
* the simulated target.
63+
*/
64+
#ifndef __STATIC_INLINE
65+
#define __STATIC_INLINE static inline
66+
#endif
67+
5368
#ifndef NRFX_STATIC_INLINE
5469
#ifdef NRFX_DECLARE_ONLY
5570
#define NRFX_STATIC_INLINE
@@ -170,6 +185,29 @@ extern "C" {
170185
*/
171186
#define NRFX_OFFSETOF(type, member) ((size_t)&(((type *)0)->member))
172187

188+
/**
189+
* @brief Macro for waiting until condition is met.
190+
*
191+
* @param[in] condition Condition to meet.
192+
* @param[in] attempts Maximum number of condition checks. Must not be 0.
193+
* @param[in] delay_us Delay between consecutive checks, in microseconds.
194+
* @param[out] result Boolean variable to store the result of the wait process.
195+
* Set to true if the condition is met or false otherwise.
196+
*/
197+
#define NRFX_WAIT_FOR(condition, attempts, delay_us, result) \
198+
do { \
199+
result = false; \
200+
uint32_t remaining_attempts = (attempts); \
201+
do { \
202+
if (condition) \
203+
{ \
204+
result = true; \
205+
break; \
206+
} \
207+
NRFX_DELAY_US(delay_us); \
208+
} while (--remaining_attempts); \
209+
} while(0)
210+
173211
unsigned int nrfx_peripheral_from_base_address(void const * p_reg);
174212

175213
/**
@@ -199,6 +237,11 @@ unsigned int nrfx_peripheral_from_base_address(void const * p_reg);
199237
*/
200238
#define NRFX_IRQ_NUMBER_GET(base_addr) NRFX_PERIPHERAL_ID_GET(base_addr)
201239

240+
/**
241+
* @brief IRQ handler type.
242+
*/
243+
typedef void (*nrfx_irq_handler_t)(void);
244+
202245
NRF_STATIC_INLINE bool nrfx_is_word_aligned(void const * p_object)
203246
{
204247
return ((((uint32_t)p_object) & 0x3u) == 0u);
@@ -215,4 +258,4 @@ NRF_STATIC_INLINE IRQn_Type nrfx_get_irq_number(void const * p_reg)
215258
}
216259
#endif
217260

218-
#endif // NRFX_COMMON_H__
261+
#endif /* BS_NRFX_COMMON_H__ */

src/nrfx/hal/nrf_soc_if.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,9 @@ extern void __SEV(void);
9595
extern void NVIC_SetPendingIRQ(IRQn_Type IRQn);
9696
extern void NVIC_ClearPendingIRQ(IRQn_Type IRQn);
9797

98+
#ifndef NRFX_ASSERT
9899
#define NRFX_ASSERT(...)
100+
#endif
99101

100102
#ifdef __cplusplus
101103
}

0 commit comments

Comments
 (0)