cancel
Showing results for 
Search instead for 
Did you mean: 

How to link stm32l4xx_hal_i2c.c with stm32l4xx_hal_i2c.h?

Yu LU
Associate II
Posted on August 14, 2017 at 16:32

Hello, I am using STM32Cube lib to development my project which include both spi and i2c communication.

So I develop the project based on the SPI example in STM32Cube example package.

However the initial project do not include stm32l4xx_hal_i2c.c and  stm32l4xx_hal_i2c.h. So I added them by right click the project driver group to add the two files into project. The path is well reveiwed. there is no problem with path. .h from inc and .c from src folder.

However, the 

stm32l4xx_hal_i2c is added,  but its dependancies do not include stm32l4xx_hal_i2c.h. And the project can not be built successfully. Showing  :

STM32L432KC_NUCLEO\STM32L432KC_NUCLEO.axf: Error: L6218E: Undefined symbol HAL_I2C_Init (referred from hsensor_i2c.o).

STM32L432KC_NUCLEO\STM32L432KC_NUCLEO.axf: Error: L6218E: Undefined symbol HAL_I2C_Master_Receive_IT (referred from hsensor_i2c.o).

HAL_I2C_Master_Receive_IT and HAL_I2C_Init are both from stm32l4xx_hal_i2c.h.

0690X00000607lyQAA.png

Could any one help me with this ? Is there configuration files to be modified ?

Thank you!

Yu LU

1 REPLY 1
Amel NASRI
ST Employee
Posted on August 15, 2017 at 13:33

Hi

‌,

You have to enable the I2C modules in the file stm32l4xx_hal_conf.h:

#define HAL_I2C_MODULE_ENABLED�?

You may check some ready to use examples available in the Cube package underSTM32Cube_FW_L4_V1.8.0\Projects\STM32L432KC-Nucleo\Examples\I2C.

-Amel

To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.