HAL SPI Overview

Introducing SPI

group SPI_Introduction

  • This introduction is under development.

Module and files

The following diagram illustrates the SPI module and its associated files.

Module and files diagram

Component diagram

The following diagram illustrates the software components involved in the SPI module. It shows the interactions between the user application, HAL drivers, low-level drivers, and the hardware components.



@startuml

<style>

componentDiagram {

   arrow {

      FontSize 8

   }

}

</style>



title SPI Software Component Diagram



package "HAL" {

    [HAL_SERVICE]

    [HAL_SPI]

    [HAL_DMA]

}



package "Low Layer" {

    [LL_SPI]

    [CMSIS]

    [SPI Interrupt routine service]

    [DMA Interrupt routine service]

}



package "HW" {

    [STM32_HW]

}



[Appli] --> [HAL_SPI] : HAL SPI API

[Appli] <-- [HAL_SPI] : SPI callback

[HAL_SPI] --> [LL_SPI] : LL SPI API

[HAL_SPI] -r-> [HAL_DMA] : HAL DMA_Start_IT\nHAL_DMA_Abort_IT

[HAL_SPI] -l-> [HAL_SERVICE] : HAL_GetTick

[HAL_SPI] <-- [SPI Interrupt routine service]

[HAL_SPI] <-r- [HAL_DMA]:Half transfer complete\nTransfer complete\nError

[LL_SPI] --> [CMSIS]:SPI register def

[HAL_DMA] <-d- [DMA Interrupt routine service]

[STM32_HW] -u--> [SPI Interrupt routine service]: SPIx Irq

[STM32_HW] -u--> [DMA Interrupt routine service] : DMA Channel Irq

[STM32_HW] <-u-- [LL_SPI] : SPI registers R/W

@enduml

Configuration table

The following table lists the configuration defines for the HAL SPI module, specifying their locations, default values, and descriptions:

group SPI_Configuration_Table

Configuration inside the SPI driver:

Config defines

Where

Default value

Note

USE_HAL_SPI_MODULE

hal_conf.h

1U

Enable the HAL SPI module.

USE_HAL_SPI_DMA

hal_conf.h

1U

Enable the use of DMA in the HAL driver

USE_HAL_SPI_GET_LAST_ERRORS

hal_conf.h

0U

Enable retrieving last processes error codes

USE_HAL_SPI_REGISTER_CALLBACKS

hal_conf.h

0U

Enable the register callbacks assert

USE_HAL_SPI_USER_DATA

hal_conf.h

0U

Add an user data inside HAL SPI handle

USE_HAL_SPI_CRC

hal_conf.h

1U

Enable the use of CRC feature inside driver

USE_HAL_SPI_CLK_ENABLE_MODEL

hal_conf.h

HAL_CLK_ENABLE_NO

Enable peripheral clock inside the HAL_SPI_Init

USE_HAL_CHECK_PARAM

hal_conf.h

0U

Enable checking of vital parameters at runtime

USE_HAL_MUTEX

hal_conf.h

0U

Enable the use of semaphore in the HAL driver

USE_ASSERT_DBG_PARAM

PreProcessor env

NA

Enable the params assert

USE_ASSERT_DBG_STATE

PreProcessor env

NA

Enable the state assert