pub struct Spi<'d, M, T = AnySpi> { /* private fields */ }Expand description
SPI peripheral driver
Implementations§
Source§impl<'d, M, T> Spi<'d, M, T>
impl<'d, M, T> Spi<'d, M, T>
Source§impl<M, T> Spi<'_, M, T>where
T: Instance,
impl<M, T> Spi<'_, M, T>where
T: Instance,
Sourcepub fn read_byte(&mut self) -> Result<u8, Error>
pub fn read_byte(&mut self) -> Result<u8, Error>
Read a byte from SPI.
Sends out a stuffing byte for every byte to read. This function doesn’t
perform flushing. If you want to read the response to something you
have written before, consider using Self::transfer instead.
Source§impl<'d> Spi<'d, Blocking>
impl<'d> Spi<'d, Blocking>
Sourcepub fn new(spi: impl Peripheral<P = impl Instance> + 'd) -> Spi<'d, Blocking>
pub fn new(spi: impl Peripheral<P = impl Instance> + 'd) -> Spi<'d, Blocking>
Constructs an SPI instance in 8bit dataframe mode.
Sourcepub fn new_with_config(
spi: impl Peripheral<P = impl Instance> + 'd,
config: Config,
) -> Spi<'d, Blocking>
pub fn new_with_config( spi: impl Peripheral<P = impl Instance> + 'd, config: Config, ) -> Spi<'d, Blocking>
Constructs an SPI instance in 8bit dataframe mode.
Sourcepub fn into_async(self) -> Spi<'d, Async>
pub fn into_async(self) -> Spi<'d, Async>
Converts the SPI instance into async mode.
Source§impl<'d> Spi<'d, Async>
impl<'d> Spi<'d, Async>
Sourcepub fn into_blocking(self) -> Spi<'d, Blocking>
pub fn into_blocking(self) -> Spi<'d, Blocking>
Converts the SPI instance into blocking mode.
Source§impl<'d, M, T> Spi<'d, M, T>where
T: Instance,
impl<'d, M, T> Spi<'d, M, T>where
T: Instance,
Sourcepub fn new_typed(spi: impl Peripheral<P = T> + 'd) -> Spi<'d, M, T>
pub fn new_typed(spi: impl Peripheral<P = T> + 'd) -> Spi<'d, M, T>
Constructs an SPI instance in 8bit dataframe mode.
Sourcepub fn new_typed_with_config(
spi: impl Peripheral<P = T> + 'd,
config: Config,
) -> Spi<'d, M, T>
pub fn new_typed_with_config( spi: impl Peripheral<P = T> + 'd, config: Config, ) -> Spi<'d, M, T>
Constructs an SPI instance in 8bit dataframe mode.
Sourcepub fn with_mosi<MOSI: PeripheralOutput>(
self,
mosi: impl Peripheral<P = MOSI> + 'd,
) -> Self
pub fn with_mosi<MOSI: PeripheralOutput>( self, mosi: impl Peripheral<P = MOSI> + 'd, ) -> Self
Assign the MOSI (Master Out Slave In) pin for the SPI instance.
Enables both input and output functionality for the pin, and connects it to the MOSI signal and SIO0 input signal.
Sourcepub fn with_miso<MISO: PeripheralOutput>(
self,
miso: impl Peripheral<P = MISO> + 'd,
) -> Self
pub fn with_miso<MISO: PeripheralOutput>( self, miso: impl Peripheral<P = MISO> + 'd, ) -> Self
Assign the MISO (Master In Slave Out) pin for the SPI instance.
Enables both input and output functionality for the pin, and connects it to the MISO signal and SIO1 input signal.
Sourcepub fn with_sck<SCK: PeripheralOutput>(
self,
sclk: impl Peripheral<P = SCK> + 'd,
) -> Self
pub fn with_sck<SCK: PeripheralOutput>( self, sclk: impl Peripheral<P = SCK> + 'd, ) -> Self
Assign the SCK (Serial Clock) pin for the SPI instance.
Sets the specified pin to push-pull output and connects it to the SPI clock signal.
Sourcepub fn with_cs<CS: PeripheralOutput>(
self,
cs: impl Peripheral<P = CS> + 'd,
) -> Self
pub fn with_cs<CS: PeripheralOutput>( self, cs: impl Peripheral<P = CS> + 'd, ) -> Self
Assign the CS (Chip Select) pin for the SPI instance.
Sets the specified pin to push-pull output and connects it to the SPI CS signal.
Sourcepub fn apply_config(&mut self, config: &Config) -> Result<(), ConfigError>
pub fn apply_config(&mut self, config: &Config) -> Result<(), ConfigError>
Change the bus configuration.
Source§impl<'d, M, T> Spi<'d, M, T>where
T: QspiInstance,
impl<'d, M, T> Spi<'d, M, T>where
T: QspiInstance,
Sourcepub fn with_sio2<SIO2: PeripheralOutput>(
self,
sio2: impl Peripheral<P = SIO2> + 'd,
) -> Selfwhere
T: QspiInstance,
pub fn with_sio2<SIO2: PeripheralOutput>(
self,
sio2: impl Peripheral<P = SIO2> + 'd,
) -> Selfwhere
T: QspiInstance,
Assign the SIO2 pin for the SPI instance.
Enables both input and output functionality for the pin, and connects it to the SIO2 output and input signals.
Sourcepub fn with_sio3<SIO3: PeripheralOutput>(
self,
sio3: impl Peripheral<P = SIO3> + 'd,
) -> Selfwhere
T: QspiInstance,
pub fn with_sio3<SIO3: PeripheralOutput>(
self,
sio3: impl Peripheral<P = SIO3> + 'd,
) -> Selfwhere
T: QspiInstance,
Assign the SIO3 pin for the SPI instance.
Enables both input and output functionality for the pin, and connects it to the SIO3 output and input signals.
Source§impl<M, T> Spi<'_, M, T>where
T: Instance,
impl<M, T> Spi<'_, M, T>where
T: Instance,
Sourcepub fn half_duplex_read(
&mut self,
data_mode: SpiDataMode,
cmd: Command,
address: Address,
dummy: u8,
buffer: &mut [u8],
) -> Result<(), Error>
pub fn half_duplex_read( &mut self, data_mode: SpiDataMode, cmd: Command, address: Address, dummy: u8, buffer: &mut [u8], ) -> Result<(), Error>
Half-duplex read.
Sourcepub fn half_duplex_write(
&mut self,
data_mode: SpiDataMode,
cmd: Command,
address: Address,
dummy: u8,
buffer: &[u8],
) -> Result<(), Error>
pub fn half_duplex_write( &mut self, data_mode: SpiDataMode, cmd: Command, address: Address, dummy: u8, buffer: &[u8], ) -> Result<(), Error>
Half-duplex write.
Trait Implementations§
Source§impl<M, T> FullDuplex for Spi<'_, M, T>where
T: Instance,
impl<M, T> FullDuplex for Spi<'_, M, T>where
T: Instance,
Source§impl<M, T> SetConfig for Spi<'_, M, T>
impl<M, T> SetConfig for Spi<'_, M, T>
Source§type ConfigError = ConfigError
type ConfigError = ConfigError
set_config fails.Source§fn set_config(&mut self, config: &Self::Config) -> Result<(), Self::ConfigError>
fn set_config(&mut self, config: &Self::Config) -> Result<(), Self::ConfigError>
Source§impl<M, T> SpiBus for Spi<'_, M, T>where
T: Instance,
impl<M, T> SpiBus for Spi<'_, M, T>where
T: Instance,
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§fn transfer(&mut self, read: &mut [u8], write: &[u8]) -> Result<(), Self::Error>
fn transfer(&mut self, read: &mut [u8], write: &[u8]) -> Result<(), Self::Error>
write is written to the slave on MOSI and
words received on MISO are stored in read. Read more