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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
//! # mmio Library API
//!
//! This crate provides safe, concurrent access to 32-bit memory-mapped IO registers via /dev/mem.
//! It is designed for use in CLI tools, controllers, and logging utilities that need direct register access.
//!
//! ## Example Usage
//!
//! ```rust
//! use mmreg::{read_register_at, write_register_at};
//!
//! // Read a 32-bit value from a physical address
//! let value = read_register_at(0x4000_0000)?;
//!
//! // Write a 32-bit value to a physical address
//! write_register_at(0x4000_0000, 0xDEADBEEF)?;
//! ```
/// The main interface for managing mapped registers and safe access.
///
/// Create an `Interface` to manage a group of registers, handle mapping/unmapping, and provide safe concurrent access.
pub use Interface;
/// Represents a 32-bit register with optional subregisters (bitfields).
///
/// Use `Register::new` to construct, and access via `Interface` methods.
pub use ;
/// Reads a 32-bit value from a physical address using /dev/mem.
///
/// # Arguments
/// * `address` - The physical address to read from.
///
/// # Returns
/// * `Ok(u32)` - The value read from the address.
/// * `Err(String)` - Error message if mapping or reading fails.
///
/// # Example
/// ```rust
/// let value = mmreg::read_register_at(0x4000_0000)?;
/// println!("Value: 0x{:08X}", value);
/// ```
/// Writes a 32-bit value to a physical address using /dev/mem.
///
/// # Arguments
/// * `address` - The physical address to write to.
/// * `value` - The 32-bit value to write.
///
/// # Returns
/// * `Ok(())` - On success.
/// * `Err(String)` - Error message if mapping or writing fails.
///
/// # Example
/// ```rust
/// mmreg::write_register_at(0x4000_0000, 0xDEADBEEF)?;
/// println!("Wrote value.");
/// ```