Zth (libzth)
Loading...
Searching...
No Matches

Classes

struct  zth::Register< T, Addr, Fields >
 Helper class to read/write (bitfields in) hardware registers. More...
 

Macros

#define ZTH_REG_DEFINE(T, name, addr, fields...)
 Define a hardware reference helper class, with bitfields.
 

Detailed Description

Macro Definition Documentation

◆ ZTH_REG_DEFINE

#define ZTH_REG_DEFINE (   T,
  name,
  addr,
  fields... 
)
Value:
struct name##__type { \
T ZTH_REG_BITFIELDS(fields); \
} __attribute__((packed)); \
struct name : public zth::Register<T, addr, name##__type> { \
using typename base::type; \
name() noexcept \
: base() \
{} \
constexpr explicit name(type v) noexcept \
: base(v) \
{} \
};
#define ZTH_REG_BITFIELDS(...)
Definition regs.h:90
Helper class to read/write (bitfields in) hardware registers.
Definition regs.h:31

Define a hardware reference helper class, with bitfields.

Example to create zth::reg_mpu_type register:

// clang-format off
ZTH_REG_DEFINE(uint32_t, reg_mpu_type, 0xE000ED90,
// 32-bit register definition in unsigned int fields,
// ordered from MSB to LSB.
reserved1 : 8,
region : 8,
dregion : 8,
reserved2 : 7,
separate : 1)
// clang-format on
#define ZTH_REG_DEFINE(T, name, addr, fields...)
Define a hardware reference helper class, with bitfields.
Definition regs.h:116

Afterwards, instantiate the zth::reg_mpu_type class to access the hardware register.

See also
zth::Register

Definition at line 116 of file regs.h.