Zephyr API Documentation  2.7.0-rc2
A Scalable Open Source RTOS
reg property

Macros

#define DT_NUM_REGS(node_id)   DT_CAT(node_id, _REG_NUM)
 Get the number of register blocks in the reg property. More...
 
#define DT_REG_HAS_IDX(node_id, idx)    IS_ENABLED(DT_CAT(node_id, _REG_IDX_##idx##_EXISTS))
 Is "idx" a valid register block index? More...
 
#define DT_REG_ADDR_BY_IDX(node_id, idx)    DT_CAT(node_id, _REG_IDX_##idx##_VAL_ADDRESS)
 Get the base address of the register block at index "idx". More...
 
#define DT_REG_SIZE_BY_IDX(node_id, idx)    DT_CAT(node_id, _REG_IDX_##idx##_VAL_SIZE)
 Get the size of the register block at index "idx". More...
 
#define DT_REG_ADDR(node_id)   DT_REG_ADDR_BY_IDX(node_id, 0)
 Get a node's (only) register block address. More...
 
#define DT_REG_SIZE(node_id)   DT_REG_SIZE_BY_IDX(node_id, 0)
 Get a node's (only) register block size. More...
 
#define DT_REG_ADDR_BY_NAME(node_id, name)    DT_CAT(node_id, _REG_NAME_##name##_VAL_ADDRESS)
 Get a register block's base address by name. More...
 
#define DT_REG_SIZE_BY_NAME(node_id, name)    DT_CAT(node_id, _REG_NAME_##name##_VAL_SIZE)
 Get a register block's size by name. More...
 

Detailed Description

Macro Definition Documentation

◆ DT_NUM_REGS

#define DT_NUM_REGS (   node_id)    DT_CAT(node_id, _REG_NUM)

#include <include/devicetree.h>

Get the number of register blocks in the reg property.

Use this instead of DT_PROP_LEN(node_id, reg).

Parameters
node_idnode identifier
Returns
Number of register blocks in the node's "reg" property.

◆ DT_REG_ADDR

#define DT_REG_ADDR (   node_id)    DT_REG_ADDR_BY_IDX(node_id, 0)

#include <include/devicetree.h>

Get a node's (only) register block address.

Equivalent to DT_REG_ADDR_BY_IDX(node_id, 0).

Parameters
node_idnode identifier
Returns
node's register block address

◆ DT_REG_ADDR_BY_IDX

#define DT_REG_ADDR_BY_IDX (   node_id,
  idx 
)     DT_CAT(node_id, _REG_IDX_##idx##_VAL_ADDRESS)

#include <include/devicetree.h>

Get the base address of the register block at index "idx".

Parameters
node_idnode identifier
idxindex of the register whose address to return
Returns
address of the idx-th register block

◆ DT_REG_ADDR_BY_NAME

#define DT_REG_ADDR_BY_NAME (   node_id,
  name 
)     DT_CAT(node_id, _REG_NAME_##name##_VAL_ADDRESS)

#include <include/devicetree.h>

Get a register block's base address by name.

Parameters
node_idnode identifier
namelowercase-and-underscores register specifier name
Returns
address of the register block specified by name

◆ DT_REG_HAS_IDX

#define DT_REG_HAS_IDX (   node_id,
  idx 
)     IS_ENABLED(DT_CAT(node_id, _REG_IDX_##idx##_EXISTS))

#include <include/devicetree.h>

Is "idx" a valid register block index?

If this returns 1, then DT_REG_ADDR_BY_IDX(node_id, idx) or DT_REG_SIZE_BY_IDX(node_id, idx) are valid. If it returns 0, it is an error to use those macros with index "idx".

Parameters
node_idnode identifier
idxindex to check
Returns
1 if "idx" is a valid register block index, 0 otherwise.

◆ DT_REG_SIZE

#define DT_REG_SIZE (   node_id)    DT_REG_SIZE_BY_IDX(node_id, 0)

#include <include/devicetree.h>

Get a node's (only) register block size.

Equivalent to DT_REG_SIZE_BY_IDX(node_id, 0).

Parameters
node_idnode identifier
Returns
node's only register block's size

◆ DT_REG_SIZE_BY_IDX

#define DT_REG_SIZE_BY_IDX (   node_id,
  idx 
)     DT_CAT(node_id, _REG_IDX_##idx##_VAL_SIZE)

#include <include/devicetree.h>

Get the size of the register block at index "idx".

This is the size of an individual register block, not the total number of register blocks in the property; use DT_NUM_REGS() for that.

Parameters
node_idnode identifier
idxindex of the register whose size to return
Returns
size of the idx-th register block

◆ DT_REG_SIZE_BY_NAME

#define DT_REG_SIZE_BY_NAME (   node_id,
  name 
)     DT_CAT(node_id, _REG_NAME_##name##_VAL_SIZE)

#include <include/devicetree.h>

Get a register block's size by name.

Parameters
node_idnode identifier
namelowercase-and-underscores register specifier name
Returns
size of the register block specified by name