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

Commit 0d89959

Browse files
auroraslbwopu-ot
authored andcommitted
Add NRFX_OFFSETOF to nrfx_common.h
Signed-off-by: Sletnes Bjørlo, Aurora <[email protected]>
1 parent c9e052c commit 0d89959

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

src/nrfx/drivers/nrfx_common.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,16 @@ extern "C" {
159159
*/
160160
#define NRFX_ARRAY_SIZE(array) (sizeof(array) / sizeof((array)[0]))
161161

162+
/**
163+
* @brief Macro for getting the offset (in bytes) from the beginning of a structure
164+
* of the specified type to its specified member.
165+
*
166+
* @param[in] type Structure type.
167+
* @param[in] member Structure member whose offset is searched for.
168+
*
169+
* @return Member offset in bytes.
170+
*/
171+
#define NRFX_OFFSETOF(type, member) ((size_t)&(((type *)0)->member))
162172

163173
unsigned int nrfx_peripheral_from_base_address(void const * p_reg);
164174

0 commit comments

Comments
 (0)