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§

source§

impl<T: UIntLike, R: RegisterLongName> LocalRegisterCopy<T, R>

source

pub const fn new(value: T) -> Self

source

pub fn get(&self) -> T

Get the raw register value

source

pub fn set(&mut self, value: T)

Set the raw register value

source

pub fn read(&self, field: Field<T, R>) -> T

Read the value of the given field

source

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

source

pub fn write(&mut self, field: FieldValue<T, R>)

Write the value of one or more fields, overwriting the other fields with zero

source

pub fn modify(&mut self, field: FieldValue<T, R>)

Write the value of one or more fields, leaving the other fields unchanged

source

pub fn is_set(&self, field: Field<T, R>) -> bool

Check if one or more bits in a field are set

source

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.

source

pub fn matches_all(&self, field: FieldValue<T, R>) -> bool

Check if all specified parts of a field match

source

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.

source

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§

source§

impl<T: Clone + UIntLike, R: Clone + RegisterLongName> Clone for LocalRegisterCopy<T, R>

source§

fn clone(&self) -> LocalRegisterCopy<T, R>

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl<T: UIntLike + Debug, R: RegisterLongName> Debug for LocalRegisterCopy<T, R>

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl<R: RegisterLongName> From<LocalRegisterCopy<u128, R>> for u128

source§

fn from(r: LocalRegisterCopy<u128, R>) -> u128

Converts to this type from the input type.
source§

impl<R: RegisterLongName> From<LocalRegisterCopy<u16, R>> for u16

source§

fn from(r: LocalRegisterCopy<u16, R>) -> u16

Converts to this type from the input type.
source§

impl<R: RegisterLongName> From<LocalRegisterCopy<u32, R>> for u32

source§

fn from(r: LocalRegisterCopy<u32, R>) -> u32

Converts to this type from the input type.
source§

impl<R: RegisterLongName> From<LocalRegisterCopy<u64, R>> for u64

source§

fn from(r: LocalRegisterCopy<u64, R>) -> u64

Converts to this type from the input type.
source§

impl<R: RegisterLongName> From<LocalRegisterCopy<u8, R>> for u8

source§

fn from(r: LocalRegisterCopy<u8, R>) -> u8

Converts to this type from the input type.
source§

impl<R: RegisterLongName> From<LocalRegisterCopy<usize, R>> for usize

source§

fn from(r: LocalRegisterCopy<usize, R>) -> usize

Converts to this type from the input type.
source§

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§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.