Skip to main content

IndexedRegister

Trait IndexedRegister 

Source
pub trait IndexedRegister: Sized {
    type Value: MmioOperand;

    const BASE_OFFSET: usize;
    const STRIDE: usize;
    const COUNT: usize;

    // Required methods
    fn from_raw(value: Self::Value) -> Self;
    fn to_raw(&self) -> Self::Value;
}
Expand description

A trait for types representing an array (block) of registers in MMIO.

Indexed registers are located at a base offset and repeat at a fixed stride. They are typically accessed using a zero-based index.

§Examples

indexed_register! {
    DataReg, u32, 0x100, 4, 16, RW, {
        pub value, set_value: 31, 0;
    }
}

Required Associated Constants§

Source

const BASE_OFFSET: usize

The byte offset of the first element in the register array.

Source

const STRIDE: usize

The byte distance between successive elements in the register array.

Source

const COUNT: usize

The maximum number of valid elements in the register array.

Required Associated Types§

Source

type Value: MmioOperand

The underlying integer type (e.g., u32) that holds the register bits.

Required Methods§

Source

fn from_raw(value: Self::Value) -> Self

Initializes the register type with a raw value, typically after reading from MMIO.

Source

fn to_raw(&self) -> Self::Value

Converts the register type back to its raw bits, typically before writing to MMIO.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§