From e5c90232af198889f32aa77f2df9a636b326b22f Mon Sep 17 00:00:00 2001 From: Jeonghyun Kim Date: Wed, 10 Feb 2021 23:32:21 +0900 Subject: [PATCH] board: nucleo-l432kc: Add I2C3 registering logic on app init I2C3 hasn't been registered on /dev because registering logic cares about only I2C1, not I2C3. So, added I2C3 on it. --- .../stm32l4/nucleo-l432kc/src/stm32_appinit.c | 29 +++++++++++++++---- 1 file changed, 24 insertions(+), 5 deletions(-) diff --git a/boards/arm/stm32l4/nucleo-l432kc/src/stm32_appinit.c b/boards/arm/stm32l4/nucleo-l432kc/src/stm32_appinit.c index bbe75916217..c3dae0b5003 100644 --- a/boards/arm/stm32l4/nucleo-l432kc/src/stm32_appinit.c +++ b/boards/arm/stm32l4/nucleo-l432kc/src/stm32_appinit.c @@ -71,7 +71,7 @@ ****************************************************************************/ #undef HAVE_I2C_DRIVER -#if defined(CONFIG_STM32L4_I2C1) && defined(CONFIG_I2C_DRIVER) +#if (defined(CONFIG_STM32L4_I2C1) || defined(CONFIG_STM32L4_I2C3)) && defined(CONFIG_I2C_DRIVER) # define HAVE_I2C_DRIVER 1 #endif @@ -190,11 +190,11 @@ int board_app_initialize(uintptr_t arg) } #endif -#ifdef HAVE_I2C_DRIVER +#ifdef CONFIG_STM32L4_I2C1 /* Get the I2C lower half instance */ - i2c = stm32l4_i2cbus_initialize(1); - if (i2c == NULL) + i2c1 = stm32l4_i2cbus_initialize(1); + if (i2c1 == NULL) { i2cerr("ERROR: Initialize I2C1: %d\n", ret); } @@ -202,7 +202,7 @@ int board_app_initialize(uintptr_t arg) { /* Register the I2C character driver */ - ret = i2c_register(i2c, 1); + ret = i2c_register(i2c1, 1); if (ret < 0) { i2cerr("ERROR: Failed to register I2C1 device: %d\n", ret); @@ -210,6 +210,25 @@ int board_app_initialize(uintptr_t arg) } #endif +#ifdef CONFIG_STM32L4_I2C3 + /* Get the I2C lower half instance */ + i2c3 = stm32l4_i2cbus_initialize(3); + if (i2c3 == NULL) + { + i2cerr("ERROR: Initialize I2C3: %d\n", ret); + } + else + { + /* Register the I2C character driver */ + + ret = i2c_register(i2c3, 3); + if (ret < 0) + { + i2cerr("ERROR: Failed to register I2C3 device: %d\n", ret); + } + } +#endif + #ifdef HAVE_AT45DB /* Initialize and register the ATDB FLASH file system. */