pub struct Spi<SPI: Instance, W, PULL = Floating> { /* private fields */ }
Expand description
Spi in Master mode
Implementations§
Source§impl<SPI: Instance, PULL: UpMode> Spi<SPI, u8, PULL>
impl<SPI: Instance, PULL: UpMode> Spi<SPI, u8, PULL>
Sourcepub fn new<const R: u8>(
spi: impl Into<Rmp<SPI, R>>,
pins: (Option<impl RInto<SPI::MSck, R>>, Option<impl RInto<SPI::Mi<PULL>, R>>, Option<impl RInto<SPI::Mo, R>>),
mode: Mode,
freq: Hertz,
rcc: &mut Rcc,
) -> Self
pub fn new<const R: u8>( spi: impl Into<Rmp<SPI, R>>, pins: (Option<impl RInto<SPI::MSck, R>>, Option<impl RInto<SPI::Mi<PULL>, R>>, Option<impl RInto<SPI::Mo, R>>), mode: Mode, freq: Hertz, rcc: &mut Rcc, ) -> Self
Constructs an SPI instance using SPI1 in 8bit dataframe mode.
The pin parameter tuple (sck, miso, mosi) should be (PA5, PA6, PA7)
or (PB3, PB4, PB5)
configured as (Alternate<PushPull>, Input<...>, Alternate<PushPull>)
.
You can also use NoSck
, NoMiso
or NoMosi
if you don’t want to use the pins
Source§impl<SPI: Instance, PULL> Spi<SPI, u8, PULL>
impl<SPI: Instance, PULL> Spi<SPI, u8, PULL>
Sourcepub fn frame_size_16bit(self) -> Spi<SPI, u16, PULL>
pub fn frame_size_16bit(self) -> Spi<SPI, u16, PULL>
Converts from 8bit dataframe to 16bit.
Source§impl<SPI: Instance, PULL> Spi<SPI, u16, PULL>
impl<SPI: Instance, PULL> Spi<SPI, u16, PULL>
Sourcepub fn frame_size_8bit(self) -> Spi<SPI, u16, PULL>
pub fn frame_size_8bit(self) -> Spi<SPI, u16, PULL>
Converts from 16bit dataframe to 8bit.
Methods from Deref<Target = SpiInner<SPI, W>>§
Sourcepub fn bit_format(&mut self, format: SpiBitFormat)
pub fn bit_format(&mut self, format: SpiBitFormat)
Select which frame format is used for data transfers
Sourcepub fn listen(&mut self, event: Event)
pub fn listen(&mut self, event: Event)
Starts listening to the SPI by enabling the Received data ready to be read (RXNE) interrupt and Transmit data register empty (TXE) interrupt
Sourcepub fn unlisten(&mut self, event: Event)
pub fn unlisten(&mut self, event: Event)
Stops listening to the SPI by disabling the Received data ready to be read (RXNE) interrupt and Transmit data register empty (TXE) interrupt
Sourcepub fn is_tx_empty(&self) -> bool
pub fn is_tx_empty(&self) -> bool
Returns true if the tx register is empty (and can accept data)
Sourcepub fn is_rx_not_empty(&self) -> bool
pub fn is_rx_not_empty(&self) -> bool
Returns true if the rx register is not empty (and can be read)
Sourcepub fn is_overrun(&self) -> bool
pub fn is_overrun(&self) -> bool
Returns true if data are received and the previous data have not yet been read from SPI_DR.
pub fn read_nonblocking(&mut self) -> Result<W, Error>
pub fn write_nonblocking(&mut self, data: W) -> Result<(), Error>
pub fn write(&mut self, words: &[W]) -> Result<(), Error>
pub fn transfer_in_place(&mut self, words: &mut [W]) -> Result<(), Error>
pub fn transfer(&mut self, buff: &mut [W], data: &[W]) -> Result<(), Error>
pub fn flush(&mut self) -> Result<(), Error>
pub fn read(&mut self, words: &mut [W]) -> Result<(), Error>
Trait Implementations§
Source§impl<SPI, W, PULL> FullDuplex<W> for Spi<SPI, W, PULL>
impl<SPI, W, PULL> FullDuplex<W> for Spi<SPI, W, PULL>
Source§impl<SPI, W, PULL> SpiBus<W> for Spi<SPI, W, PULL>
impl<SPI, W, PULL> SpiBus<W> for Spi<SPI, W, PULL>
Source§fn transfer_in_place(&mut self, words: &mut [W]) -> Result<(), Self::Error>
fn transfer_in_place(&mut self, words: &mut [W]) -> Result<(), Self::Error>
words
are
written to the slave, and the received words are stored into the same
words
buffer, overwriting it. Read moreSource§fn transfer(&mut self, buff: &mut [W], data: &[W]) -> Result<(), Self::Error>
fn transfer(&mut self, buff: &mut [W], data: &[W]) -> Result<(), Self::Error>
write
is written to the slave on MOSI and
words received on MISO are stored in read
. Read moreSource§fn read(&mut self, words: &mut [W]) -> Result<(), Self::Error>
fn read(&mut self, words: &mut [W]) -> Result<(), Self::Error>
words
from the slave. Read more