Skip to main content

FakeMmioDevice

Struct FakeMmioDevice 

Source
pub struct FakeMmioDevice<M>(/* private fields */);
Expand description

Provides a wrapper around Mmio and AtomicMmio implementations for register access in tests from the perspective of a device.

This struct effectively sidesteps the WritableRegister and ReadableRegister traits, given it’s meant to be used by a faked peripheral Mmio.

Implementations§

Source§

impl<M> FakeMmioDevice<M>

Source

pub fn new(m: M) -> Self

Creates a new FakeMmioDevice wrapping the MMIO implementation m.

Source§

impl<M: Mmio> FakeMmioDevice<M>

Source

pub fn read<R: Register>(&self) -> R

Reads a register R.

Source

pub fn write<R: Register>(&mut self, v: R)

Writes a register R with value v.

Source

pub fn clear_bits<R: Register>(&mut self, v: R::Value)

Clears the specified bits in v for register R.

Source

pub fn set_bits<R: Register>(&mut self, v: R::Value)

Sets the specified bits in v for register R.

Source

pub fn read_indexed<R: IndexedRegister>(&self, index: usize) -> R

Reads an indexed register R at index.

Source

pub fn write_indexed<R: IndexedRegister>(&mut self, index: usize, v: R)

Writes an indexed register R with value v at index.

Source§

impl<M: AtomicMmio> FakeMmioDevice<M>

Source

pub fn swap<R: Register<Value: MmioOperand>>(&self, v: R) -> R

Atomically swaps register R with value v and returns the previous value.

Source

pub fn take<R: Register<Value: MmioOperand> + Default>(&self) -> R

Atomically takes register R, replacing it with R::default(), and returns the previous value.

Source

pub fn fetch_or<R: Register<Value: MmioOperand>>(&self, v: R) -> R

Atomically performs bitwise OR on register R with v and returns the previous value.

Auto Trait Implementations§

§

impl<M> Freeze for FakeMmioDevice<M>
where M: Freeze,

§

impl<M> RefUnwindSafe for FakeMmioDevice<M>
where M: RefUnwindSafe,

§

impl<M> Send for FakeMmioDevice<M>
where M: Send,

§

impl<M> Sync for FakeMmioDevice<M>
where M: Sync,

§

impl<M> Unpin for FakeMmioDevice<M>
where M: Unpin,

§

impl<M> UnsafeUnpin for FakeMmioDevice<M>
where M: UnsafeUnpin,

§

impl<M> UnwindSafe for FakeMmioDevice<M>
where M: 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> 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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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.