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

This commit is contained in:
Siwei Xu 2023-07-07 21:11:14 +08:00 committed by guo
parent fefffcf363
commit 6a9973cf19
3 changed files with 37 additions and 8 deletions

View File

@ -23,7 +23,7 @@ if GetDepend(['RT_USING_I2C', 'RT_USING_I2C_BITOPS']):
src += ['drv_soft_i2c.c'] src += ['drv_soft_i2c.c']
if GetDepend(['RT_USING_I2C']): 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'] src += ['drv_i2c.c']
if GetDepend(['BSP_USING_SDIO1']): if GetDepend(['BSP_USING_SDIO1']):

View File

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

View File

@ -155,6 +155,20 @@ menu "On-chip Peripheral Drivers"
range 1 113 range 1 113
default 49 default 49
endif 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 config BSP_USING_HW_I2C6
bool "Enable I2C6 Bus (User I2C)" bool "Enable I2C6 Bus (User I2C)"
default n default n