32 template <
typename T, u
intptr_t Addr,
typename Fields>
38 static_assert(
sizeof(Fields) ==
sizeof(
type),
"");
51 static type volatile*
r() noexcept
53 return (
type volatile*)Addr;
81 operator type() const noexcept
87 # if defined(__BYTE_ORDER__) && __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
90 # define ZTH_REG_BITFIELDS(...) REVERSE(__VA_ARGS__)
92 # define ZTH_REG_BITFIELDS(...) __VA_ARGS__
118 # define ZTH_REG_DEFINE(T, name, addr, fields...) \
119 struct name##__type { \
120 T ZTH_REG_BITFIELDS(fields); \
121 } __attribute__((packed)); \
122 struct name : public zth::Register<T, addr, name##__type> { \
123 typedef zth::Register<T, addr, name##__type> base; \
124 using typename base::type; \
128 constexpr explicit name(type v) noexcept \
Helper class to read/write (bitfields in) hardware registers.
constexpr Register(type v) noexcept
static type volatile * r() noexcept
void write(type v) noexcept
type read() const noexcept
void write(type v) const noexcept
void write() const noexcept