1
0
Эх сурвалжийг харах

[bsp][Infineon] Add I2C4 config for psoc6-evaluationkit

Siwei Xu 2 жил өмнө
parent
commit
6a9973cf19

+ 1 - 1
bsp/Infineon/libraries/HAL_Drivers/SConscript

@@ -23,7 +23,7 @@ if GetDepend(['RT_USING_I2C', 'RT_USING_I2C_BITOPS']):
         src += ['drv_soft_i2c.c']
 
 if GetDepend(['RT_USING_I2C']):
-    if GetDepend('BSP_USING_HW_I2C3') or GetDepend('BSP_USING_HW_I2C6'):
+    if GetDepend('BSP_USING_HW_I2C3') or GetDepend('BSP_USING_HW_I2C4') or GetDepend('BSP_USING_HW_I2C6'):
         src += ['drv_i2c.c']
 
 if GetDepend(['BSP_USING_SDIO1']):

+ 22 - 7
bsp/Infineon/libraries/HAL_Drivers/drv_i2c.c

@@ -11,7 +11,7 @@
 #include "board.h"
 
 #if defined(RT_USING_I2C)
-#if defined(BSP_USING_HW_I2C3) || defined(BSP_USING_HW_I2C6)
+#if defined(BSP_USING_HW_I2C3) || defined(BSP_USING_HW_I2C4) || defined(BSP_USING_HW_I2C6)
 #include <rtdevice.h>
 
 #ifndef I2C3_CONFIG
@@ -22,7 +22,16 @@
         .sda_pin = BSP_I2C3_SDA_PIN, \
     }
 #endif /* I2C3_CONFIG */
-#endif
+
+#ifndef I2C4_CONFIG
+#define I2C4_CONFIG                  \
+    {                                \
+        .name = "i2c4",              \
+        .scl_pin = BSP_I2C4_SCL_PIN, \
+        .sda_pin = BSP_I2C4_SDA_PIN, \
+    }
+#endif /* I2C4_CONFIG */
+
 #ifndef I2C6_CONFIG
 #define I2C6_CONFIG                  \
     {                                \
@@ -32,11 +41,16 @@
     }
 #endif /* I2C6_CONFIG */
 
+#endif /* defined(BSP_USING_I2C1) || defined(BSP_USING_I2C2) */
+
 enum
 {
 #ifdef BSP_USING_HW_I2C3
     I2C3_INDEX,
 #endif
+#ifdef BSP_USING_HW_I2C4
+    I2C4_INDEX,
+#endif
 #ifdef BSP_USING_HW_I2C6
     I2C6_INDEX,
 #endif
@@ -63,6 +77,10 @@ static struct ifx_i2c_config i2c_config[] =
         I2C3_CONFIG,
 #endif
 
+#ifdef BSP_USING_HW_I2C4
+        I2C4_CONFIG,
+#endif
+
 #ifdef BSP_USING_HW_I2C6
         I2C6_CONFIG,
 #endif
@@ -145,8 +163,7 @@ void HAL_I2C_Init(struct ifx_i2c *obj)
 
 int rt_hw_i2c_init(void)
 {
-    rt_err_t result;
-    cyhal_i2c_t mI2C;
+    rt_err_t result = RT_EOK;
 
     for (int i = 0; i < sizeof(i2c_config) / sizeof(i2c_config[0]); i++)
     {
@@ -157,8 +174,6 @@ int rt_hw_i2c_init(void)
         i2c_objs[i].mI2C_cfg.address = 0;
         i2c_objs[i].mI2C_cfg.frequencyhal_hz = (400000UL);
 
-        i2c_objs[i].mI2C = mI2C;
-
         i2c_objs[i].i2c_bus.ops = &i2c_ops;
 
         HAL_I2C_Init(&i2c_objs[i]);
@@ -171,4 +186,4 @@ int rt_hw_i2c_init(void)
 }
 INIT_DEVICE_EXPORT(rt_hw_i2c_init);
 
-#endif /* defined(BSP_USING_I2C1) || defined(BSP_USING_I2C2) */
+#endif /* RT_USING_I2C */

+ 14 - 0
bsp/Infineon/psoc6-evaluationkit-062S2/board/Kconfig

@@ -155,6 +155,20 @@ menu "On-chip Peripheral Drivers"
                         range 1 113
                         default 49
                 endif
+            config BSP_USING_HW_I2C4
+                bool "Enable I2C4 Bus (Arduino I2C)"
+                default n
+                if BSP_USING_HW_I2C4
+                    comment "Notice: P8_0 --> 64; P8_1 --> 65"
+                    config BSP_I2C4_SCL_PIN
+                        int "i2c4 SCL pin number"
+                        range 1 113
+                        default 64
+                    config BSP_I2C4_SDA_PIN
+                        int "i2c4 SDA pin number"
+                        range 1 113
+                        default 65
+                endif
             config BSP_USING_HW_I2C6
                 bool "Enable I2C6 Bus (User I2C)"
                 default n