pub struct Spis<'d, T: Instance> { /* private fields */ }
Expand description
SPIS driver.
Implementations§
Source§impl<'d, T: Instance> Spis<'d, T>
impl<'d, T: Instance> Spis<'d, T>
Sourcepub fn new(
spis: impl Peripheral<P = T> + 'd,
_irq: impl Binding<T::Interrupt, InterruptHandler<T>> + 'd,
cs: impl Peripheral<P = impl GpioPin> + 'd,
sck: impl Peripheral<P = impl GpioPin> + 'd,
miso: impl Peripheral<P = impl GpioPin> + 'd,
mosi: impl Peripheral<P = impl GpioPin> + 'd,
config: Config,
) -> Self
pub fn new( spis: impl Peripheral<P = T> + 'd, _irq: impl Binding<T::Interrupt, InterruptHandler<T>> + 'd, cs: impl Peripheral<P = impl GpioPin> + 'd, sck: impl Peripheral<P = impl GpioPin> + 'd, miso: impl Peripheral<P = impl GpioPin> + 'd, mosi: impl Peripheral<P = impl GpioPin> + 'd, config: Config, ) -> Self
Create a new SPIS driver.
Sourcepub fn new_txonly(
spis: impl Peripheral<P = T> + 'd,
_irq: impl Binding<T::Interrupt, InterruptHandler<T>> + 'd,
cs: impl Peripheral<P = impl GpioPin> + 'd,
sck: impl Peripheral<P = impl GpioPin> + 'd,
miso: impl Peripheral<P = impl GpioPin> + 'd,
config: Config,
) -> Self
pub fn new_txonly( spis: impl Peripheral<P = T> + 'd, _irq: impl Binding<T::Interrupt, InterruptHandler<T>> + 'd, cs: impl Peripheral<P = impl GpioPin> + 'd, sck: impl Peripheral<P = impl GpioPin> + 'd, miso: impl Peripheral<P = impl GpioPin> + 'd, config: Config, ) -> Self
Create a new SPIS driver, capable of TX only (MISO only).
Sourcepub fn new_rxonly(
spis: impl Peripheral<P = T> + 'd,
_irq: impl Binding<T::Interrupt, InterruptHandler<T>> + 'd,
cs: impl Peripheral<P = impl GpioPin> + 'd,
sck: impl Peripheral<P = impl GpioPin> + 'd,
mosi: impl Peripheral<P = impl GpioPin> + 'd,
config: Config,
) -> Self
pub fn new_rxonly( spis: impl Peripheral<P = T> + 'd, _irq: impl Binding<T::Interrupt, InterruptHandler<T>> + 'd, cs: impl Peripheral<P = impl GpioPin> + 'd, sck: impl Peripheral<P = impl GpioPin> + 'd, mosi: impl Peripheral<P = impl GpioPin> + 'd, config: Config, ) -> Self
Create a new SPIS driver, capable of RX only (MOSI only).
Sourcepub fn new_txonly_nosck(
spis: impl Peripheral<P = T> + 'd,
_irq: impl Binding<T::Interrupt, InterruptHandler<T>> + 'd,
cs: impl Peripheral<P = impl GpioPin> + 'd,
miso: impl Peripheral<P = impl GpioPin> + 'd,
config: Config,
) -> Self
pub fn new_txonly_nosck( spis: impl Peripheral<P = T> + 'd, _irq: impl Binding<T::Interrupt, InterruptHandler<T>> + 'd, cs: impl Peripheral<P = impl GpioPin> + 'd, miso: impl Peripheral<P = impl GpioPin> + 'd, config: Config, ) -> Self
Create a new SPIS driver, capable of TX only (MISO only) without SCK pin.
Sourcepub fn blocking_read(&mut self, data: &mut [u8]) -> Result<usize, Error>
pub fn blocking_read(&mut self, data: &mut [u8]) -> Result<usize, Error>
Reads data from the SPI bus without sending anything. Blocks until cs
is deasserted.
Returns number of bytes read.
Sourcepub fn blocking_transfer(
&mut self,
read: &mut [u8],
write: &[u8],
) -> Result<(usize, usize), Error>
pub fn blocking_transfer( &mut self, read: &mut [u8], write: &[u8], ) -> Result<(usize, usize), Error>
Simultaneously sends and receives data. Blocks until the transmission is completed.
If necessary, the write buffer will be copied into RAM (see struct description for detail).
Returns number of bytes transferred (n_rx, n_tx)
.
Sourcepub fn blocking_transfer_from_ram(
&mut self,
read: &mut [u8],
write: &[u8],
) -> Result<(usize, usize), Error>
pub fn blocking_transfer_from_ram( &mut self, read: &mut [u8], write: &[u8], ) -> Result<(usize, usize), Error>
Same as blocking_transfer
but will fail instead of copying data into RAM. Consult the module level documentation to learn more.
Returns number of bytes transferred (n_rx, n_tx)
.
Sourcepub fn blocking_transfer_in_place(
&mut self,
data: &mut [u8],
) -> Result<usize, Error>
pub fn blocking_transfer_in_place( &mut self, data: &mut [u8], ) -> Result<usize, Error>
Simultaneously sends and receives data. Places the received data into the same buffer and blocks until the transmission is completed. Returns number of bytes transferred.
Sourcepub fn blocking_write(&mut self, data: &[u8]) -> Result<usize, Error>
pub fn blocking_write(&mut self, data: &[u8]) -> Result<usize, Error>
Sends data, discarding any received data. Blocks until the transmission is completed. If necessary, the write buffer will be copied into RAM (see struct description for detail). Returns number of bytes written.
Sourcepub fn blocking_write_from_ram(&mut self, data: &[u8]) -> Result<usize, Error>
pub fn blocking_write_from_ram(&mut self, data: &[u8]) -> Result<usize, Error>
Same as blocking_write
but will fail instead of copying data into RAM. Consult the module level documentation to learn more.
Returns number of bytes written.
Sourcepub async fn read(&mut self, data: &mut [u8]) -> Result<usize, Error>
pub async fn read(&mut self, data: &mut [u8]) -> Result<usize, Error>
Reads data from the SPI bus without sending anything. Returns number of bytes read.
Sourcepub async fn transfer(
&mut self,
read: &mut [u8],
write: &[u8],
) -> Result<(usize, usize), Error>
pub async fn transfer( &mut self, read: &mut [u8], write: &[u8], ) -> Result<(usize, usize), Error>
Simultaneously sends and receives data.
If necessary, the write buffer will be copied into RAM (see struct description for detail).
Returns number of bytes transferred (n_rx, n_tx)
.
Sourcepub async fn transfer_from_ram(
&mut self,
read: &mut [u8],
write: &[u8],
) -> Result<(usize, usize), Error>
pub async fn transfer_from_ram( &mut self, read: &mut [u8], write: &[u8], ) -> Result<(usize, usize), Error>
Same as transfer
but will fail instead of copying data into RAM. Consult the module level documentation to learn more.
Returns number of bytes transferred (n_rx, n_tx)
.
Sourcepub async fn transfer_in_place(
&mut self,
data: &mut [u8],
) -> Result<usize, Error>
pub async fn transfer_in_place( &mut self, data: &mut [u8], ) -> Result<usize, Error>
Simultaneously sends and receives data. Places the received data into the same buffer. Returns number of bytes transferred.
Sourcepub async fn write(&mut self, data: &[u8]) -> Result<usize, Error>
pub async fn write(&mut self, data: &[u8]) -> Result<usize, Error>
Sends data, discarding any received data. If necessary, the write buffer will be copied into RAM (see struct description for detail). Returns number of bytes written.
Sourcepub async fn write_from_ram(&mut self, data: &[u8]) -> Result<usize, Error>
pub async fn write_from_ram(&mut self, data: &[u8]) -> Result<usize, Error>
Same as write
but will fail instead of copying data into RAM. Consult the module level documentation to learn more.
Returns number of bytes written.
Sourcepub fn is_overread(&mut self) -> bool
pub fn is_overread(&mut self) -> bool
Checks if last transaction overread.
Sourcepub fn is_overflow(&mut self) -> bool
pub fn is_overflow(&mut self) -> bool
Checks if last transaction overflowed.