[−][src]Crate ruspiro_mmio_register
RusPiRo MMIO Register
This crate provides a macro to conveniently define memory mapped I/O registers.
define_mmio_register!( /// FOO Register with read/write access, 32 bit wide and mapped at memory /// address 0x3F20_0000 FOO<ReadWrite<u32>@(0x3F20_0000)> { /// This register provides a field BAR at offset 0 covering 1 Bit BAR OFFSET(0), /// There is another field BAZ at offset 1 covering 3 Bits BAZ OFFSET(1) BITS(3), /// The third field BAL also has specific predefined values BAL OFFSET(4) BITS(2) [ /// Field Value 1 VAL1 = 0b01, /// Field Value 2 VAL2 = 0b10 ] } ); fn main() { // write a specific value to a field of the register FOO::Register.write_value( FOO::BAL::VAL1 ); // combine two field values with logical OR FOO::Register.write_value( FOO::BAL::VAL1 | FOO::BAL::VAL2 ); // if there is no field defined for the MMIO register or raw value storage // is preffered the raw value could be written FOO::Register.write_value(FOO::BAZ::with_value(0b101)); FOO::Register.write(FOO::BAZ, 0b101); FOO::Register.set(0x1F); // reading from the MMIO register works in a simmilar way let baz_val = FOO::Register.read(FOO::BAL); // return 0b01 or 0b10 eg. let baz_field = FOO::Register.read_value(FOO::BAL); // returns a FieldValue let raw_val = FOO::Register.get(); }
Modules
macros | Register definition macros |
Macros
define_mmio_register | Macro to define a MMIO register with specific defined access mode. |
Structs
ReadOnly | This struct allows read only access to a register. |
ReadWrite | This struct allows read/write access to a register. |
RegisterField | Definition of a field contained inside of a register. Each field is defined by a mask and the bit shift value when constructing the field definition the stored mask is already shifted by the shift value |
RegisterFieldValue | Definition of a specific fieldvalue of a regiser. This structure allows to combine field values with bit operators
like |
WriteOnly | This struct allows write only access to a register. |
Traits
RegisterType | This trait is used to describe the register size/length as type specifier. The trait is only implemented for the internal types u8, u16, u32 and u64 to ensure safe register access sizes with compile time checking |