Module stm32f1xx_hal::spi
source · Expand description
Serial Peripheral Interface
To construct the SPI instances, use the Spi::spiX
functions.
The pin parameter is a tuple containing (sck, miso, mosi)
which should be configured as (Alternate<...>, Input<...>, Alternate<...>)
.
As some STM32F1xx chips have 5V tolerant SPI pins, it is also possible to configure Sck and Mosi outputs as Alternate<PushPull>
. Then
a simple Pull-Up to 5V can be used to use SPI on a 5V bus without a level shifter.
You can also use NoSck
, NoMiso
or NoMosi
if you don’t want to use the pins
SPI1
can use(PA5, PA6, PA7)
or(PB3, PB4, PB5)
.SPI2
can use(PB13, PB14, PB15)
SPI3
can use(PB3, PB4, PB5)
or only in connectivity line devices(PC10, PC11, PC12)
Initialisation example
// Acquire the GPIOB peripheral
let mut gpiob = dp.GPIOB.split();
let pins = (
gpiob.pb13.into_alternate_push_pull(&mut gpiob.crh),
gpiob.pb14.into_floating_input(&mut gpiob.crh),
gpiob.pb15.into_alternate_push_pull(&mut gpiob.crh),
);
let spi_mode = Mode {
polarity: Polarity::IdleLow,
phase: Phase::CaptureOnFirstTransition,
};
let spi = Spi::spi2(dp.SPI2, pins, spi_mode, 100.khz(), clocks);
Structs
Spi in Master mode (type state)
SPI mode
A filler type for when the Miso pin is unnecessary
A filler type for when the Mosi pin is unnecessary
A filler type for when the SCK pin is unnecessary
Spi in Slave mode (type state)
Enums
SPI error
Interrupt event
Clock phase
Clock polarity
The bit format to send the data in