Peripheral Access

__I volatile const
__O volatile
__IO volatile
__IM volatile const
__OM volatile
__IOM volatile
_VAL2FLD(field, value) (((uint32_t)(value) << field ## _Pos) & field ## _Msk)
_FLD2VAL(field, value) (((uint32_t)(value) & field ## _Msk) >> field ## _Pos)
group NMSIS_Core_PeriphAccess

Naming conventions and optional features for accessing peripherals.

The section below describes the naming conventions, requirements, and optional features for accessing device specific peripherals. Most of the rules also apply to the core peripherals.

The Device Header File <device.h> contains typically these definition and also includes the core specific header files.

Defines

__I volatile const

Defines ‘read only’ permissions.

__O volatile

Defines ‘write only’ permissions.

__IO volatile

Defines ‘read / write’ permissions.

__IM volatile const

Defines ‘read only’ structure member permissions.

__OM volatile

Defines ‘write only’ structure member permissions.

__IOM volatile

Defines ‘read/write’ structure member permissions.

_VAL2FLD(field, value) (((uint32_t)(value) << field ## _Pos) & field ## _Msk)

Mask and shift a bit field value for use in a register bit range.

The macro _VAL2FLD uses the #define’s _Pos and _Msk of the related bit field to shift bit-field values for assigning to a register.

Example:

ECLIC->CFG = _VAL2FLD(CLIC_CLICCFG_NLBIT, 3);

Parameters
  • field[in] Name of the register bit field.

  • value[in] Value of the bit field. This parameter is interpreted as an uint32_t type.

Returns

Masked and shifted value.

_FLD2VAL(field, value) (((uint32_t)(value) & field ## _Msk) >> field ## _Pos)

Mask and shift a register value to extract a bit filed value.

The macro _FLD2VAL uses the #define’s _Pos and _Msk of the related bit field to extract the value of a bit field from a register.

Example:

nlbits = _FLD2VAL(CLIC_CLICCFG_NLBIT, ECLIC->CFG);

Parameters
  • field[in] Name of the register bit field.

  • value[in] Value of register. This parameter is interpreted as an uint32_t type.

Returns

Masked and shifted bit field value.