Crate volatile_register [−] [src]
Volatile access to memory mapped hardware registers
Usage
use volatile_register::{RO, RW, WO}; /// A struct that represents the memory mapped register block for the GPIO /// (General Purpose I/O) peripherals. #[repr(C)] pub struct Gpio { /// Control Register cr: RW<u32>, /// Input Data Register idr: RO<u32>, /// Output Data Register odr: WO<u32>, // .. more registers .. } /// Accessor to the register block associated to the GPIOA peripheral fn gpioa() -> &'static Gpio { const ADDRESS: usize = 0x40010800; unsafe { &*(ADDRESS as *const Gpio) } } /// Accessor to the register block associated to the GPIOC peripheral /// NOTE(unsafe) This function hands out mutable aliases to a single address. unsafe fn gpioc_mut() -> &'static mut Gpio { const ADDRESS: usize = 0x40011000; unsafe { &mut *(ADDRESS as *mut Gpio) } }Run
Structs
RO |
Read-Only register |
RW |
Read-Write register |
WO |
Write-Only register |