reg-map
Derive volatile accesses to a register map and memory-mapped IO.
Documentation
API documentation in available at docs.rs/reg-map.
Usage
Here's a quick-and-dirty example, see the API documentation for more use cases such as iteration and a more in-depth description of the functionality.
use RegMap;
// define struct Registers with the register map
// and derive the pointer RegistersPtr using the RegMap macro
// initialize the base struct
// and obtain a pointer to the registers
let mut regs = default;
let ptr = from_mut;
// when dealing with e.g. memory-mapped IO (MMIO),
// you'd probably just get a pointer to the data from a known base address
// let ptr = unsafe { RegistersPtr::from_ptr(0xAA55_000 as *mut _) };
// all write() operations are volatile
ptr.field1.write;
ptr.field2.write;
ptr.write_only_field.write;
ptr.read_write_is_default.write;
// all read() operations are volatile
assert_eq!;
assert_eq!;
assert_eq!;
assert_eq!;
License
Licensed under either of
at your option.
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in this crate by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.