#no-std #volatile #register

no-std volatile-register

Volatile access to memory mapped hardware registers

4 releases

0.2.0 Mar 8, 2017
0.1.2 Oct 15, 2016
0.1.1 Sep 28, 2016
0.1.0 Sep 27, 2016

#6 in #volatile

Download history 1006/week @ 2019-12-10 1158/week @ 2019-12-17 1155/week @ 2019-12-24 1051/week @ 2019-12-31 1536/week @ 2020-01-07 1342/week @ 2020-01-14 1543/week @ 2020-01-21 1261/week @ 2020-01-28 1432/week @ 2020-02-04 1381/week @ 2020-02-11 1037/week @ 2020-02-18 1169/week @ 2020-02-25 1204/week @ 2020-03-03 1196/week @ 2020-03-10 1549/week @ 2020-03-17 1656/week @ 2020-03-24

4,286 downloads per month
Used in 368 crates (10 directly)

MIT/Apache

7KB
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