Embassy
embassy-rp

Crates

git

Versions

rp2040

Flavors

Struct embassy_rp::spi::Spi

source ·
pub struct Spi<'d, T: Instance, M: Mode> { /* private fields */ }
Expand description

SPI driver.

Implementations§

source§

impl<'d, T: Instance, M: Mode> Spi<'d, T, M>

source

pub fn blocking_write(&mut self, data: &[u8]) -> Result<(), Error>

Write data to SPI blocking execution until done.

source

pub fn blocking_transfer_in_place( &mut self, data: &mut [u8] ) -> Result<(), Error>

Transfer data in place to SPI blocking execution until done.

source

pub fn blocking_read(&mut self, data: &mut [u8]) -> Result<(), Error>

Read data from SPI blocking execution until done.

source

pub fn blocking_transfer( &mut self, read: &mut [u8], write: &[u8] ) -> Result<(), Error>

Transfer data to SPI blocking execution until done.

source

pub fn flush(&mut self) -> Result<(), Error>

Block execution until SPI is done.

source

pub fn set_frequency(&mut self, freq: u32)

Set SPI frequency.

source§

impl<'d, T: Instance> Spi<'d, T, Blocking>

source

pub fn new_blocking( inner: impl Peripheral<P = T> + 'd, clk: impl Peripheral<P = impl ClkPin<T> + 'd> + 'd, mosi: impl Peripheral<P = impl MosiPin<T> + 'd> + 'd, miso: impl Peripheral<P = impl MisoPin<T> + 'd> + 'd, config: Config ) -> Self

Create an SPI driver in blocking mode.

source

pub fn new_blocking_txonly( inner: impl Peripheral<P = T> + 'd, clk: impl Peripheral<P = impl ClkPin<T> + 'd> + 'd, mosi: impl Peripheral<P = impl MosiPin<T> + 'd> + 'd, config: Config ) -> Self

Create an SPI driver in blocking mode supporting writes only.

source

pub fn new_blocking_rxonly( inner: impl Peripheral<P = T> + 'd, clk: impl Peripheral<P = impl ClkPin<T> + 'd> + 'd, miso: impl Peripheral<P = impl MisoPin<T> + 'd> + 'd, config: Config ) -> Self

Create an SPI driver in blocking mode supporting reads only.

source§

impl<'d, T: Instance> Spi<'d, T, Async>

source

pub fn new( inner: impl Peripheral<P = T> + 'd, clk: impl Peripheral<P = impl ClkPin<T> + 'd> + 'd, mosi: impl Peripheral<P = impl MosiPin<T> + 'd> + 'd, miso: impl Peripheral<P = impl MisoPin<T> + 'd> + 'd, tx_dma: impl Peripheral<P = impl Channel> + 'd, rx_dma: impl Peripheral<P = impl Channel> + 'd, config: Config ) -> Self

Create an SPI driver in async mode supporting DMA operations.

source

pub fn new_txonly( inner: impl Peripheral<P = T> + 'd, clk: impl Peripheral<P = impl ClkPin<T> + 'd> + 'd, mosi: impl Peripheral<P = impl MosiPin<T> + 'd> + 'd, tx_dma: impl Peripheral<P = impl Channel> + 'd, config: Config ) -> Self

Create an SPI driver in async mode supporting DMA write operations only.

source

pub fn new_rxonly( inner: impl Peripheral<P = T> + 'd, clk: impl Peripheral<P = impl ClkPin<T> + 'd> + 'd, miso: impl Peripheral<P = impl MisoPin<T> + 'd> + 'd, rx_dma: impl Peripheral<P = impl Channel> + 'd, config: Config ) -> Self

Create an SPI driver in async mode supporting DMA read operations only.

source

pub async fn write(&mut self, buffer: &[u8]) -> Result<(), Error>

Write data to SPI using DMA.

source

pub async fn read(&mut self, buffer: &mut [u8]) -> Result<(), Error>

Read data from SPI using DMA.

source

pub async fn transfer( &mut self, rx_buffer: &mut [u8], tx_buffer: &[u8] ) -> Result<(), Error>

Transfer data to SPI using DMA.

source

pub async fn transfer_in_place(&mut self, words: &mut [u8]) -> Result<(), Error>

Transfer data in place to SPI using DMA.

Trait Implementations§

source§

impl<'d, T: Instance, M: Mode> ErrorType for Spi<'d, T, M>

§

type Error = Error

Error type.
source§

impl<'d, T: Instance, M: Mode> SetConfig for Spi<'d, T, M>

§

type Config = Config

The configuration type used by this driver.
§

type ConfigError = ()

The error type that can occur if set_config fails.
source§

fn set_config(&mut self, config: &Self::Config) -> Result<(), ()>

Set the configuration of the driver.
source§

impl<'d, T: Instance> SpiBus for Spi<'d, T, Async>

source§

async fn flush(&mut self) -> Result<(), Self::Error>

Wait until all operations have completed and the bus is idle. Read more
source§

async fn write(&mut self, words: &[u8]) -> Result<(), Self::Error>

Write words to the slave, ignoring all the incoming words. Read more
source§

async fn read(&mut self, words: &mut [u8]) -> Result<(), Self::Error>

Read words from the slave. Read more
source§

async fn transfer( &mut self, read: &mut [u8], write: &[u8] ) -> Result<(), Self::Error>

Write and read simultaneously. write is written to the slave on MOSI and words received on MISO are stored in read. Read more
source§

async fn transfer_in_place( &mut self, words: &mut [u8] ) -> Result<(), Self::Error>

Write and read simultaneously. The contents of words are written to the slave, and the received words are stored into the same words buffer, overwriting it. Read more
source§

impl<'d, T: Instance, M: Mode> SpiBus for Spi<'d, T, M>

source§

fn flush(&mut self) -> Result<(), Self::Error>

Wait until all operations have completed and the bus is idle. Read more
source§

fn read(&mut self, words: &mut [u8]) -> Result<(), Self::Error>

Read words from the slave. Read more
source§

fn write(&mut self, words: &[u8]) -> Result<(), Self::Error>

Write words to the slave, ignoring all the incoming words. Read more
source§

fn transfer(&mut self, read: &mut [u8], write: &[u8]) -> Result<(), Self::Error>

Write and read simultaneously. write is written to the slave on MOSI and words received on MISO are stored in read. Read more
source§

fn transfer_in_place(&mut self, words: &mut [u8]) -> Result<(), Self::Error>

Write and read simultaneously. The contents of words are written to the slave, and the received words are stored into the same words buffer, overwriting it. Read more
source§

impl<'d, T: Instance, M: Mode> Transfer<u8> for Spi<'d, T, M>

§

type Error = Error

Error type
source§

fn transfer<'w>(&mut self, words: &'w mut [u8]) -> Result<&'w [u8], Self::Error>

Sends words to the slave. Returns the words received from the slave
source§

impl<'d, T: Instance, M: Mode> Write<u8> for Spi<'d, T, M>

§

type Error = Error

Error type
source§

fn write(&mut self, words: &[u8]) -> Result<(), Self::Error>

Sends words to the slave, ignoring all the incoming words

Auto Trait Implementations§

§

impl<'d, T, M> Freeze for Spi<'d, T, M>
where T: Freeze,

§

impl<'d, T, M> RefUnwindSafe for Spi<'d, T, M>

§

impl<'d, T, M> Send for Spi<'d, T, M>
where T: Send, M: Send,

§

impl<'d, T, M> Sync for Spi<'d, T, M>
where T: Sync, M: Sync,

§

impl<'d, T, M> Unpin for Spi<'d, T, M>
where T: Unpin, M: Unpin,

§

impl<'d, T, M> !UnwindSafe for Spi<'d, T, M>

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

source§

fn az<Dst>(self) -> Dst
where T: Cast<Dst>,

Casts the value.
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<Src, Dst> CastFrom<Src> for Dst
where Src: Cast<Dst>,

source§

fn cast_from(src: Src) -> Dst

Casts the value.
source§

impl<T> CheckedAs for T

source§

fn checked_as<Dst>(self) -> Option<Dst>
where T: CheckedCast<Dst>,

Casts the value.
source§

impl<Src, Dst> CheckedCastFrom<Src> for Dst
where Src: CheckedCast<Dst>,

source§

fn checked_cast_from(src: Src) -> Option<Dst>

Casts the value.
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<Src, Dst> LosslessTryInto<Dst> for Src
where Dst: LosslessTryFrom<Src>,

source§

fn lossless_try_into(self) -> Option<Dst>

Performs the conversion.
source§

impl<Src, Dst> LossyInto<Dst> for Src
where Dst: LossyFrom<Src>,

source§

fn lossy_into(self) -> Dst

Performs the conversion.
source§

impl<T> OverflowingAs for T

source§

fn overflowing_as<Dst>(self) -> (Dst, bool)
where T: OverflowingCast<Dst>,

Casts the value.
source§

impl<Src, Dst> OverflowingCastFrom<Src> for Dst
where Src: OverflowingCast<Dst>,

source§

fn overflowing_cast_from(src: Src) -> (Dst, bool)

Casts the value.
source§

impl<T> Same for T

§

type Output = T

Should always be Self
source§

impl<T> SaturatingAs for T

source§

fn saturating_as<Dst>(self) -> Dst
where T: SaturatingCast<Dst>,

Casts the value.
source§

impl<Src, Dst> SaturatingCastFrom<Src> for Dst
where Src: SaturatingCast<Dst>,

source§

fn saturating_cast_from(src: Src) -> Dst

Casts the value.
source§

impl<T, U> TryFrom<U> for T
where 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 T
where 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> UnwrappedAs for T

source§

fn unwrapped_as<Dst>(self) -> Dst
where T: UnwrappedCast<Dst>,

Casts the value.
source§

impl<Src, Dst> UnwrappedCastFrom<Src> for Dst
where Src: UnwrappedCast<Dst>,

source§

fn unwrapped_cast_from(src: Src) -> Dst

Casts the value.
source§

impl<T> WrappingAs for T

source§

fn wrapping_as<Dst>(self) -> Dst
where T: WrappingCast<Dst>,

Casts the value.
source§

impl<Src, Dst> WrappingCastFrom<Src> for Dst
where Src: WrappingCast<Dst>,

source§

fn wrapping_cast_from(src: Src) -> Dst

Casts the value.