ARMmbed / mbed-os

Arm Mbed OS is a platform operating system designed for the internet of things
https://mbed.com
Other
4.68k stars 2.98k forks source link

STM32 - HAL_I2C_ErrorCallback - error 'handle' undeclared #14696

Closed ladislas closed 3 years ago

ladislas commented 3 years ago

Description of defect

Commit b5f864d96dd0f02a4e884b79a70d2a81e397663e introduced a bug for STM32 targets in HAL_I2C_ErrorCallback when DEVICE_I2CSLAVE is not defined.

../../extern/mbed-os/targets/TARGET_STM/i2c_api.c: In function 'HAL_I2C_ErrorCallback':
../../extern/mbed-os/targets/TARGET_STM/i2c_api.c:1082:10: error: 'handle' undeclared (first use in this function)
 1082 |     if ((handle->ErrorCode & HAL_I2C_ERROR_AF) == HAL_I2C_ERROR_AF) {
      |          ^~~~~~

I can provide a fix, but I don't know if the handle should be defined outside of the #if or if the if() should be moved in the #if

Target(s) affected by this defect ?

STM32

Toolchain(s) (name and version) displaying this defect ?

gcc version 10.2.1 20201103 (release) (GNU Arm Embedded Toolchain 10-2020-q4-major)

What version of Mbed-os are you using (tag or sha) ?

mbed-os-6.11.0

What version(s) of tools are you using. List all that apply (E.g. mbed-cli)

7.15.0

How is this defect reproduced ?

Compile code using I2C on STM32 targets, e.g. DISCO_F769

cc @jeromecoutant @affrinpinhero-2356

ladislas commented 3 years ago

I tracked the bug to the fact that I have the following in my custom target

"device_has_remove": [
      "I2CSLAVE"
],

Removing the entry fixed the issue. That being said, it should still not be a bug if you don't want to use I2CSLAVE