Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 37 additions & 13 deletions bsp/Infineon/libraries/HAL_Drivers/drv_i2c.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,18 @@
#include "board.h"

#if defined(RT_USING_I2C)
#if defined(BSP_USING_HW_I2C3) || defined(BSP_USING_HW_I2C4) || defined(BSP_USING_HW_I2C6)
#if defined(BSP_USING_HW_I2C2) || defined(BSP_USING_HW_I2C3) || defined(BSP_USING_HW_I2C4)|| defined(BSP_USING_HW_I2C6)
#include <rtdevice.h>

#ifndef I2C2_CONFIG
#define I2C2_CONFIG \
{ \
.name = "i2c2", \
.scl_pin = BSP_I2C2_SCL_PIN, \
.sda_pin = BSP_I2C2_SDA_PIN, \
}
#endif /* I2C2_CONFIG */

#ifndef I2C3_CONFIG
#define I2C3_CONFIG \
{ \
Expand All @@ -40,11 +49,13 @@
.sda_pin = BSP_I2C6_SDA_PIN, \
}
#endif /* I2C6_CONFIG */

#endif /* defined(BSP_USING_I2C1) || defined(BSP_USING_I2C2) */

enum
{
#ifdef BSP_USING_HW_I2C2
I2C2_INDEX,
#endif
#ifdef BSP_USING_HW_I2C3
I2C3_INDEX,
#endif
Expand Down Expand Up @@ -72,17 +83,21 @@ struct ifx_i2c
};

static struct ifx_i2c_config i2c_config[] =
{
{
#ifdef BSP_USING_HW_I2C2
I2C2_CONFIG,
#endif

#ifdef BSP_USING_HW_I2C3
I2C3_CONFIG,
I2C3_CONFIG,
#endif

#ifdef BSP_USING_HW_I2C4
I2C4_CONFIG,
I2C4_CONFIG,
#endif

#ifdef BSP_USING_HW_I2C6
I2C6_CONFIG,
I2C6_CONFIG,
#endif
};

Expand Down Expand Up @@ -145,20 +160,29 @@ static rt_ssize_t _i2c_xfer(struct rt_i2c_bus_device *bus, struct rt_i2c_msg msg
}

static const struct rt_i2c_bus_device_ops i2c_ops =
{
_i2c_xfer,
RT_NULL,
RT_NULL};
{
_i2c_xfer,
RT_NULL,
RT_NULL
};

void HAL_I2C_Init(struct ifx_i2c *obj)
{
rt_uint8_t result = RT_EOK;
cy_rslt_t result = CY_RSLT_SUCCESS;

result = cyhal_i2c_init(&obj->mI2C, obj->config->sda_pin, obj->config->scl_pin, NULL);
RT_ASSERT(result == RT_EOK);
if (result != CY_RSLT_SUCCESS)
{
rt_kprintf("hal i2c init fail!\n");
return;
}

result = cyhal_i2c_configure(&obj->mI2C, &obj->mI2C_cfg);
RT_ASSERT(result == RT_EOK);
if (result != CY_RSLT_SUCCESS)
{
rt_kprintf("hal i2c configure fail!\n");
return;
}
}

int rt_hw_i2c_init(void)
Expand Down
35 changes: 11 additions & 24 deletions bsp/Infineon/psoc6-evaluationkit-062S2/board/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ menu "Onboard Peripheral Drivers"
select BSP_USING_UART
select BSP_USING_UART6
default y

endmenu

menu "On-chip Peripheral Drivers"
Expand Down Expand Up @@ -141,19 +142,19 @@ menu "On-chip Peripheral Drivers"
select RT_USING_I2C
select RT_USING_PIN
if BSP_USING_HW_I2C
config BSP_USING_HW_I2C3
bool "Enable I2C3 Bus (User I2C)"
config BSP_USING_HW_I2C2
bool "Enable I2C2 Bus (User I2C)"
default n
if BSP_USING_HW_I2C3
comment "Notice: P6_0 --> 48; P6_1 --> 49"
config BSP_I2C3_SCL_PIN
int "i2c3 SCL pin number"
if BSP_USING_HW_I2C2
comment "Notice: P3_0 --> 24; P3_1 --> 25"
config BSP_I2C2_SCL_PIN
int "i2c2 SCL pin number"
range 1 113
default 48
config BSP_I2C3_SDA_PIN
int "i2c3 SDA pin number"
default 24
config BSP_I2C2_SDA_PIN
int "i2c2 SDA pin number"
range 1 113
default 49
default 25
endif
config BSP_USING_HW_I2C4
bool "Enable I2C4 Bus (Arduino I2C)"
Expand All @@ -169,20 +170,6 @@ menu "On-chip Peripheral Drivers"
range 1 113
default 65
endif
config BSP_USING_HW_I2C6
bool "Enable I2C6 Bus (User I2C)"
default n
if BSP_USING_HW_I2C6
comment "Notice: P13_0 --> 48; P13_1 --> 49"
config BSP_I2C6_SCL_PIN
int "i2c6 SCL pin number"
range 1 113
default 104
config BSP_I2C6_SDA_PIN
int "i2c6 SDA pin number"
range 1 113
default 105
endif
endif

menuconfig BSP_USING_I2C
Expand Down
2 changes: 1 addition & 1 deletion bsp/Infineon/psoc6-evaluationkit-062S2/board/board.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
#define IFX_EFLASH_END_ADDRESS ((uint32_t)(IFX_EFLASH_START_ADRESS + IFX_EFLASH_SIZE))

/*SRAM CONFIG*/
#define IFX_SRAM_SIZE (1013)
#define IFX_SRAM_SIZE (1010)
#define IFX_SRAM_END (0x08002000 + IFX_SRAM_SIZE * 1024)

#ifdef __ARMCC_VERSION
Expand Down