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

Commit c25df98

Browse files
committed
HAL: Add and use NRF_STATIC_INLINE
To minimize the amount of unnedded differences between the HW models HAL files and the real nRFx HAL files lets define this macro and use it. Signed-off-by: Alberto Escolar Piedras <[email protected]>
1 parent ab77d6b commit c25df98

File tree

4 files changed

+55
-44
lines changed

4 files changed

+55
-44
lines changed

src/nrfx/drivers/nrfx_common.h

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,22 @@
5050
extern "C" {
5151
#endif
5252

53+
#ifndef NRFX_STATIC_INLINE
54+
#ifdef NRFX_DECLARE_ONLY
55+
#define NRFX_STATIC_INLINE
56+
#else
57+
#define NRFX_STATIC_INLINE static inline
58+
#endif
59+
#endif // NRFX_STATIC_INLINE
60+
61+
#ifndef NRF_STATIC_INLINE
62+
#ifdef NRF_DECLARE_ONLY
63+
#define NRF_STATIC_INLINE
64+
#else
65+
#define NRF_STATIC_INLINE static inline
66+
#endif
67+
#endif // NRF_STATIC_INLINE
68+
5369
/**
5470
* @defgroup nrfx_common Common module
5571
* @{
@@ -173,12 +189,12 @@ unsigned int nrfx_peripheral_from_base_address(void const * p_reg);
173189
*/
174190
#define NRFX_IRQ_NUMBER_GET(base_addr) NRFX_PERIPHERAL_ID_GET(base_addr)
175191

176-
static inline bool nrfx_is_word_aligned(void const * p_object)
192+
NRF_STATIC_INLINE bool nrfx_is_word_aligned(void const * p_object)
177193
{
178194
return ((((uint32_t)p_object) & 0x3u) == 0u);
179195
}
180196

181-
static inline IRQn_Type nrfx_get_irq_number(void const * p_reg)
197+
NRF_STATIC_INLINE IRQn_Type nrfx_get_irq_number(void const * p_reg)
182198
{
183199
return (IRQn_Type)NRFX_IRQ_NUMBER_GET(p_reg);
184200
}

src/nrfx/hal/nrf_clock.h

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,7 @@ void nrf_clock_task_trigger(NRF_CLOCK_Type * p_reg, nrf_clock_task_t task);
251251
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
252252
* @param[in] event Event to clear.
253253
*/
254-
static inline void nrf_clock_event_clear(NRF_CLOCK_Type * p_reg, nrf_clock_event_t event);
254+
NRF_STATIC_INLINE void nrf_clock_event_clear(NRF_CLOCK_Type * p_reg, nrf_clock_event_t event);
255255

256256
/**
257257
* @brief Function for retrieving the state of the specified event.
@@ -262,7 +262,7 @@ static inline void nrf_clock_event_clear(NRF_CLOCK_Type * p_reg, nrf_clock_event
262262
* @retval true The event has been generated.
263263
* @retval false The event has not been generated.
264264
*/
265-
static inline bool nrf_clock_event_check(NRF_CLOCK_Type const * p_reg, nrf_clock_event_t event);
265+
NRF_STATIC_INLINE bool nrf_clock_event_check(NRF_CLOCK_Type const * p_reg, nrf_clock_event_t event);
266266

267267
/**
268268
* @brief Function for changing the low-frequency clock source.
@@ -271,7 +271,7 @@ static inline bool nrf_clock_event_check(NRF_CLOCK_Type const * p_reg, nrf_clock
271271
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
272272
* @param[in] source New low-frequency clock source.
273273
*/
274-
static inline void nrf_clock_lf_src_set(NRF_CLOCK_Type * p_reg, nrf_clock_lfclk_t source);
274+
NRF_STATIC_INLINE void nrf_clock_lf_src_set(NRF_CLOCK_Type * p_reg, nrf_clock_lfclk_t source);
275275

276276
/**
277277
* @brief Function for retrieving the selected source for the low-frequency clock.
@@ -285,32 +285,32 @@ static inline void nrf_clock_lf_src_set(NRF_CLOCK_Type * p_reg, nrf_clock_lfclk_
285285
* @retval NRF_CLOCK_LFCLK_Synth The internal 32 kHz synthesizer from
286286
* the HFCLK is the selected source for the low-frequency clock.
287287
*/
288-
static inline nrf_clock_lfclk_t nrf_clock_lf_src_get(NRF_CLOCK_Type const * p_reg);
288+
NRF_STATIC_INLINE nrf_clock_lfclk_t nrf_clock_lf_src_get(NRF_CLOCK_Type const * p_reg);
289289

290290

291291
/* Bodies for inlined functions */
292292

293-
static inline void nrf_clock_event_clear(NRF_CLOCK_Type * p_reg, nrf_clock_event_t event)
293+
NRF_STATIC_INLINE void nrf_clock_event_clear(NRF_CLOCK_Type * p_reg, nrf_clock_event_t event)
294294
{
295295
*((volatile uint32_t *)((uint8_t *)p_reg + (uint32_t)event)) = 0x0UL;
296296
}
297297

298-
static inline bool nrf_clock_event_check(NRF_CLOCK_Type const * p_reg, nrf_clock_event_t event)
298+
NRF_STATIC_INLINE bool nrf_clock_event_check(NRF_CLOCK_Type const * p_reg, nrf_clock_event_t event)
299299
{
300300
return (bool)*((volatile uint32_t *)((uint8_t *)p_reg + event));
301301
}
302302

303-
static inline void nrf_clock_lf_src_set(NRF_CLOCK_Type * p_reg, nrf_clock_lfclk_t source)
303+
NRF_STATIC_INLINE void nrf_clock_lf_src_set(NRF_CLOCK_Type * p_reg, nrf_clock_lfclk_t source)
304304
{
305305
p_reg->LFCLKSRC = (uint32_t)(source);
306306
}
307307

308-
static inline nrf_clock_lfclk_t nrf_clock_lf_src_get(NRF_CLOCK_Type const * p_reg)
308+
NRF_STATIC_INLINE nrf_clock_lfclk_t nrf_clock_lf_src_get(NRF_CLOCK_Type const * p_reg)
309309
{
310310
return (nrf_clock_lfclk_t)(p_reg->LFCLKSRC);
311311
}
312312

313-
static inline bool nrf_clock_is_running(NRF_CLOCK_Type const * p_reg,
313+
NRF_STATIC_INLINE bool nrf_clock_is_running(NRF_CLOCK_Type const * p_reg,
314314
nrf_clock_domain_t domain,
315315
void * p_clk_src)
316316
{

src/nrfx/hal/nrf_rng.h

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ void nrf_rng_int_disable(NRF_RNG_Type * p_reg, uint32_t mask);
108108
*
109109
* @return Mask of enabled interrupts.
110110
*/
111-
static inline uint32_t nrf_rng_int_enable_check(NRF_RNG_Type const * p_reg, uint32_t mask);
111+
NRF_STATIC_INLINE uint32_t nrf_rng_int_enable_check(NRF_RNG_Type const * p_reg, uint32_t mask);
112112

113113
/**
114114
* @brief Function for triggering the specified task.
@@ -124,7 +124,7 @@ void nrf_rng_task_trigger(NRF_RNG_Type * p_reg, nrf_rng_task_t rng_task);
124124
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
125125
* @param[in] rng_event The specified event.
126126
*/
127-
static inline void nrf_rng_event_clear(NRF_RNG_Type * p_reg, nrf_rng_event_t rng_event);
127+
NRF_STATIC_INLINE void nrf_rng_event_clear(NRF_RNG_Type * p_reg, nrf_rng_event_t rng_event);
128128

129129
/**
130130
* @brief Function for retrieving the state of the specified event.
@@ -135,7 +135,7 @@ static inline void nrf_rng_event_clear(NRF_RNG_Type * p_reg, nrf_rng_event_t rng
135135
* @retval true The event is set.
136136
* @retval false The event is not set.
137137
*/
138-
static inline bool nrf_rng_event_check(NRF_RNG_Type const * p_reg, nrf_rng_event_t rng_event);
138+
NRF_STATIC_INLINE bool nrf_rng_event_check(NRF_RNG_Type const * p_reg, nrf_rng_event_t rng_event);
139139

140140
/**
141141
* @brief Function for getting the previously generated random value.
@@ -144,52 +144,52 @@ static inline bool nrf_rng_event_check(NRF_RNG_Type const * p_reg, nrf_rng_event
144144
*
145145
* @return Previously generated random value.
146146
*/
147-
static inline uint8_t nrf_rng_random_value_get(NRF_RNG_Type const * p_reg);
147+
NRF_STATIC_INLINE uint8_t nrf_rng_random_value_get(NRF_RNG_Type const * p_reg);
148148

149149
/**
150150
* @brief Function for enabling digital error correction.
151151
*
152152
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
153153
*/
154-
static inline void nrf_rng_error_correction_enable(NRF_RNG_Type * p_reg);
154+
NRF_STATIC_INLINE void nrf_rng_error_correction_enable(NRF_RNG_Type * p_reg);
155155

156156
/**
157157
* @brief Function for disabling digital error correction.
158158
*
159159
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
160160
*/
161-
static inline void nrf_rng_error_correction_disable(NRF_RNG_Type * p_reg);
161+
NRF_STATIC_INLINE void nrf_rng_error_correction_disable(NRF_RNG_Type * p_reg);
162162

163163

164164

165165
/* Bodies for inlined functions */
166166

167-
static inline uint32_t nrf_rng_int_enable_check(NRF_RNG_Type const * p_reg, uint32_t mask)
167+
NRF_STATIC_INLINE uint32_t nrf_rng_int_enable_check(NRF_RNG_Type const * p_reg, uint32_t mask)
168168
{
169169
return p_reg->INTENSET & mask;
170170
}
171171

172-
static inline void nrf_rng_event_clear(NRF_RNG_Type * p_reg, nrf_rng_event_t rng_event)
172+
NRF_STATIC_INLINE void nrf_rng_event_clear(NRF_RNG_Type * p_reg, nrf_rng_event_t rng_event)
173173
{
174174
*((volatile uint32_t *)((uint8_t *)p_reg + (uint32_t)rng_event)) = 0x0UL;
175175
}
176176

177-
static inline bool nrf_rng_event_check(NRF_RNG_Type const * p_reg, nrf_rng_event_t rng_event)
177+
NRF_STATIC_INLINE bool nrf_rng_event_check(NRF_RNG_Type const * p_reg, nrf_rng_event_t rng_event)
178178
{
179179
return (bool) * ((volatile uint32_t *)((uint8_t *)p_reg + (uint32_t)rng_event));
180180
}
181181

182-
static inline uint8_t nrf_rng_random_value_get(NRF_RNG_Type const * p_reg)
182+
NRF_STATIC_INLINE uint8_t nrf_rng_random_value_get(NRF_RNG_Type const * p_reg)
183183
{
184184
return (uint8_t)(p_reg->VALUE & RNG_VALUE_VALUE_Msk);
185185
}
186186

187-
static inline void nrf_rng_error_correction_enable(NRF_RNG_Type * p_reg)
187+
NRF_STATIC_INLINE void nrf_rng_error_correction_enable(NRF_RNG_Type * p_reg)
188188
{
189189
p_reg->CONFIG |= RNG_CONFIG_DERCEN_Msk;
190190
}
191191

192-
static inline void nrf_rng_error_correction_disable(NRF_RNG_Type * p_reg)
192+
NRF_STATIC_INLINE void nrf_rng_error_correction_disable(NRF_RNG_Type * p_reg)
193193
{
194194
p_reg->CONFIG &= ~RNG_CONFIG_DERCEN_Msk;
195195
}

src/nrfx/hal/nrf_rtc.h

Lines changed: 16 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,6 @@
4545
#include "nrf_soc_if.h"
4646
#include "../drivers/nrfx_common.h"
4747

48-
#ifndef __STATIC_INLINE
49-
#define __STATIC_INLINE static inline
50-
#endif
51-
5248
#ifdef __cplusplus
5349
extern "C" {
5450
#endif
@@ -98,7 +94,6 @@ typedef enum
9894
} nrf_rtc_int_t;
9995

10096

101-
10297
/**
10398
* @brief Function for setting a compare value for a channel.
10499
*
@@ -116,7 +111,7 @@ void nrf_rtc_cc_set(NRF_RTC_Type * p_reg, uint32_t ch, uint32_t cc_val);
116111
*
117112
* @return COMPARE[ch] value.
118113
*/
119-
__STATIC_INLINE uint32_t nrf_rtc_cc_get(NRF_RTC_Type const * p_reg, uint32_t ch);
114+
NRF_STATIC_INLINE uint32_t nrf_rtc_cc_get(NRF_RTC_Type const * p_reg, uint32_t ch);
120115

121116
/**
122117
* @brief Function for enabling interrupts.
@@ -142,7 +137,7 @@ void nrf_rtc_int_disable(NRF_RTC_Type * p_reg, uint32_t mask);
142137
*
143138
* @return Mask of enabled interrupts.
144139
*/
145-
__STATIC_INLINE uint32_t nrf_rtc_int_enable_check(NRF_RTC_Type const * p_reg, uint32_t mask);
140+
NRF_STATIC_INLINE uint32_t nrf_rtc_int_enable_check(NRF_RTC_Type const * p_reg, uint32_t mask);
146141

147142
/**
148143
* @brief Function for retrieving the state of the RTC event.
@@ -153,15 +148,15 @@ __STATIC_INLINE uint32_t nrf_rtc_int_enable_check(NRF_RTC_Type const * p_reg, ui
153148
* @retval true The event has been generated.
154149
* @retval false The event has not been generated.
155150
*/
156-
__STATIC_INLINE bool nrf_rtc_event_check(NRF_RTC_Type const * p_reg, nrf_rtc_event_t event);
151+
NRF_STATIC_INLINE bool nrf_rtc_event_check(NRF_RTC_Type const * p_reg, nrf_rtc_event_t event);
157152

158153
/**
159154
* @brief Function for clearing an event.
160155
*
161156
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
162157
* @param[in] event Event to be cleared.
163158
*/
164-
__STATIC_INLINE void nrf_rtc_event_clear(NRF_RTC_Type * p_reg, nrf_rtc_event_t event);
159+
NRF_STATIC_INLINE void nrf_rtc_event_clear(NRF_RTC_Type * p_reg, nrf_rtc_event_t event);
165160

166161
/**
167162
* @brief Function for returning a counter value.
@@ -178,7 +173,7 @@ uint32_t nrf_rtc_counter_get(NRF_RTC_Type const * p_reg);
178173
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
179174
* @param[in] val Value to set the prescaler to.
180175
*/
181-
__STATIC_INLINE void nrf_rtc_prescaler_set(NRF_RTC_Type * p_reg, uint32_t val);
176+
NRF_STATIC_INLINE void nrf_rtc_prescaler_set(NRF_RTC_Type * p_reg, uint32_t val);
182177

183178
/**
184179
* @brief Function for returning the address of an event.
@@ -188,7 +183,7 @@ __STATIC_INLINE void nrf_rtc_prescaler_set(NRF_RTC_Type * p_reg, uint32_t val);
188183
*
189184
* @return Address of the requested event register.
190185
*/
191-
__STATIC_INLINE uint32_t nrf_rtc_event_address_get(NRF_RTC_Type const * p_reg,
186+
NRF_STATIC_INLINE uint32_t nrf_rtc_event_address_get(NRF_RTC_Type const * p_reg,
192187
nrf_rtc_event_t event);
193188

194189
/**
@@ -199,7 +194,7 @@ __STATIC_INLINE uint32_t nrf_rtc_event_address_get(NRF_RTC_Type const * p_reg,
199194
*
200195
* @return Address of the requested task register.
201196
*/
202-
__STATIC_INLINE uint32_t nrf_rtc_task_address_get(NRF_RTC_Type const * p_reg,
197+
NRF_STATIC_INLINE uint32_t nrf_rtc_task_address_get(NRF_RTC_Type const * p_reg,
203198
nrf_rtc_task_t task);
204199

205200
/**
@@ -230,39 +225,39 @@ void nrf_rtc_event_disable(NRF_RTC_Type * p_reg, uint32_t event);
230225
/* Inlined functions bodies: */
231226
/*****************************/
232227

233-
__STATIC_INLINE uint32_t nrf_rtc_cc_get(NRF_RTC_Type const * p_reg, uint32_t ch)
228+
NRF_STATIC_INLINE uint32_t nrf_rtc_cc_get(NRF_RTC_Type const * p_reg, uint32_t ch)
234229
{
235230
return p_reg->CC[ch];
236231
}
237232

238-
__STATIC_INLINE uint32_t nrf_rtc_int_enable_check(NRF_RTC_Type const * p_reg, uint32_t mask)
233+
NRF_STATIC_INLINE uint32_t nrf_rtc_int_enable_check(NRF_RTC_Type const * p_reg, uint32_t mask)
239234
{
240235
return p_reg->INTENSET & mask;
241236
}
242237

243-
__STATIC_INLINE bool nrf_rtc_event_check(NRF_RTC_Type const * p_reg, nrf_rtc_event_t event)
238+
NRF_STATIC_INLINE bool nrf_rtc_event_check(NRF_RTC_Type const * p_reg, nrf_rtc_event_t event)
244239
{
245240
return (bool)*(volatile uint32_t *)((uint8_t *)p_reg + (uint32_t)event);
246241
}
247242

248-
__STATIC_INLINE void nrf_rtc_event_clear(NRF_RTC_Type * p_reg, nrf_rtc_event_t event)
243+
NRF_STATIC_INLINE void nrf_rtc_event_clear(NRF_RTC_Type * p_reg, nrf_rtc_event_t event)
249244
{
250245
*((volatile uint32_t *)((uint8_t *)p_reg + (uint32_t)event)) = 0;
251246
}
252247

253-
__STATIC_INLINE void nrf_rtc_prescaler_set(NRF_RTC_Type * p_reg, uint32_t val)
248+
NRF_STATIC_INLINE void nrf_rtc_prescaler_set(NRF_RTC_Type * p_reg, uint32_t val)
254249
{
255250
p_reg->PRESCALER = val;
256251
}
257252

258-
__STATIC_INLINE uint32_t nrf_rtc_event_address_get(NRF_RTC_Type const * p_reg,
259-
nrf_rtc_event_t event)
253+
NRF_STATIC_INLINE uint32_t nrf_rtc_event_address_get(NRF_RTC_Type const * p_reg,
254+
nrf_rtc_event_t event)
260255
{
261256
return (uint32_t)p_reg + event;
262257
}
263258

264-
__STATIC_INLINE uint32_t nrf_rtc_task_address_get(NRF_RTC_Type const * p_reg,
265-
nrf_rtc_task_t task)
259+
NRF_STATIC_INLINE uint32_t nrf_rtc_task_address_get(NRF_RTC_Type const * p_reg,
260+
nrf_rtc_task_t task)
266261
{
267262
return (uint32_t)p_reg + task;
268263
}

0 commit comments

Comments
 (0)