This driver requires the STM32 device specific HAL and STM32CubeMX (CubeMX) initialization code generator. The driver instance is mapped to hardware as shown in the table below:
CMSIS Driver Instance | STM32 Hardware Resource |
---|---|
Driver_SPI1 | SPI1 |
Driver_SPI2 | SPI2 |
Driver_SPI3 | SPI3 |
Driver_SPI4 | SPI4 |
Driver_SPI5 | SPI5 |
Driver_SPI6 | SPI6 |
Driver_SPI7 | SPI7 |
Driver_SPI8 | SPI8 |
This driver has the following deviations from the CMSIS-Driver specification:
Conceptual deviations:
main.c
.Functional deviations:
This driver requires the following configuration in CubeMX:
Notes
- configuration information in the MX_Device.h file is based on CubeMX configuration.
- Hardware or Software Slave Select functionality is only available if NSS pin is configured in the CubeMX with alternate function Hardware NSS Signal.
- DMA configuration can differ between devices series so configure DMA as required by the used device.
- for DMA usage on devices with cache, ensure that data buffers for Send and Receive functions are in non-cacheable memory, or ensure that memory for send is updated (cache clean) before Send function is called and that memory containing received data is updated after the reception finishes (cache invalidate).
- some DMA controllers can only access specific memories, so ensure that proper memory is used for the buffers according to the DMA requirement.
Pin | Functionality |
---|---|
PF6 | SPI5_NSS |
PF7 | SPI5_SCK |
PF8 | SPI5_MISO |
PF9 | SPI5_MOSI |
Under Categories: Connectivity select SPI5:
Mode:
Configuration:
Pin Name | Signal on Pin | Pin Context.. | GPIO output.. | GPIO mode | GPIO Pull-up/Pull.. | Maximum out.. | Fast Mode | User Label |
---|---|---|---|---|---|---|---|---|
PF6 | SPI5_NSS | n/a | n/a | Alternate Function Push Pull | No pull-up and no.. | Medium | n/a | . |
PF7 | SPI5_SCK | n/a | n/a | Alternate Function Push Pull | No pull-up and no.. | Medium | n/a | . |
PF8 | SPI5_MISO | n/a | n/a | Alternate Function Push Pull | No pull-up and no.. | Medium | n/a | . |
PF9 | SPI5_MOSI | n/a | n/a | Alternate Function Push Pull | No pull-up and no.. | Medium | n/a | . |
Under Categories: System Core select DMA (might be different on other device series, or for some peripherals might be BDMA):
Configuration:
DMA1, DMA2:
Click on Add button and add DMA Requests as in table below:
DMA Request | Stream | Direction | Priority |
---|---|---|---|
SPI5_RX | DMA1 Stream 0 | Peripheral to Memory | Low |
SPI5_TX | DMA1 Stream 1 | Memory to Peripheral | Low |
Under Categories: System Core select NVIC:
Configuration:
NVIC Interrupt Table | Enabled | Preemption Priority | Sub Priority |
---|---|---|---|
DMA1 stream0 global interrupt | checked | 0 | 0 |
DMA1 stream1 global interrupt | checked | 0 | 0 |
SPI5 global interrupt | checked | 0 | 0 |
Enabled interrupt table | Select for.. | Generate Enable in.. | Generate IRQ h.. | Call HAL handler |
---|---|---|---|---|
DMA1 stream0 global interrupt | unchecked | checked | checked | checked |
DMA1 stream1 global interrupt | unchecked | checked | checked | checked |
SPI5 global interrupt | unchecked | checked | checked | checked |
Under Advanced Settings:
Generated Function Calls:
Generate Code | Function Name | Peripheral Inst.. | Do not generate .. | Visibility (Static) |
---|---|---|---|---|
checked | MX_SPI5_Init | SPI5 | unchecked | checked |