Struct stm32f7xx_hal::spi::Spi [−][src]
pub struct Spi<I, P, State> { /* fields omitted */ }
Expand description
Entry point to the SPI API
Implementations
pub fn enable<Word>(
self,
apb: &mut <I as RccBus>::Bus,
clock_divider: ClockDivider,
mode: Mode
) -> Spi<I, P, Enabled<Word>> where
Word: SupportedWordSize,
pub fn enable<Word>(
self,
apb: &mut <I as RccBus>::Bus,
clock_divider: ClockDivider,
mode: Mode
) -> Spi<I, P, Enabled<Word>> where
Word: SupportedWordSize,
Initialize the SPI peripheral
pub fn transfer_all<B>(
self,
buffer: Pin<B>,
dma_rx: &Handle<<Rx<I> as Target>::Instance, Enabled>,
dma_tx: &Handle<<Tx<I> as Target>::Instance, Enabled>,
rx: <Rx<I> as Target>::Stream,
tx: <Tx<I> as Target>::Stream
) -> Transfer<Word, I, P, B, Rx<I>, Tx<I>, Ready> where
Rx<I>: Target,
Tx<I>: Target,
B: DerefMut + 'static,
B::Target: AsMutSlice<Element = Word>,
pub fn transfer_all<B>(
self,
buffer: Pin<B>,
dma_rx: &Handle<<Rx<I> as Target>::Instance, Enabled>,
dma_tx: &Handle<<Tx<I> as Target>::Instance, Enabled>,
rx: <Rx<I> as Target>::Stream,
tx: <Tx<I> as Target>::Stream
) -> Transfer<Word, I, P, B, Rx<I>, Tx<I>, Ready> where
Rx<I>: Target,
Tx<I>: Target,
B: DerefMut + 'static,
B::Target: AsMutSlice<Element = Word>,
Start an SPI transfer using DMA
Sends the data in buffer
and writes the received data into buffer
right after. Returns a Transfer
, to represent the ongoing SPI
transfer.
Please note that the word “transfer” is used with two different meanings here:
- An SPI transfer, as in an SPI transaction that involves both sending and receiving data. The method name refers to this kind of transfer.
- A DMA transfer, as in an ongoing DMA operation. The name of the return type refers to this kind of transfer.
This method, as well as all other DMA-related methods in this module, requires references to two DMA handles, one each for the RX and TX streams. This will actually always be the same handle, as each SPI instance uses the same DMA instance for both sending and receiving. It would be nice to simplify that, but I believe that requires an equality constraint in the where clause, which is not supported yet by the compiler.
Trait Implementations
impl<I, P, Word> FullDuplex<Word> for Spi<I, P, Enabled<Word>> where
I: Instance,
P: Pins<I>,
Word: SupportedWordSize,
impl<I, P, Word> FullDuplex<Word> for Spi<I, P, Enabled<Word>> where
I: Instance,
P: Pins<I>,
Word: SupportedWordSize,
impl<I, P, Word> Default<Word> for Spi<I, P, Enabled<Word>> where
I: Instance,
P: Pins<I>,
Word: SupportedWordSize,
Auto Trait Implementations
impl<I, P, State> RefUnwindSafe for Spi<I, P, State> where
I: RefUnwindSafe,
P: RefUnwindSafe,
State: RefUnwindSafe,
impl<I, P, State> UnwindSafe for Spi<I, P, State> where
I: UnwindSafe,
P: UnwindSafe,
State: UnwindSafe,
Blanket Implementations
Mutably borrows from an owned value. Read more
type Output = T
type Output = T
Should always be Self
type Error = <S as FullDuplex<W>>::Error
type Error = <S as FullDuplex<W>>::Error
Error type
pub fn transfer(
&mut self,
words: &'w mut [W]
) -> Result<&'w [W], <S as FullDuplex<W>>::Error>
pub fn transfer(
&mut self,
words: &'w mut [W]
) -> Result<&'w [W], <S as FullDuplex<W>>::Error>
Sends words
to the slave. Returns the words
received from the slave
type Error = <S as FullDuplex<W>>::Error
type Error = <S as FullDuplex<W>>::Error
Error type
type Error = <S as FullDuplex<W>>::Error
type Error = <S as FullDuplex<W>>::Error
Error type
pub fn write_iter<WI>(
&mut self,
words: WI
) -> Result<(), <S as FullDuplex<W>>::Error> where
WI: IntoIterator<Item = W>,
pub fn write_iter<WI>(
&mut self,
words: WI
) -> Result<(), <S as FullDuplex<W>>::Error> where
WI: IntoIterator<Item = W>,
Sends words
to the slave, ignoring all the incoming words