pub trait Readable {
    type T: UIntLike;
    type R: RegisterLongName;

    fn get(&self) -> Self::T;

    fn read(&self, field: Field<Self::T, Self::R>) -> Self::T { ... }
    fn read_as_enum<E>(&self, field: Field<Self::T, Self::R>) -> Option<E>
        E: TryFromValue<Self::T, EnumType = E>
, { ... } fn extract(&self) -> LocalRegisterCopy<Self::T, Self::R> { ... } fn is_set(&self, field: Field<Self::T, Self::R>) -> bool { ... } fn matches_any(&self, field: FieldValue<Self::T, Self::R>) -> bool { ... } fn matches_all(&self, field: FieldValue<Self::T, Self::R>) -> bool { ... } }
Expand description

Readable register

Register which at least supports reading the current value. Only Readable::get must be implemented, as for other methods a default implementation is provided.

A register that is both Readable and Writeable will also automatically be ReadWriteable, if the RegisterLongName of Readable is the same as that of Writeable (i.e. not for Aliased registers).

Required Associated Types

Required Methods

Get the raw register value

Provided Methods

Read the value of the given field

Set the raw register value

The register_bitfields! macro will generate an enum containing the various named field variants and implementing the required TryFromValue trait. It is accessible as $REGISTER_NAME::$FIELD_NAME::Value.

This method can be useful to symbolically represent read register field states throughout the codebase and to enforce exhaustive matches over all defined valid register field values.

Usage Example
            Foo = 0,
            Bar = 1,
            Baz = 2,

let reg: InMemoryRegister<u8, EXAMPLEREG::Register> =

match reg.read_as_enum(EXAMPLEREG::TESTFIELD) {
    Some(EXAMPLEREG::TESTFIELD::Value::Foo) => "Tock",
    Some(EXAMPLEREG::TESTFIELD::Value::Bar) => "is",
    Some(EXAMPLEREG::TESTFIELD::Value::Baz) => "awesome!",
    None => panic!("boo!"),

Make a local copy of the register

Check if one or more bits in a field are set

Check if any specified parts of a field match

Check if all specified parts of a field match