Struct ReadWriteRiscvCsr

Source
pub struct ReadWriteRiscvCsr<T: UIntLike, R: RegisterLongName, const V: usize> { /* private fields */ }
Expand description

Read/Write registers.

Implementations§

Source§

impl<R: RegisterLongName, const V: usize> ReadWriteRiscvCsr<usize, R, V>

Source

pub const fn new() -> Self

Source

pub fn atomic_replace(&self, val_to_set: usize) -> usize

Atomically swap the contents of a CSR

Reads the current value of a CSR and replaces it with the specified value in a single instruction, returning the previous value.

This method corresponds to the RISC-V CSRRW rd, csr, rs1 instruction where rs1 = in(reg) value_to_set and rd = out(reg) <return value>.

Source

pub fn read_and_set_bits(&self, bitmask: usize) -> usize

Atomically read a CSR and set bits specified in a bitmask

This method corresponds to the RISC-V CSRRS rd, csr, rs1 instruction where rs1 = in(reg) bitmask and rd = out(reg) <return value>.

Source

pub fn read_and_clear_bits(&self, bitmask: usize) -> usize

Atomically read a CSR and clear bits specified in a bitmask

This method corresponds to the RISC-V CSRRC rd, csr, rs1 instruction where rs1 = in(reg) bitmask and rd = out(reg) <return value>.

Source

pub fn read_and_set_field(&self, field: Field<usize, R>) -> usize

Atomically read field and set all bits to 1

This method corresponds to the RISC-V CSRRS rd, csr, rs1 instruction, where rs1 is the bitmask described by the Field.

The previous value of the field is returned.

Source

pub fn read_and_clear_field(&self, field: Field<usize, R>) -> usize

Atomically read field and set all bits to 0

This method corresponds to the RISC-V CSRRC rd, csr, rs1 instruction, where rs1 is the bitmask described by the Field.

The previous value of the field is returned.

Trait Implementations§

Source§

impl<T: Clone + UIntLike, R: Clone + RegisterLongName, const V: usize> Clone for ReadWriteRiscvCsr<T, R, V>

Source§

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

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<R: RegisterLongName, const V: usize> Readable for ReadWriteRiscvCsr<usize, R, V>

Source§

type T = usize

Source§

type R = R

Source§

fn get(&self) -> usize

Get the raw register value
Source§

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

Read the value of the given field
Source§

fn read_as_enum<E>(&self, field: Field<Self::T, Self::R>) -> Option<E>
where E: TryFromValue<Self::T, EnumType = E>,

Set the raw register value Read more
Source§

fn extract(&self) -> LocalRegisterCopy<Self::T, Self::R>

Make a local copy of the register
Source§

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

Check if one or more bits in a field are set
Source§

fn any_matching_bits_set(&self, field: FieldValue<Self::T, Self::R>) -> bool

Check if any bits corresponding to the mask in the passed FieldValue are set. This function is identical to is_set() but operates on a FieldValue rather than a Field, allowing for checking if any bits are set across multiple, non-contiguous portions of a bitfield.
Source§

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

Check if all specified parts of a field match
Source§

fn matches_any(&self, fields: &[FieldValue<Self::T, Self::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§

impl<R: RegisterLongName, const V: usize> Writeable for ReadWriteRiscvCsr<usize, R, V>

Source§

type T = usize

Source§

type R = R

Source§

fn set(&self, val_to_set: usize)

Set the raw register value
Source§

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

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

fn modify_no_read( &self, original: LocalRegisterCopy<Self::T, Self::R>, field: FieldValue<Self::T, Self::R>, )

Write the value of one or more fields, maintaining the value of unchanged fields via a provided original value, rather than a register read.
Source§

impl<T: Copy + UIntLike, R: Copy + RegisterLongName, const V: usize> Copy for ReadWriteRiscvCsr<T, R, V>

Auto Trait Implementations§

§

impl<T, R, const V: usize> Freeze for ReadWriteRiscvCsr<T, R, V>

§

impl<T, R, const V: usize> RefUnwindSafe for ReadWriteRiscvCsr<T, R, V>

§

impl<T, R, const V: usize> Send for ReadWriteRiscvCsr<T, R, V>
where R: Send, T: Send,

§

impl<T, R, const V: usize> Sync for ReadWriteRiscvCsr<T, R, V>
where R: Sync, T: Sync,

§

impl<T, R, const V: usize> Unpin for ReadWriteRiscvCsr<T, R, V>
where R: Unpin, T: Unpin,

§

impl<T, R, const V: usize> UnwindSafe for ReadWriteRiscvCsr<T, R, V>
where R: UnwindSafe, T: UnwindSafe,

Blanket Implementations§

Source§

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

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

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

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

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

Source§

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

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dst: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. Read more
Source§

impl<T> Debuggable for T
where T: Readable,

Source§

fn debug(&self) -> RegisterDebugValue<Self::T, Self::R>
where Self::R: RegisterDebugInfo<Self::T>,

Returns a RegisterDebugValue that implements core::fmt::Debug, the debug information is extracted from <Register>::DebugInfo.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where 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, R, S> ReadWriteable for S
where R: RegisterLongName, S: Readable<T = T, R = R> + Writeable<T = T, R = R>, T: UIntLike,

Source§

type T = T

Source§

type R = R

Source§

fn modify( &self, field: FieldValue<<S as ReadWriteable>::T, <S as ReadWriteable>::R>, )

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

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

Source§

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 T
where U: TryFrom<T>,

Source§

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.