nRF5 SDK v17.1.0
Macros | Typedefs | Enumerations | Functions
Common module

Common module. More...

Macros

#define NRFX_CHECK(module_enabled)   (module_enabled)
 Macro for checking if the specified identifier is defined and it has a non-zero value. More...
 
#define NRFX_CONCAT_2(p1, p2)   NRFX_CONCAT_2_(p1, p2)
 Macro for concatenating two tokens in macro expansion. More...
 
#define NRFX_CONCAT_2_(p1, p2)   p1 ## p2
 Internal macro used by NRFX_CONCAT_2 to perform the expansion in two steps.
 
#define NRFX_CONCAT_3(p1, p2, p3)   NRFX_CONCAT_3_(p1, p2, p3)
 Macro for concatenating three tokens in macro expansion. More...
 
#define NRFX_CONCAT_3_(p1, p2, p3)   p1 ## p2 ## p3
 Internal macro used by NRFX_CONCAT_3 to perform the expansion in two steps.
 
#define NRFX_ROUNDED_DIV(a, b)   (((a) + ((b) / 2)) / (b))
 Macro for performing rounded integer division (as opposed to truncating the result). More...
 
#define NRFX_CEIL_DIV(a, b)   ((((a) - 1) / (b)) + 1)
 Macro for performing integer division, making sure the result is rounded up. More...
 
#define NRFX_ARRAY_SIZE(array)   (sizeof(array) / sizeof((array)[0]))
 Macro for getting the number of elements in an array. More...
 
#define NRFX_OFFSETOF(type, member)   ((size_t)&(((type *)0)->member))
 Macro for getting the offset (in bytes) from the beginning of a structure of the specified type to its specified member. More...
 
#define NRFX_EASYDMA_LENGTH_VALIDATE(peripheral, length1, length2)
 Macro for checking if given lengths of EasyDMA transfers do not exceed the limit of the specified peripheral. More...
 
#define NRFX_WAIT_FOR(condition, attempts, delay_us, result)
 Macro for waiting until condition is met. More...
 
#define NRFX_PERIPHERAL_ID_GET(base_addr)   (uint8_t)((uint32_t)(base_addr) >> 12)
 Macro for getting the ID number of the specified peripheral. More...
 
#define NRFX_IRQ_NUMBER_GET(base_addr)   NRFX_PERIPHERAL_ID_GET(base_addr)
 Macro for getting the interrupt number assigned to a specific peripheral. More...
 

Typedefs

typedef void(* nrfx_irq_handler_t )(void)
 IRQ handler type.
 

Enumerations

enum  nrfx_drv_state_t {
  NRFX_DRV_STATE_UNINITIALIZED,
  NRFX_DRV_STATE_INITIALIZED,
  NRFX_DRV_STATE_POWERED_ON
}
 Driver state. More...
 

Functions

__STATIC_INLINE bool nrfx_is_in_ram (void const *p_object)
 Function for checking if an object is placed in the Data RAM region. More...
 
__STATIC_INLINE bool nrfx_is_word_aligned (void const *p_object)
 Function for checking if an object is aligned to a 32-bit word. More...
 
__STATIC_INLINE IRQn_Type nrfx_get_irq_number (void const *p_reg)
 Function for getting the interrupt number for the specified peripheral. More...
 
__STATIC_INLINE uint32_t nrfx_bitpos_to_event (uint32_t bit)
 Function for converting an INTEN register bit position to the corresponding event identifier. More...
 
__STATIC_INLINE uint32_t nrfx_event_to_bitpos (uint32_t event)
 Function for converting an event identifier to the corresponding INTEN register bit position. More...
 

Detailed Description

Common module.

Macro Definition Documentation

#define NRFX_ARRAY_SIZE (   array)    (sizeof(array) / sizeof((array)[0]))

Macro for getting the number of elements in an array.

Parameters
[in]arrayName of the array.
Returns
Array element count.
#define NRFX_CEIL_DIV (   a,
 
)    ((((a) - 1) / (b)) + 1)

Macro for performing integer division, making sure the result is rounded up.

A typical use case for this macro is to compute the number of objects with size b required to hold a number of bytes.

Parameters
[in]aNumerator.
[in]bDenominator.
Returns
Integer result of dividing a by b, rounded up.
#define NRFX_CHECK (   module_enabled)    (module_enabled)

Macro for checking if the specified identifier is defined and it has a non-zero value.

Normally, preprocessors treat all undefined identifiers as having the value zero. However, some tools, like static code analyzers, can issue a warning when such identifier is evaluated. This macro gives the possibility to suppress such warnings only in places where this macro is used for evaluation, not in the whole analyzed code.

#define NRFX_CONCAT_2 (   p1,
  p2 
)    NRFX_CONCAT_2_(p1, p2)

Macro for concatenating two tokens in macro expansion.

Note
This macro is expanded in two steps so that tokens given as macros themselves are fully expanded before they are merged.
Parameters
[in]p1First token.
[in]p2Second token.
Returns
The two tokens merged into one, unless they cannot together form a valid token (in such case, the preprocessor issues a warning and does not perform the concatenation).
See Also
NRFX_CONCAT_3
#define NRFX_CONCAT_3 (   p1,
  p2,
  p3 
)    NRFX_CONCAT_3_(p1, p2, p3)

Macro for concatenating three tokens in macro expansion.

