nRF5 SDK v12.1.0
Macros
Section variables

Section variables. More...

Macros

#define NRF_PRAGMA(x)   _Pragma(#x)
 
#define NRF_SECTION_VARS_START_SYMBOL(section_name)   section_name ## $$Base
 Macro to obtain the symbol marking the beginning of a given section. More...
 
#define NRF_SECTION_VARS_END_SYMBOL(section_name)   section_name ## $$Limit
 Macro to obtain the symbol marking the end of a given section. More...
 
#define NRF_SECTION_VARS_LENGTH(section_name)   ((uint32_t)&NRF_SECTION_VARS_END_SYMBOL(section_name) - (uint32_t)&NRF_SECTION_VARS_START_SYMBOL(section_name))
 Macro for retrieving the length of a given section, in bytes. More...
 
#define NRF_SECTION_VARS_START_ADDR(section_name)   (uint32_t)&NRF_SECTION_VARS_START_SYMBOL(section_name)
 Macro to obtain the address of the beginning of a section. More...
 
#define NRF_SECTION_VARS_END_ADDR(section_name)   (uint32_t)&NRF_SECTION_VARS_END_SYMBOL(section_name)
 Macro to obtain the address of end of a section. More...
 
#define NRF_SECTION_VARS_CREATE_SECTION(section_name, data_type)
 Macro to create a section to register variables in. More...
 
#define NRF_SECTION_VARS_REGISTER_VAR(section_name, section_var)   static section_var __attribute__ ((section(#section_name))) __attribute__((used))
 Macro to declare a variable and register it in a section. More...
 
#define NRF_SECTION_VARS_GET(i, data_type, section_name)   (data_type*)(NRF_SECTION_VARS_START_ADDR(section_name) + i * sizeof(data_type))
 Macro to retrieve a variable from a section. More...
 
#define NRF_SECTION_VARS_COUNT(data_type, section_name)   NRF_SECTION_VARS_LENGTH(section_name) / sizeof(data_type)
 Macro to get number of variables registered in a section. More...
 

Detailed Description

Section variables.

Macro Definition Documentation

#define NRF_SECTION_VARS_COUNT (   data_type,
  section_name 
)    NRF_SECTION_VARS_LENGTH(section_name) / sizeof(data_type)

Macro to get number of variables registered in a section.

Parameters
[in]data_typeData type of the variables in the section.
[in]section_nameName of the section.
#define NRF_SECTION_VARS_CREATE_SECTION (   section_name,
  data_type 
)
Value:
extern data_type * NRF_SECTION_VARS_START_SYMBOL(section_name); \
extern void * NRF_SECTION_VARS_END_SYMBOL(section_name)

Macro to create a section to register variables in.

Parameters
[in]data_typeThe data type of the variables to be registered in the section.
[in]section_nameName of the section.
Warning
The data type must be word aligned to prevent padding.
#define NRF_SECTION_VARS_END_ADDR (   section_name)    (uint32_t)&NRF_SECTION_VARS_END_SYMBOL(section_name)

Macro to obtain the address of end of a section.

Parameters
[in]section_nameName of the section.
#define NRF_SECTION_VARS_END_SYMBOL (   section_name)    section_name ## $$Limit

Macro to obtain the symbol marking the end of a given section.

The symbol that this macro resolves to is used to obtain a section stop address.

Parameters
[in]section_nameName of the section.
#define NRF_SECTION_VARS_GET (   i,
  data_type,
  section_name 
)    (data_type*)(NRF_SECTION_VARS_START_ADDR(section_name) + i * sizeof(data_type))

Macro to retrieve a variable from a section.

Warning
The stored symbol can only be resolved using this macro if the type of the data is word aligned. The operation of acquiring the stored symbol relies on sizeof of the stored type, no padding can exist in the named section in between individual stored items or this macro will fail.
Parameters
[in]iIndex of the variable in section.
[in]data_typeData type of the variable.
[in]section_nameName of the section.
#define NRF_SECTION_VARS_LENGTH (   section_name)    ((uint32_t)&NRF_SECTION_VARS_END_SYMBOL(section_name) - (uint32_t)&NRF_SECTION_VARS_START_SYMBOL(section_name))

Macro for retrieving the length of a given section, in bytes.

Parameters
[in]section_nameName of the section.
#define NRF_SECTION_VARS_REGISTER_VAR (   section_name,
  section_var 
)    static section_var __attribute__ ((section(#section_name))) __attribute__((used))

Macro to declare a variable and register it in a section.

Declares a variable and registers it in a named section. This macro ensures that the variable is not stripped away when using optimizations.

Note
The order with which variables are placed in a section is dependant on the order with which the linker encouters the variables during linking.
Parameters
[in]section_nameName of the section.
[in]section_varThe variable to register in the given section.
#define NRF_SECTION_VARS_START_ADDR (   section_name)    (uint32_t)&NRF_SECTION_VARS_START_SYMBOL(section_name)

Macro to obtain the address of the beginning of a section.

param[in] section_name Name of the section.

#define NRF_SECTION_VARS_START_SYMBOL (   section_name)    section_name ## $$Base

Macro to obtain the symbol marking the beginning of a given section.

The symbol that this macro resolves to is used to obtain a section start address.

Parameters
[in]section_nameName of the section.

Documentation feedback | Developer Zone | Subscribe | Updated