pub struct Spi<'d, M: Mode> { /* private fields */ }Expand description
SPI driver.
Implementations§
Source§impl<'d, M: Mode> Spi<'d, M>
impl<'d, M: Mode> Spi<'d, M>
Sourcepub fn blocking_write(&mut self, data: &[u8]) -> Result<(), Error>
pub fn blocking_write(&mut self, data: &[u8]) -> Result<(), Error>
Write data to SPI blocking execution until done.
Sourcepub fn blocking_transfer_in_place(
&mut self,
data: &mut [u8],
) -> Result<(), Error>
pub fn blocking_transfer_in_place( &mut self, data: &mut [u8], ) -> Result<(), Error>
Transfer data in place to SPI blocking execution until done.
Sourcepub fn blocking_read(&mut self, data: &mut [u8]) -> Result<(), Error>
pub fn blocking_read(&mut self, data: &mut [u8]) -> Result<(), Error>
Read data from SPI blocking execution until done.
Sourcepub fn blocking_transfer(
&mut self,
read: &mut [u8],
write: &[u8],
) -> Result<(), Error>
pub fn blocking_transfer( &mut self, read: &mut [u8], write: &[u8], ) -> Result<(), Error>
Transfer data to SPI blocking execution until done.
Sourcepub fn blocking_flush(&mut self) -> Result<(), Error>
pub fn blocking_flush(&mut self) -> Result<(), Error>
Block execution until SPI is done.
Sourcepub fn set_frequency(&mut self, freq: Hertz) -> Result<(), ConfigError>
pub fn set_frequency(&mut self, freq: Hertz) -> Result<(), ConfigError>
Set SPI frequency.
Sourcepub fn set_config(&mut self, config: &Config) -> Result<(), ConfigError>
pub fn set_config(&mut self, config: &Config) -> Result<(), ConfigError>
Set SPI config.
Source§impl<'d> Spi<'d, Blocking>
impl<'d> Spi<'d, Blocking>
Sourcepub fn new_blocking<T: Instance>(
spi: Peri<'d, T>,
clk: Peri<'d, impl ClkPin<T> + 'd>,
mosi: Peri<'d, impl MosiPin<T> + 'd>,
miso: Peri<'d, impl MisoPin<T> + 'd>,
config: Config,
) -> Result<Self, ConfigError>
pub fn new_blocking<T: Instance>( spi: Peri<'d, T>, clk: Peri<'d, impl ClkPin<T> + 'd>, mosi: Peri<'d, impl MosiPin<T> + 'd>, miso: Peri<'d, impl MisoPin<T> + 'd>, config: Config, ) -> Result<Self, ConfigError>
Create an SPI driver in blocking mode.
Sourcepub fn new_blocking_txonly<T: Instance>(
spi: Peri<'d, T>,
clk: Peri<'d, impl ClkPin<T> + 'd>,
mosi: Peri<'d, impl MosiPin<T> + 'd>,
config: Config,
) -> Result<Self, ConfigError>
pub fn new_blocking_txonly<T: Instance>( spi: Peri<'d, T>, clk: Peri<'d, impl ClkPin<T> + 'd>, mosi: Peri<'d, impl MosiPin<T> + 'd>, config: Config, ) -> Result<Self, ConfigError>
Create an SPI driver in blocking mode supporting writes only.
Sourcepub fn new_blocking_txonly_nosck<T: Instance>(
spi: Peri<'d, T>,
mosi: Peri<'d, impl MosiPin<T> + 'd>,
config: Config,
) -> Result<Self, ConfigError>
pub fn new_blocking_txonly_nosck<T: Instance>( spi: Peri<'d, T>, mosi: Peri<'d, impl MosiPin<T> + 'd>, config: Config, ) -> Result<Self, ConfigError>
Create an SPI driver in blocking mode supporting writes only, without SCK pin.
Source§impl<'d> Spi<'d, Async>
impl<'d> Spi<'d, Async>
Sourcepub fn new<T: Instance, TxDma: ChannelInstance, RxDma: ChannelInstance>(
spi: Peri<'d, T>,
clk: Peri<'d, impl ClkPin<T> + 'd>,
mosi: Peri<'d, impl MosiPin<T> + 'd>,
miso: Peri<'d, impl MisoPin<T> + 'd>,
tx_dma: Peri<'d, TxDma>,
rx_dma: Peri<'d, RxDma>,
irq: impl Binding<TxDma::Interrupt, InterruptHandler<TxDma>> + Binding<RxDma::Interrupt, InterruptHandler<RxDma>> + 'd,
config: Config,
) -> Result<Self, ConfigError>
pub fn new<T: Instance, TxDma: ChannelInstance, RxDma: ChannelInstance>( spi: Peri<'d, T>, clk: Peri<'d, impl ClkPin<T> + 'd>, mosi: Peri<'d, impl MosiPin<T> + 'd>, miso: Peri<'d, impl MisoPin<T> + 'd>, tx_dma: Peri<'d, TxDma>, rx_dma: Peri<'d, RxDma>, irq: impl Binding<TxDma::Interrupt, InterruptHandler<TxDma>> + Binding<RxDma::Interrupt, InterruptHandler<RxDma>> + 'd, config: Config, ) -> Result<Self, ConfigError>
Create an SPI driver in async mode supporting DMA operations.
Sourcepub fn new_txonly<T: Instance, TxDma: ChannelInstance>(
spi: Peri<'d, T>,
clk: Peri<'d, impl ClkPin<T> + 'd>,
mosi: Peri<'d, impl MosiPin<T> + 'd>,
tx_dma: Peri<'d, TxDma>,
irq: impl Binding<TxDma::Interrupt, InterruptHandler<TxDma>> + 'd,
config: Config,
) -> Result<Self, ConfigError>
pub fn new_txonly<T: Instance, TxDma: ChannelInstance>( spi: Peri<'d, T>, clk: Peri<'d, impl ClkPin<T> + 'd>, mosi: Peri<'d, impl MosiPin<T> + 'd>, tx_dma: Peri<'d, TxDma>, irq: impl Binding<TxDma::Interrupt, InterruptHandler<TxDma>> + 'd, config: Config, ) -> Result<Self, ConfigError>
Create an SPI driver in async mode supporting DMA write operations only.
Sourcepub fn new_txonly_nosck<T: Instance, TxDma: ChannelInstance>(
spi: Peri<'d, T>,
mosi: Peri<'d, impl MosiPin<T> + 'd>,
tx_dma: Peri<'d, TxDma>,
irq: impl Binding<TxDma::Interrupt, InterruptHandler<TxDma>> + 'd,
config: Config,
) -> Result<Self, ConfigError>
pub fn new_txonly_nosck<T: Instance, TxDma: ChannelInstance>( spi: Peri<'d, T>, mosi: Peri<'d, impl MosiPin<T> + 'd>, tx_dma: Peri<'d, TxDma>, irq: impl Binding<TxDma::Interrupt, InterruptHandler<TxDma>> + 'd, config: Config, ) -> Result<Self, ConfigError>
Create an SPI driver in async mode supporting DMA write operations only, without SCK pin.
Sourcepub fn new_rxonly<T: Instance, TxDma: ChannelInstance, RxDma: ChannelInstance>(
spi: Peri<'d, T>,
clk: Peri<'d, impl ClkPin<T> + 'd>,
miso: Peri<'d, impl MisoPin<T> + 'd>,
tx_dma: Peri<'d, TxDma>,
rx_dma: Peri<'d, RxDma>,
irq: impl Binding<TxDma::Interrupt, InterruptHandler<TxDma>> + Binding<RxDma::Interrupt, InterruptHandler<RxDma>> + 'd,
config: Config,
) -> Result<Self, ConfigError>
pub fn new_rxonly<T: Instance, TxDma: ChannelInstance, RxDma: ChannelInstance>( spi: Peri<'d, T>, clk: Peri<'d, impl ClkPin<T> + 'd>, miso: Peri<'d, impl MisoPin<T> + 'd>, tx_dma: Peri<'d, TxDma>, rx_dma: Peri<'d, RxDma>, irq: impl Binding<TxDma::Interrupt, InterruptHandler<TxDma>> + Binding<RxDma::Interrupt, InterruptHandler<RxDma>> + 'd, config: Config, ) -> Result<Self, ConfigError>
Create an SPI driver in async mode supporting DMA read operations only.
Sourcepub async fn read(&mut self, buffer: &mut [u8]) -> Result<(), Error>
pub async fn read(&mut self, buffer: &mut [u8]) -> Result<(), Error>
Read data from SPI using DMA.
Trait Implementations§
Source§impl<'d, M: Mode> SetConfig for Spi<'d, M>
impl<'d, M: Mode> SetConfig for Spi<'d, M>
Source§type ConfigError = ConfigError
type ConfigError = ConfigError
set_config fails.Source§fn set_config(&mut self, config: &Self::Config) -> Result<(), ConfigError>
fn set_config(&mut self, config: &Self::Config) -> Result<(), ConfigError>
Source§impl<'d, M: Mode> SpiBus for Spi<'d, M>
impl<'d, M: Mode> SpiBus for Spi<'d, M>
Source§fn flush(&mut self) -> Result<(), Self::Error>
fn flush(&mut self) -> Result<(), Self::Error>
Source§fn read(&mut self, words: &mut [u8]) -> Result<(), Self::Error>
fn read(&mut self, words: &mut [u8]) -> Result<(), Self::Error>
words from the slave. Read moreSource§fn write(&mut self, words: &[u8]) -> Result<(), Self::Error>
fn write(&mut self, words: &[u8]) -> Result<(), Self::Error>
words to the slave, ignoring all the incoming words. Read moreSource§impl<'d> SpiBus for Spi<'d, Async>
impl<'d> SpiBus for Spi<'d, Async>
Source§async fn flush(&mut self) -> Result<(), Self::Error>
async fn flush(&mut self) -> Result<(), Self::Error>
Source§async fn write(&mut self, words: &[u8]) -> Result<(), Self::Error>
async fn write(&mut self, words: &[u8]) -> Result<(), Self::Error>
words to the slave, ignoring all the incoming words. Read moreSource§async fn read(&mut self, words: &mut [u8]) -> Result<(), Self::Error>
async fn read(&mut self, words: &mut [u8]) -> Result<(), Self::Error>
words from the slave. Read more