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,

source

pub const fn new(value: T) -> LocalRegisterCopy<T, R>

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>(&self, field: Field<T, R>) -> Option<E>where E: TryFromValue<T, EnumType = 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, R> Clone for LocalRegisterCopy<T, R>where T: Clone + UIntLike, R: Clone + RegisterLongName,

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, R> Debug for LocalRegisterCopy<T, R>where T: UIntLike + Debug, R: RegisterLongName,

source§

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

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

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

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> SizedTypeProperties for T

source§

const IS_ZST: bool = size_of::<Self>() == 0

🔬This is a nightly-only experimental API. (sized_type_properties)
true if this type requires no storage. false if its size is greater than zero. Read more
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.
source§

impl<T> Printable for Twhere T: Copy + Debug,