Note
This macro is expanded in two steps so that tokens given as macros themselves are fully expanded before they are merged.
Parameters
[in]p1First token.
[in]p2Second token.
[in]p3Third token.
Returns
The three tokens merged into one, unless they cannot together form a valid token (in such case, the preprocessor issues a warning and does not perform the concatenation).
See Also
NRFX_CONCAT_2
#define NRFX_EASYDMA_LENGTH_VALIDATE (   peripheral,
  length1,
  length2 
)
Value:
(((length1) < (1U << NRFX_CONCAT_2(peripheral, _EASYDMA_MAXCNT_SIZE))) && \
((length2) < (1U << NRFX_CONCAT_2(peripheral, _EASYDMA_MAXCNT_SIZE))))

Macro for checking if given lengths of EasyDMA transfers do not exceed the limit of the specified peripheral.

Parameters
[in]peripheralPeripheral to check the lengths against.
[in]length1First length to be checked.
[in]length2Second length to be checked (pass 0 if not needed).
Return values
trueThe length of buffers does not exceed the limit of the specified peripheral.
falseThe length of buffers exceeds the limit of the specified peripheral.
#define NRFX_IRQ_NUMBER_GET (   base_addr)    NRFX_PERIPHERAL_ID_GET(base_addr)

Macro for getting the interrupt number assigned to a specific peripheral.

For peripherals in Nordic SoCs, the IRQ number assigned to a peripheral is equal to its ID number. See the chapter "Peripheral interface" (sections "Peripheral ID" and "Interrupts") in the Product Specification.

Parameters
[in]base_addrPeripheral base address or pointer.
Returns
Interrupt number associated with the specified peripheral.
#define NRFX_OFFSETOF (   type,
  member 
)    ((size_t)&(((type *)0)->member))

Macro for getting the offset (in bytes) from the beginning of a structure of the specified type to its specified member.

Parameters
[in]typeStructure type.
[in]memberStructure member whose offset is searched for.
Returns
Member offset in bytes.
#define NRFX_PERIPHERAL_ID_GET (   base_addr)    (uint8_t)((uint32_t)(base_addr) >> 12)

Macro for getting the ID number of the specified peripheral.

For peripherals in Nordic SoCs, there is a direct relationship between their ID numbers and their base addresses. See the chapter "Peripheral interface" (section "Peripheral ID") in the Product Specification.

Parameters
[in]base_addrPeripheral base address or pointer.
Returns
ID number associated with the specified peripheral.
#define NRFX_ROUNDED_DIV (   a,
 
)    (((a) + ((b) / 2)) / (b))

Macro for performing rounded integer division (as opposed to truncating the result).

Parameters
[in]aNumerator.
[in]bDenominator.
Returns
Rounded (integer) result of dividing a by b.
#define NRFX_WAIT_FOR (   condition,
  attempts,
  delay_us,
  result 
)
Value:
do { \
result = false; \
uint32_t remaining_attempts = (attempts); \
do { \
if (condition) \
{ \
result = true; \
break; \
} \
NRFX_DELAY_US(delay_us); \
} while (--remaining_attempts); \
} while(0)

Macro for waiting until condition is met.

Parameters
[in]conditionCondition to meet.
[in]attemptsMaximum number of condition checks. Must not be 0.
[in]delay_usDelay between consecutive checks, in microseconds.
[out]resultBoolean variable to store the result of the wait process. Set to true if the condition is met or false otherwise.

Enumeration Type Documentation

Driver state.

Enumerator
NRFX_DRV_STATE_UNINITIALIZED 

Uninitialized.

NRFX_DRV_STATE_INITIALIZED 

Initialized but powered off.

NRFX_DRV_STATE_POWERED_ON 

Initialized and powered on.

Function Documentation

__STATIC_INLINE uint32_t nrfx_bitpos_to_event ( uint32_t  bit)

Function for converting an INTEN register bit position to the corresponding event identifier.

The event identifier is the offset between the event register address and the peripheral base address, and is equal (thus, can be directly cast) to the corresponding value of the enumerated type from HAL (nrf_*_event_t).

Parameters
[in]bitINTEN register bit position.
Returns
Event identifier.
See Also
nrfx_event_to_bitpos
__STATIC_INLINE uint32_t nrfx_event_to_bitpos ( uint32_t  event)

Function for converting an event identifier to the corresponding INTEN register bit position.

The event identifier is the offset between the event register address and the peripheral base address, and is equal (thus, can be directly cast) to the corresponding value of the enumerated type from HAL (nrf_*_event_t).

Parameters
[in]eventEvent identifier.
Returns
INTEN register bit position.
See Also
nrfx_bitpos_to_event
__STATIC_INLINE IRQn_Type nrfx_get_irq_number ( void const *  p_reg)

Function for getting the interrupt number for the specified peripheral.

Parameters
[in]p_regPeripheral base pointer.
Returns
Interrupt number associated with the pointed peripheral.
__STATIC_INLINE bool nrfx_is_in_ram ( void const *  p_object)

Function for checking if an object is placed in the Data RAM region.

Several peripherals (the ones using EasyDMA) require the transfer buffers to be placed in the Data RAM region. This function can be used to check if this condition is met.

Parameters
[in]p_objectPointer to an object whose location is to be checked.
Return values
trueThe pointed object is located in the Data RAM region.
falseThe pointed object is not located in the Data RAM region.
__STATIC_INLINE bool nrfx_is_word_aligned ( void const *  p_object)

Function for checking if an object is aligned to a 32-bit word.

Several peripherals (the ones using EasyDMA) require the transfer buffers to be aligned to a 32-bit word. This function can be used to check if this condition is met.

Parameters
[in]p_objectPointer to an object whose location is to be checked.
Return values
trueThe pointed object is aligned to a 32-bit word.
falseThe pointed object is not aligned to a 32-bit word.

Documentation feedback | Developer Zone | Subscribe | Updated