nRF5 SDK v17.1.0
Macros
FIFO instance macros

Macros

#define NRF_ATFIFO_BUF_NAME(fifo_id)   CONCAT_2(fifo_id, _data)
 Macro for generating the name for a data buffer. More...
 
#define NRF_ATFIFO_INST_NAME(fifo_id)   CONCAT_2(fifo_id, _inst)
 Macro for generating the name for a FIFO instance. More...
 
#define NRF_ATFIFO_DEF(fifo_id, storage_type, item_cnt)
 Macro for creating an instance. More...
 
#define NRF_ATFIFO_INIT(fifo_id)
 Macro for initializing the FIFO that was previously declared by the macro. More...
 

Detailed Description

A group of macros helpful for FIFO instance creation and initialization. They may be used to create and initialize instances for most use cases.

FIFO may also be created and initialized directly using nrf_atfifo_init function.

Macro Definition Documentation

#define NRF_ATFIFO_BUF_NAME (   fifo_id)    CONCAT_2(fifo_id, _data)

Macro for generating the name for a data buffer.

The name of the data buffer that would be created by NRF_ATFIFO_DEF macro.

Parameters
[in]fifo_idIdentifier of the FIFO object.
Returns
Name of the buffer variable.
Note
This is auxiliary internal macro and in normal usage it should not be called.
#define NRF_ATFIFO_DEF (   fifo_id,
  storage_type,
  item_cnt 
)
Value:
static storage_type NRF_ATFIFO_BUF_NAME(fifo_id)[(item_cnt)+1]; \
NRF_LOG_INSTANCE_REGISTER(NRF_ATFIFO_LOG_NAME, fifo_id, \
NRF_ATFIFO_CONFIG_LOG_LEVEL : NRF_LOG_SEVERITY_NONE); \
static nrf_atfifo_t NRF_ATFIFO_INST_NAME(fifo_id) = { \
.p_buf = NULL, \
NRF_LOG_INSTANCE_PTR_INIT(p_log, NRF_ATFIFO_LOG_NAME, fifo_id) \
}; \
static nrf_atfifo_t * const fifo_id = &NRF_ATFIFO_INST_NAME(fifo_id)

Macro for creating an instance.

Creates the FIFO object variable itself.

Usage example:

NRF_ATFIFO_DEF(my_fifo, uint16_t, 12);
NRF_ATFIFO_INIT(my_fifo);
uint16_t some_val = 45;
nrf_atfifo_item_put(my_fifo, &some_val, sizeof(some_val), NULL);
nrf_atfifo_item_get(my_fifo, &some_val, sizeof(some_val), NULL);
Parameters
[in]fifo_idIdentifier of a FIFO object. This identifier will be a pointer to the instance. It makes it possible to use this directly for the functions that operate on the FIFO. Because it is a static const object, it should be optimized by the compiler.
[in]storage_typeType of data that will be stored in the FIFO.
[in]item_cntCapacity of the created FIFO in maximum number of items that may be stored. The phisical size of the buffer will be 1 element bigger.
#define NRF_ATFIFO_INIT (   fifo_id)
Value:
fifo_id, \
NRF_ATFIFO_BUF_NAME(fifo_id), \
sizeof(NRF_ATFIFO_BUF_NAME(fifo_id)), \
sizeof(NRF_ATFIFO_BUF_NAME(fifo_id)[0]) \
)

Macro for initializing the FIFO that was previously declared by the macro.

Use this macro to simplify FIFO initialization.

Note
This macro can be only used on a FIFO object defined by NRF_ATFIFO_DEF macro.
Parameters
[in]fifo_idIdentifier of the FIFO object.
Returns
Value from the nrf_atfifo_init function.
#define NRF_ATFIFO_INST_NAME (   fifo_id)    CONCAT_2(fifo_id, _inst)

Macro for generating the name for a FIFO instance.

The name of the instance variable that will be created by the NRF_ATFIFO_DEF macro.

Parameters
[in]fifo_idIdentifier of the FIFO object.
Returns
Name of the instance variable.
Note
This is auxiliary internal macro and in normal usage it should not be called.

Documentation feedback | Developer Zone | Subscribe | Updated