[−][src]Crate ruspiro_register
RusPiRo MMIO register abstraction
The crate provides a hopefully simple to use compiletime type safe abstraction of MMIO registers of the Raspberry Pi.
Usage
Register defintitions are simple and straight forward using the macros provided by this crate. In your code you can define registers like this:
use ruspiro_register::*; // define a single register without any specific fields, like the free running system timer counter low value // of the Raspberry Pi 3. Valid register size types are u8, u16, u32, u64. define_register!( TIMERCLO: ReadOnly<u32> @ 0x3F00_3004 => [] ); // define a list of registers that may ore may not contain a specific field configuration define_registers! [ TIMERCHI: ReadOnly<u32> @ 0x3F00_3008 => [], I2C_C: ReadWrite<u32> @ 0x3F80_4000 => [ ENABLE OFFSET(15), IRQ_RX OFFSET(10), IRQ_TX OFFSET(9), IRQ_DONE OFFSET(8), STARTTRANS OFFSET(7), CLEAR OFFSET(4) BITS(2), READ OFFSET(1), WRITE OFFSET(0) ] ];
With the name of the register given at the definition the contents and the fields are accessible like so:
let _ = TIMERCLO::Register.get(); // get the raw register value let _ = I2C_C::Register.read(I2C_C::ENABLE); // get the value of the requested register field I2C_C::Register.modify(I2C_C::CLEAR, 0x1); // update a specific field value of the register
Re-exports
pub use self::macros::*; |
pub use self::register::*; |
Modules
macros | Register definition macros |
register | Register abstraction implementation |
Macros
define_register | Macro to define a single register with a specific defined access mode. |
define_registers | Macro to provide multiple register definitions at once |