#no-std #volatile #register

no-std volatile-register

Volatile access to memory mapped hardware registers

5 releases

Uses old Rust 2015

0.2.1 Aug 14, 2021
0.2.0 Mar 8, 2017
0.1.2 Oct 15, 2016
0.1.1 Sep 28, 2016
0.1.0 Sep 27, 2016

#210 in Hardware support

Download history 33322/week @ 2022-10-09 36058/week @ 2022-10-16 33188/week @ 2022-10-23 36689/week @ 2022-10-30 35816/week @ 2022-11-06 31133/week @ 2022-11-13 27036/week @ 2022-11-20 31214/week @ 2022-11-27 29097/week @ 2022-12-04 26775/week @ 2022-12-11 24043/week @ 2022-12-18 19473/week @ 2022-12-25 22063/week @ 2023-01-01 23206/week @ 2023-01-08 18432/week @ 2023-01-15 19235/week @ 2023-01-22

85,599 downloads per month
Used in 1,088 crates (18 directly)

MIT/Apache

8KB
73 lines

crates.io crates.io

volatile-register

Volatile access to memory mapped hardware registers

Documentation

License

Licensed under either of

at your option.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.


lib.rs:

Volatile access to memory mapped hardware registers

Usage

use volatile_register::RW;

// Create a struct that represents the memory mapped register block
/// Nested Vector Interrupt Controller
#[repr(C)]
pub struct Nvic {
    /// Interrupt Set-Enable
    pub iser: [RW<u32>; 8],
    reserved0: [u32; 24],
    /// Interrupt Clear-Enable
    pub icer: [RW<u32>; 8],
    reserved1: [u32; 24],
    // .. more registers ..
}

// Access the registers by casting the base address of the register block
// to the previously declared `struct`
let nvic = 0xE000_E100 as *const Nvic;
// Unsafe because the compiler can't verify the address is correct
unsafe { (*nvic).iser[0].write(1) }

Dependencies

~7KB