HAL I2C Overview

Introducing I2C

group I2C_Introduction

  • This introduction is under development.

Module and files

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

Module and files diagram

Component diagram

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



#if !defined(GENERATOR_SYSCFG_CLOCK_ENABLE_REQUIRED)



@startuml

<style>

componentDiagram {

   arrow {

      FontSize 8

   }

}

</style>



title I2C Software Component Diagram



package "HAL" {

    [HAL_SERVICE]

    [HAL_I2C]

    [HAL_DMA]

}



package "Low Layer" {

    [LL_I2C]

    [CMSIS]

    [I2C Interrupt routine service]

    [DMA Interrupt routine service]

}



package "HW" {

    [STM32_HW]

}



[Appli] --> [HAL_I2C] : HAL I2C API

[Appli] <-- [HAL_I2C] : I2C callback

[HAL_I2C] --> [LL_I2C] : LL I2C API

[HAL_I2C] -r-> [HAL_DMA] : Configure DMA

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

[HAL_I2C] <-- [I2C Interrupt routine service]

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

[LL_I2C] --> [CMSIS]:I2C register def

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

[STM32_HW] -u--> [I2C Interrupt routine service]: I2Cx Irq

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

[STM32_HW] <-u-- [LL_I2C] : I2C registers R/W

@enduml

#else

@startuml

<style>

componentDiagram {

   arrow {

      FontSize 8

   }

}

</style>



title I2C Software Component Diagram



package "HAL" {

    [HAL_SERVICE]

    [HAL_I2C]

    [HAL_DMA]

}



package "Low Layer" {

    [LL_I2C]

    [LL_SYSTEM_SYSCFG]

    [CMSIS]

    [I2C Interrupt routine service]

    [DMA Interrupt routine service]

}



package "HW" {

    [STM32_HW]

}



[Appli] --> [HAL_I2C] : HAL I2C API

[Appli] <-- [HAL_I2C] : I2C callback

[HAL_I2C] --> [LL_I2C] : LL I2C API

[HAL_I2C] --> [LL_SYSTEM_SYSCFG] : LL SYSCFG API

[HAL_I2C] -r-> [HAL_DMA] : Configure DMA

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

[HAL_I2C] <-- [I2C Interrupt routine service]

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

[LL_I2C] --> [CMSIS]:I2C register def

[LL_SYSTEM_SYSCFG] --> [CMSIS]: SYSCFG register def

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

[STM32_HW] -u--> [I2C Interrupt routine service]: I2Cx Irq

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

[STM32_HW] <-u-- [LL_I2C] : I2C registers R/W

[STM32_HW] <-u-- [LL_SYSTEM_SYSCFG] : SYSCFG registers R/W

@enduml



#endif

Configuration table

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

group I2C_Configuration_Table

  1. Configuration inside the I2C driver

Config defines

Description

Default value

Note

USE_HAL_I2C_CLK_ENABLE_MODEL

stm32u5xx_hal_conf.h

HAL_CLK_ENABLE_NO

Enable the gating of the periph clk

USE_HAL_I2C_MODULE

stm32u5xx_hal_conf.h

1

When set, HAL I2C module is enabled

USE_HAL_I2C_DMA

stm32u5xx_hal_conf.h

1

Enable DMA code inside I2C

USE_HAL_I2C_GET_LAST_ERRORS

stm32u5xx_hal_conf.h

0

Enable the get last process error

USE_HAL_I2C_USER_DATA

stm32u5xx_hal_conf.h

0

Enable the set/get user data

USE_HAL_I2C_REGISTER_CALLBACKS

stm32u5xx_hal_conf.h

0

Enable the register callbacks assert

USE_HAL_CHECK_PARAM

stm32u5xx_hal_conf.h

0

Parameters (pointers or sizes) are checked in runtime

USE_HAL_CHECK_PROCESS_STATE

stm32u5xx_hal_conf.h

0

Enable atomic access to process state check

USE_HAL_CHECK_PROCESS_STATE

stm32u5xx_hal_conf.h

0

Check the HAL I2C state transition in run time

USE_HAL_MUTEX

stm32u5xx_hal_conf.h

0

Enable the acquire/release bus services

USE_ASSERT_DBG_PARAM

from PreProcessor env

NA

Enable the params assert

USE_ASSERT_DBG_STATE

from PreProcessor env

NA

Enable the state assert