Struct embassy_nrf::spim::Spim
source · pub struct Spim<'d, T: Instance> { /* private fields */ }
Expand description
SPIM driver.
Implementations§
source§impl<'d, T: Instance> Spim<'d, T>
impl<'d, T: Instance> Spim<'d, T>
sourcepub fn new(
spim: impl Peripheral<P = T> + 'd,
_irq: impl Binding<T::Interrupt, InterruptHandler<T>> + '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( spim: impl Peripheral<P = T> + 'd, _irq: impl Binding<T::Interrupt, InterruptHandler<T>> + '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 SPIM driver.
sourcepub fn new_txonly(
spim: impl Peripheral<P = T> + 'd,
_irq: impl Binding<T::Interrupt, InterruptHandler<T>> + 'd,
sck: impl Peripheral<P = impl GpioPin> + 'd,
mosi: impl Peripheral<P = impl GpioPin> + 'd,
config: Config
) -> Self
pub fn new_txonly( spim: impl Peripheral<P = T> + 'd, _irq: impl Binding<T::Interrupt, InterruptHandler<T>> + 'd, sck: impl Peripheral<P = impl GpioPin> + 'd, mosi: impl Peripheral<P = impl GpioPin> + 'd, config: Config ) -> Self
Create a new SPIM driver, capable of TX only (MOSI only).
sourcepub fn new_rxonly(
spim: impl Peripheral<P = T> + 'd,
_irq: impl Binding<T::Interrupt, InterruptHandler<T>> + 'd,
sck: impl Peripheral<P = impl GpioPin> + 'd,
miso: impl Peripheral<P = impl GpioPin> + 'd,
config: Config
) -> Self
pub fn new_rxonly( spim: impl Peripheral<P = T> + 'd, _irq: impl Binding<T::Interrupt, InterruptHandler<T>> + 'd, sck: impl Peripheral<P = impl GpioPin> + 'd, miso: impl Peripheral<P = impl GpioPin> + 'd, config: Config ) -> Self
Create a new SPIM driver, capable of RX only (MISO only).
sourcepub fn blocking_read(&mut self, data: &mut [u8]) -> Result<(), Error>
pub fn blocking_read(&mut self, data: &mut [u8]) -> Result<(), Error>
Reads data from the SPI bus without sending anything. Blocks until the buffer has been filled.
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>
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).
sourcepub fn blocking_transfer_from_ram(
&mut self,
read: &mut [u8],
write: &[u8]
) -> Result<(), Error>
pub fn blocking_transfer_from_ram( &mut self, read: &mut [u8], write: &[u8] ) -> Result<(), Error>
Same as blocking_transfer
but will fail instead of copying data into RAM. Consult the module level documentation to learn more.
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>
Simultaneously sends and receives data. Places the received data into the same buffer and blocks until the transmission is completed.
sourcepub fn blocking_write(&mut self, data: &[u8]) -> Result<(), Error>
pub fn blocking_write(&mut self, data: &[u8]) -> Result<(), 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).
sourcepub fn blocking_write_from_ram(&mut self, data: &[u8]) -> Result<(), Error>
pub fn blocking_write_from_ram(&mut self, data: &[u8]) -> Result<(), Error>
Same as blocking_write
but will fail instead of copying data into RAM. Consult the module level documentation to learn more.
sourcepub async fn read(&mut self, data: &mut [u8]) -> Result<(), Error>
pub async fn read(&mut self, data: &mut [u8]) -> Result<(), Error>
Reads data from the SPI bus without sending anything.
sourcepub async fn transfer(
&mut self,
read: &mut [u8],
write: &[u8]
) -> Result<(), Error>
pub async fn transfer( &mut self, read: &mut [u8], write: &[u8] ) -> Result<(), Error>
Simultaneously sends and receives data. If necessary, the write buffer will be copied into RAM (see struct description for detail).
sourcepub async fn transfer_from_ram(
&mut self,
read: &mut [u8],
write: &[u8]
) -> Result<(), Error>
pub async fn transfer_from_ram( &mut self, read: &mut [u8], write: &[u8] ) -> Result<(), Error>
Same as transfer
but will fail instead of copying data into RAM. Consult the module level documentation to learn more.
sourcepub async fn transfer_in_place(&mut self, data: &mut [u8]) -> Result<(), Error>
pub async fn transfer_in_place(&mut self, data: &mut [u8]) -> Result<(), Error>
Simultaneously sends and receives data. Places the received data into the same buffer.
Trait Implementations§
source§impl<'d, T: Instance> SetConfig for Spim<'d, T>
impl<'d, T: Instance> SetConfig for Spim<'d, T>
§type ConfigError = ()
type 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<'d, T: Instance> SpiBus<u8> for Spim<'d, T>
impl<'d, T: Instance> SpiBus<u8> for Spim<'d, T>
source§async fn flush(&mut self) -> Result<(), Error>
async fn flush(&mut self) -> Result<(), Error>
source§async fn read(&mut self, words: &mut [u8]) -> Result<(), Error>
async fn read(&mut self, words: &mut [u8]) -> Result<(), Error>
words
from the slave. Read moresource§async fn write(&mut self, data: &[u8]) -> Result<(), Error>
async fn write(&mut self, data: &[u8]) -> Result<(), Error>
words
to the slave, ignoring all the incoming words Read moresource§impl<'d, T: Instance> SpiBus<u8> for Spim<'d, T>
impl<'d, T: Instance> SpiBus<u8> for Spim<'d, T>
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 more