1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55
/*********************************************************************************************************************** * Copyright (c) 2019 by the authors * * Author: André Borrmann * License: Apache License 2.0 **********************************************************************************************************************/ #![doc(html_root_url = "https://docs.rs/ruspiro-register/0.1.1")] #![no_std] #![feature(const_fn)] //! # 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: //! ``` //! # fn main() { //! 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 //! # } //! ``` //! pub mod macros; pub use self::macros::*; pub mod register; pub use self::register::*;