macro_rules! indexed_register {
($(#[$attr:meta])* pub struct $name:ident ($val_type:ty) @ $base_offset:expr, stride $stride:expr, count $count:expr, RO { $($field_spec:tt)* }) => { ... };
($(#[$attr:meta])* pub struct $name:ident ($val_type:ty) @ $base_offset:expr, stride $stride:expr, count $count:expr, WO { $($field_spec:tt)* }) => { ... };
($(#[$attr:meta])* pub struct $name:ident ($val_type:ty) @ $base_offset:expr, stride $stride:expr, count $count:expr, RW { $($field_spec:tt)* }) => { ... };
($(#[$attr:meta])* pub struct $name:ident ($val_type:ty) @ $base_offset:expr, stride $stride:expr, count $count:expr, RO ;) => { ... };
($(#[$attr:meta])* pub struct $name:ident ($val_type:ty) @ $base_offset:expr, stride $stride:expr, count $count:expr, WO ;) => { ... };
($(#[$attr:meta])* pub struct $name:ident ($val_type:ty) @ $base_offset:expr, stride $stride:expr, count $count:expr, RW ;) => { ... };
($name:ident, $val_type:ty, $base_offset:expr, $stride:expr, $count:expr, RO, { $($field_spec:tt)* }) => { ... };
($name:ident, $val_type:ty, $base_offset:expr, $stride:expr, $count:expr, WO, { $($field_spec:tt)* }) => { ... };
($name:ident, $val_type:ty, $base_offset:expr, $stride:expr, $count:expr, RW, { $($field_spec:tt)* }) => { ... };
}Expand description
A macro for defining an IndexedRegister and its bitfields.
This macro generates a bitfield struct that implements the IndexedRegister,
RegisterReadAccess and RegisterWriteAccess traits. The access mode (RO, WO, RW)
determines which of the ReadableIndexedRegister and WritableIndexedRegister
traits are implemented.
§Examples
indexed_register! {
pub struct DataReg(u32) @ 0x100, stride 4, count 16, RO {
pub value, _: 31, 0;
}
}Full-width indexed register:
indexed_register! {
pub struct ValueReg(u32) @ 0x200, stride 4, count 8, RW;
}NOTE: If you use this macro, you must add a dependency on the bitfield crate. (At the time of writing, it isn’t easy to avoid this.)