pub struct LocalRegisterCopy<T, R = ()>where
T: UIntLike,
R: RegisterLongName,{ /* private fields */ }
Expand description
A read-write copy of register contents.
This behaves very similarly to a read-write register, but instead of doing a volatile read to MMIO to get the value for each function call, a copy of the register contents are stored locally in memory. This allows a peripheral to do a single read on a register, and then check which bits are set without having to do a full MMIO read each time. It also allows the value of the register to be “cached” in case the peripheral driver needs to clear the register in hardware yet still be able to check the bits. You can write to a local register, which will modify the stored value, but will not modify any hardware because it operates only on local copy.
This type does not implement the
Readable
and
Writeable
traits because it
requires a mutable reference to modify the contained value. It
still mirrors the interface which would be exposed by a type
implementing Readable
,
Writeable
and
ReadWriteable
.
Implementations§
Source§impl<T, R> LocalRegisterCopy<T, R>where
T: UIntLike,
R: RegisterLongName,
impl<T, R> LocalRegisterCopy<T, R>where
T: UIntLike,
R: RegisterLongName,
pub const fn new(value: T) -> LocalRegisterCopy<T, R>
Sourcepub fn read_as_enum<E>(&self, field: Field<T, R>) -> Option<E>where
E: TryFromValue<T, EnumType = E>,
pub fn read_as_enum<E>(&self, field: Field<T, R>) -> Option<E>where
E: TryFromValue<T, EnumType = E>,
Read value of the given field as an enum member
Sourcepub fn write(&mut self, field: FieldValue<T, R>)
pub fn write(&mut self, field: FieldValue<T, R>)
Write the value of one or more fields, overwriting the other fields with zero
Sourcepub fn modify(&mut self, field: FieldValue<T, R>)
pub fn modify(&mut self, field: FieldValue<T, R>)
Write the value of one or more fields, leaving the other fields unchanged
Sourcepub fn any_matching_bits_set(&self, field: FieldValue<T, R>) -> bool
pub fn any_matching_bits_set(&self, field: FieldValue<T, R>) -> bool
Check if any bits corresponding to the mask in the passed FieldValue
are set.
Sourcepub fn matches_all(&self, field: FieldValue<T, R>) -> bool
pub fn matches_all(&self, field: FieldValue<T, R>) -> bool
Check if all specified parts of a field match
Sourcepub fn matches_any(&self, fields: &[FieldValue<T, R>]) -> bool
pub fn matches_any(&self, fields: &[FieldValue<T, R>]) -> bool
Check if any of the passed parts of a field exactly match the contained value. This allows for matching on unset bits, or matching on specific values in multi-bit fields.
Sourcepub fn bitand(&self, rhs: T) -> LocalRegisterCopy<T, R>
pub fn bitand(&self, rhs: T) -> LocalRegisterCopy<T, R>
Do a bitwise AND operation of the stored value and the passed in value and return a new LocalRegisterCopy.
pub fn debug(&self) -> RegisterDebugValue<T, R>where
R: RegisterDebugInfo<T>,
Trait Implementations§
Source§impl<T, R> Clone for LocalRegisterCopy<T, R>
impl<T, R> Clone for LocalRegisterCopy<T, R>
Source§fn clone(&self) -> LocalRegisterCopy<T, R>
fn clone(&self) -> LocalRegisterCopy<T, R>
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read more