pub struct Spi<SPI, Pins, Word = u8> { /* private fields */ }
Expand description
SPI peripheral operating in full duplex master mode
Implementations§
Source§impl<SPI, Sck, Miso, Mosi, WORD> Spi<SPI, (Sck, Miso, Mosi), WORD>
impl<SPI, Sck, Miso, Mosi, WORD> Spi<SPI, (Sck, Miso, Mosi), WORD>
Sourcepub fn new<Config>(
spi: SPI,
pins: (Sck, Miso, Mosi),
config: Config,
clocks: Clocks,
apb: &mut <SPI as RccBus>::Bus,
) -> Self
pub fn new<Config>( spi: SPI, pins: (Sck, Miso, Mosi), config: Config, clocks: Clocks, apb: &mut <SPI as RccBus>::Bus, ) -> Self
Configures the SPI peripheral to operate in full duplex master mode.
The most convinient way to get a device is like that:
use stm32f3xx_hal::prelude::*;
use stm32f3xx_hal::spi::Spi;
// ...
let spi = Spi::new(dp.SPI1, (sck_pin, mosi_pin, miso_pin), 1.MHz, clocks, &mut dp.abp1);
To get a better example, look here.
Sourcepub unsafe fn peripheral(&mut self) -> &mut SPI
pub unsafe fn peripheral(&mut self) -> &mut SPI
Get access to the underlying register block.
§Safety
This function is not memory unsafe per se, but does not guarantee anything about assumptions of invariants made in this implementation.
Changing specific options can lead to un-expected behavior and nothing is guaranteed.
Sourcepub fn free(self) -> (SPI, (Sck, Miso, Mosi))
pub fn free(self) -> (SPI, (Sck, Miso, Mosi))
Releases the SPI peripheral and associated pins
Source§impl<SPI, Pins, Word> Spi<SPI, Pins, Word>where
SPI: Instance,
impl<SPI, Pins, Word> Spi<SPI, Pins, Word>where
SPI: Instance,
Sourcepub fn reclock(&mut self, freq: impl Into<Generic<u32>>, clocks: Clocks)
pub fn reclock(&mut self, freq: impl Into<Generic<u32>>, clocks: Clocks)
Change the baud rate of the SPI
Sourcepub fn interrupt(&self) -> <SPI as InterruptNumber>::Interrupt
pub fn interrupt(&self) -> <SPI as InterruptNumber>::Interrupt
Obtain the associated interrupt number for the serial peripheral.
Used to unmask / enable the interrupt with cortex_m::peripheral::NVIC::unmask()
.
This is useful for all cortex_m::peripheral::INTERRUPT
functions.