Expand description
Zero-overhead, no_std memory-mapped I/O register abstraction.
§Quick start
ⓘ
use mmio_rs::prelude::*;
// Implement a critical section for your target once per binary.
mmio_rs::impl_critical_section!(
acquire: { /* disable interrupts, return previous state */ 0 },
release: |_state| { /* restore interrupt state */ }
);
// Define a peripheral's register layout.
mmio_rs::register_block! {
pub struct Uart @ 0x4000_1000 {
dr: u32 => ReadWrite @ 0x00,
sr: u32 => ReadOnly @ 0x04,
brr: u32 => ReadWrite @ 0x08,
}
}
// Use it.
Uart::dr().write(b'A' as u32);
let status = Uart::sr().read();
Uart::brr().write_field(0xFFFF, 0, 0x0683); // set baud divisorModules§
- prelude
- Convenience re-export of the most commonly used types.
Macros§
- impl_
critical_ section - Implement this macro once in your project to provide the critical section.
- register_
block - Define a register block with named fields and a static base address.
Structs§
- Atomic
Register - Wraps a
Registerto provide interrupt-safe read-modify-write operations via thecritical_sectionmechanism. - Dynamic
Register Block - Like
RegisterBlockbut the register typeTand access markerAccessare fixed at construction time, and the base address can be set after creation. - IrqGuard
- RAII guard that acquires the critical section on creation and releases it on drop.
- Read
Only - Access marker: register can only be read.
- Read
Write - Access marker: register can be both read and written.
- Register
- A typed pointer to a single memory-mapped register.
- Register
Block - A fixed-size array of
Nregisters sharing a base address, addressed by index. - Write
Only - Access marker: register can only be written.
Functions§
- critical_
section - Executes
finside a critical section, returning its result.