Struct tock_registers::LocalRegisterCopy
source · [−]pub struct LocalRegisterCopy<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
sourceimpl<T: UIntLike, R: RegisterLongName> LocalRegisterCopy<T, R>
impl<T: UIntLike, R: RegisterLongName> LocalRegisterCopy<T, R>
pub const fn new(value: T) -> Self
sourcepub fn read_as_enum<E: TryFromValue<T, EnumType = E>>(
&self,
field: Field<T, R>
) -> Option<E>
pub fn read_as_enum<E: TryFromValue<T, EnumType = E>>(
&self,
field: Field<T, R>
) -> Option<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 matches_any(&self, field: FieldValue<T, R>) -> bool
pub fn matches_any(&self, field: FieldValue<T, R>) -> bool
Check if any specified parts of a field match
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 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.
Trait Implementations
sourceimpl<T: Clone + UIntLike, R: Clone + RegisterLongName> Clone for LocalRegisterCopy<T, R>
impl<T: Clone + UIntLike, R: Clone + RegisterLongName> Clone for LocalRegisterCopy<T, R>
sourcefn clone(&self) -> LocalRegisterCopy<T, R>
fn clone(&self) -> LocalRegisterCopy<T, R>
Returns a copy of the value. Read more
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
sourceimpl<T: UIntLike + Debug, R: RegisterLongName> Debug for LocalRegisterCopy<T, R>
impl<T: UIntLike + Debug, R: RegisterLongName> Debug for LocalRegisterCopy<T, R>
sourceimpl<R: RegisterLongName> From<LocalRegisterCopy<u128, R>> for u128
impl<R: RegisterLongName> From<LocalRegisterCopy<u128, R>> for u128
sourcefn from(r: LocalRegisterCopy<u128, R>) -> u128
fn from(r: LocalRegisterCopy<u128, R>) -> u128
Converts to this type from the input type.
sourceimpl<R: RegisterLongName> From<LocalRegisterCopy<u16, R>> for u16
impl<R: RegisterLongName> From<LocalRegisterCopy<u16, R>> for u16
sourcefn from(r: LocalRegisterCopy<u16, R>) -> u16
fn from(r: LocalRegisterCopy<u16, R>) -> u16
Converts to this type from the input type.
sourceimpl<R: RegisterLongName> From<LocalRegisterCopy<u32, R>> for u32
impl<R: RegisterLongName> From<LocalRegisterCopy<u32, R>> for u32
sourcefn from(r: LocalRegisterCopy<u32, R>) -> u32
fn from(r: LocalRegisterCopy<u32, R>) -> u32
Converts to this type from the input type.
sourceimpl<R: RegisterLongName> From<LocalRegisterCopy<u64, R>> for u64
impl<R: RegisterLongName> From<LocalRegisterCopy<u64, R>> for u64
sourcefn from(r: LocalRegisterCopy<u64, R>) -> u64
fn from(r: LocalRegisterCopy<u64, R>) -> u64
Converts to this type from the input type.
sourceimpl<R: RegisterLongName> From<LocalRegisterCopy<u8, R>> for u8
impl<R: RegisterLongName> From<LocalRegisterCopy<u8, R>> for u8
sourcefn from(r: LocalRegisterCopy<u8, R>) -> u8
fn from(r: LocalRegisterCopy<u8, R>) -> u8
Converts to this type from the input type.
sourceimpl<R: RegisterLongName> From<LocalRegisterCopy<usize, R>> for usize
impl<R: RegisterLongName> From<LocalRegisterCopy<usize, R>> for usize
sourcefn from(r: LocalRegisterCopy<usize, R>) -> usize
fn from(r: LocalRegisterCopy<usize, R>) -> usize
Converts to this type from the input type.
impl<T: Copy + UIntLike, R: Copy + RegisterLongName> Copy for LocalRegisterCopy<T, R>
Auto Trait Implementations
impl<T, R> RefUnwindSafe for LocalRegisterCopy<T, R> where
R: RefUnwindSafe,
T: RefUnwindSafe,
impl<T, R> Send for LocalRegisterCopy<T, R> where
R: Send,
T: Send,
impl<T, R> Sync for LocalRegisterCopy<T, R> where
R: Sync,
T: Sync,
impl<T, R> Unpin for LocalRegisterCopy<T, R> where
R: Unpin,
T: Unpin,
impl<T, R> UnwindSafe for LocalRegisterCopy<T, R> where
R: UnwindSafe,
T: UnwindSafe,
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more