HAL I2S Overview

Introducing I2S

group I2S_Introduction

  • The I2S hardware abstraction layer provides a set of APIs to interface with the STM32 I2S (Inter-integrated circuit sound) peripheral.

  • It simplifies the configuration, initialization, and management of I2S communication by supporting various modes such as polling, interrupt, and DMA for efficient data transfer.

  • This abstraction layer ensures portability and ease of use across different STM32 series.

Module and files

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

Module and files diagram

Component diagram

The following diagram illustrates the software components involved in the I2S 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 I2S Software Component Diagram

package "HAL" {
    [HAL_SERVICE]
    [HAL_I2S]
    [HAL_DMA]
}

package "Low Layer" {
    [LL_SPI]
    [CMSIS]
    [I2S Interrupt routine service]
    [DMA Interrupt routine service]
}

package "HW" {
    [STM32_HW]
}

[Appli] --> [HAL_I2S] : HAL I2S API
[Appli] <-- [HAL_I2S] : I2S callback
[HAL_I2S] --> [LL_SPI] : LL I2S API
[HAL_I2S] -r-> [HAL_DMA] : Configure DMA
[HAL_I2S] -l-> [HAL_SERVICE] : HAL_GetTick
[HAL_I2S] <-- [I2S Interrupt routine service]
[HAL_I2S] <-r- [HAL_DMA]:Half transfer complete\nTransfer complete\nError
[LL_SPI] --> [CMSIS]: I2S register def
[HAL_DMA] <-d- [DMA Interrupt routine service]
[STM32_HW] -u--> [I2S Interrupt routine service]: I2Sx Irq
[STM32_HW] -u--> [DMA Interrupt routine service] : DMA Channel Irq
[STM32_HW] <-u-- [LL_SPI] : I2S registers R/W
@enduml

Configuration table

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

group I2S_Configuration_Table

Configuration inside the I2S driver

Software configuration defined in stm32c5xx_hal_conf.h:

Preprocessor flags

Default value

Comment

USE_HAL_I2S_MODULE

1

Enable the HAL I2S driver module

USE_HAL_I2S_REGISTER_CALLBACKS

0

Allow an application to define a callback

USE_HAL_I2S_DMA

1

Enable the DMA code inside I2S

USE_HAL_CHECK_PARAM

0

Enable runtime parameter check

USE_HAL_I2S_CLK_ENABLE_MODEL

HAL_CLK_ENABLE_NO

Enable the gating of the peripheral clock

USE_HAL_MUTEX

0

Enable semaphore creation for OS

USE_HAL_I2S_USER_DATA

0

Add user data inside the HAL I2S handle

USE_HAL_I2S_GET_LAST_ERRORS

0

Enable retrieving last process error codes

USE_HAL_I2S_OVR_UDR_ERRORS

0

Enable retrieving overrun and underrun errors

Software configuration defined in preprocessor environment:

Preprocessor flags

Default value

Comment

USE_ASSERT_DBG_PARAM

Not defined

Enable parameter check for HAL and LL

USE_ASSERT_DBG_STATE

Not defined

Enable state check for HAL