opentitanlib::test_utils::bitbanging::spi

Struct SpiBitbangEncoder

Source
pub struct SpiBitbangEncoder<const D0: u8, const D1: u8, const D2: u8, const D3: u8, const CLK: u8, const CS: u8> {
    pub config: SpiBitbangConfig,
    pub delays: SpiEncodingDelays,
    /* private fields */
}
Expand description

An encoder for SPI transmissions, parameterized over bits in the output bitfields to use for transmission. Does not support encoding as a SPI device (only works as a SPI host).

Fields§

§config: SpiBitbangConfig§delays: SpiEncodingDelays

Implementations§

Source§

impl<const D0: u8, const D1: u8, const D2: u8, const D3: u8, const CLK: u8, const CS: u8> SpiBitbangEncoder<D0, D1, D2, D3, CLK, CS>

Source

pub fn new(config: SpiBitbangConfig, delays: SpiEncodingDelays) -> Self

Source

pub fn reset(&mut self)

Source

pub fn set_data_mode(&mut self, mode: SpiDataMode)

Source

pub fn assert_cs(&mut self, assert: bool, samples: &mut Vec<u8>)

Output GPIO bitbanging samples for pulling CS low/high (active/inactive).

Source

pub fn encode_read( &mut self, words: usize, samples: &mut Vec<u8>, ) -> Result<(), SpiTransferEncodeError>

Encode a read transmission of several SPI words into GPIO bitbanging samples. CS should already be asserted via assert_cs before calling.

Source

pub fn encode_write( &mut self, data: &[u8], samples: &mut Vec<u8>, ) -> Result<(), SpiTransferEncodeError>

Encode a write transmission of several SPI words into GPIO bitbanging samples. CS should already be asserted via assert_cs before calling.

Source

pub fn encode_transaction( &mut self, data: &[u8], samples: &mut Vec<u8>, ) -> Result<(), SpiTransferEncodeError>

A helper function to encode a full SPI transmission, including logic for asserting and later de-asserting the CS.

Auto Trait Implementations§

§

impl<const D0: u8, const D1: u8, const D2: u8, const D3: u8, const CLK: u8, const CS: u8> Freeze for SpiBitbangEncoder<D0, D1, D2, D3, CLK, CS>

§

impl<const D0: u8, const D1: u8, const D2: u8, const D3: u8, const CLK: u8, const CS: u8> RefUnwindSafe for SpiBitbangEncoder<D0, D1, D2, D3, CLK, CS>

§

impl<const D0: u8, const D1: u8, const D2: u8, const D3: u8, const CLK: u8, const CS: u8> Send for SpiBitbangEncoder<D0, D1, D2, D3, CLK, CS>

§

impl<const D0: u8, const D1: u8, const D2: u8, const D3: u8, const CLK: u8, const CS: u8> Sync for SpiBitbangEncoder<D0, D1, D2, D3, CLK, CS>

§

impl<const D0: u8, const D1: u8, const D2: u8, const D3: u8, const CLK: u8, const CS: u8> Unpin for SpiBitbangEncoder<D0, D1, D2, D3, CLK, CS>

§

impl<const D0: u8, const D1: u8, const D2: u8, const D3: u8, const CLK: u8, const CS: u8> UnwindSafe for SpiBitbangEncoder<D0, D1, D2, D3, CLK, CS>

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

Source§

type Output = T

Should always be Self
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.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V