nRF5 SDK v11.0.0
Macros
Section variables

Section variables. More...

Macros

#define NRF_PRAGMA(x)   _Pragma(#x)
 
#define NRF_SECTION_VARS_REGISTER_SECTION(section_name)
 Macro to register a named section. More...
 
#define NRF_SECTION_VARS_START_SYMBOL(section_name)   section_name ## $$Base
 Macro to obtain the linker symbol for the beginning of a given section. More...
 
#define NRF_SECTION_VARS_END_SYMBOL(section_name)   section_name ## $$Limit
 Macro to obtain the linker symbol for 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 start address of a named section. More...
 
#define NRF_SECTION_VARS_END_ADDR(section_name)   (uint32_t)&NRF_SECTION_VARS_END_SYMBOL(section_name)
 
#define NRF_SECTION_VARS_REGISTER_SYMBOLS(type_name, section_name)
 Macro to extern a named section start and stop symbols. More...
 
#define NRF_SECTION_VARS_ADD(section_name, type_def)   static type_def __attribute__ ((section(#section_name))) __attribute__((used))
 Macro to declare a variable to be placed in a named section. More...
 
#define NRF_SECTION_VARS_GET(i, type_name, section_name)   (type_name*)(NRF_SECTION_VARS_START_ADDR(section_name) + i * sizeof(type_name))
 Macro to get symbol from named section. More...
 
#define NRF_SECTION_VARS_COUNT(type_name, section_name)   NRF_SECTION_VARS_LENGTH(section_name) / sizeof(type_name)
 Macro to get number of items in named section. More...
 

Detailed Description

Section variables.

Macro Definition Documentation

#define NRF_SECTION_VARS_ADD (   section_name,
  type_def 
)    static type_def __attribute__ ((section(#section_name))) __attribute__((used))

Macro to declare a variable to be placed in a named section.

Declares a variable to be placed in a named section. This macro ensures that its symbol is not stripped by the linker because of optimizations.

Warning
The order with which variables are placed in a section is implementation dependant. Generally, variables are placed in a section depending on the order with which they are found by the linker.
The symbols added in the named section must be word aligned to prevent padding.
Parameters
[in]section_nameName of the section.
[in]type_defDatatype of the variable to place in the given section.
#define NRF_SECTION_VARS_COUNT (   type_name,
  section_name 
)    NRF_SECTION_VARS_LENGTH(section_name) / sizeof(type_name)

Macro to get number of items in named section.

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

Macro to obtain the linker symbol for the end of a given section.

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

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

Macro to get symbol from named 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 item in section.
[in]type_nameType name of item in section.
[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_SECTION (   section_name)

Macro to register a named section.

Parameters
[in]section_nameName of the section to register.
#define NRF_SECTION_VARS_REGISTER_SYMBOLS (   type_name,
  section_name 
)
Value:
extern type_name * NRF_SECTION_VARS_START_SYMBOL(section_name); \
extern void * NRF_SECTION_VARS_END_SYMBOL(section_name)

Macro to extern a named section start and stop symbols.

Note
These declarations are required for GCC and Keil linkers (but not for IAR's).
Parameters
[in]type_nameName of the type stored in the section.
[in]section_nameName of the section.
#define NRF_SECTION_VARS_START_ADDR (   section_name)    (uint32_t)&NRF_SECTION_VARS_START_SYMBOL(section_name)

Macro to obtain the start address of a named section.

param[in] section_name Name of the section.

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

Macro to obtain the linker symbol for 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 | Updated