Skip to main content
Visitor II
November 11, 2019
Question

STM32L1 HAL has compatibility problems on I2C API.

  • November 11, 2019
  • 1 reply
  • 916 views

Hi.

I have found the STM32L1 HAL generated by CubeIDE doesn't have compatibility with the one generated by CubeMX.

For example, According to the UM1816 "Description of STM32L1 HAL and low-layer drivers", I2C has API like following :

HAL_I2C_Master_Sequential_Transmit_IT()

As I wrote, this is the right name in the User's Manual, and I was using this API with HAL generated by CubeMX.

But, this API causes compile error. The STM32L1 HAL. accept only following :

HAL_I2C_Master_Seq_Transmit_IT()

I checked HAL, and found the API name with "Sequential" is legacy. The problem is, ST doesn't define a compatibility macro in the stm32_hal_legacy.h for STM32L1 MCU.

This bug raises compatibility problems with existing code.

Attached zip file has project to demonstrate the problem. See line 100 of the main.c file. I have tested this project with following condition :

  • Ubuntu 16.04 LTS
  • STM32CubeIDE 1.0.2

This is severe problem. Please investigate and fix.

    This topic has been closed for replies.

    1 reply

    Technical Moderator
    November 13, 2019

    Hello @Takemasa​ ,

    The root cause of the issue (as you have already identified it) is that STM32L1 wasn't added in the defines related to I2C sequential transfer functions (stm32_hal_legacy.h):

    #if defined(STM32H7) || defined(STM32WB) || defined(STM32G0) || defined(STM32F4) || defined(STM32F7) || defined(STM32L0) || defined(STM32L4)
    #define HAL_I2C_Master_Sequential_Transmit_IT HAL_I2C_Master_Seq_Transmit_IT
    #define HAL_I2C_Master_Sequential_Receive_IT HAL_I2C_Master_Seq_Receive_IT
    #define HAL_I2C_Slave_Sequential_Transmit_IT HAL_I2C_Slave_Seq_Transmit_IT
    #define HAL_I2C_Slave_Sequential_Receive_IT HAL_I2C_Slave_Seq_Receive_IT
    #define HAL_I2C_Master_Sequential_Transmit_DMA HAL_I2C_Master_Seq_Transmit_DMA
    #define HAL_I2C_Master_Sequential_Receive_DMA HAL_I2C_Master_Seq_Receive_DMA
    #define HAL_I2C_Slave_Sequential_Transmit_DMA HAL_I2C_Slave_Seq_Transmit_DMA
    #define HAL_I2C_Slave_Sequential_Receive_DMA HAL_I2C_Slave_Seq_Receive_DMA
    #endif /* STM32H7 || STM32WB || STM32G0 || STM32F4 || STM32F7 || STM32L0 || STM32L4 */

    I'll report this issue internally. Thanks for bringing it to our attention.

    -Amel

    TakemasaAuthor
    Visitor II
    December 21, 2019

    Hi

    Thanks. Adding STM32L1 as conditional compile parameter fixed issue.

    By the way, I found also STM32F0 is missing. Please check and fix.

    Takemasa