[bsp/bouffalo_lab]add drv_i2c (#7473)

This commit is contained in:
flyingcys 2023-05-11 10:12:20 +08:00 committed by GitHub
parent 4f8d45375b
commit 23f91e83ab
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 853 additions and 44 deletions

View File

@ -707,55 +707,277 @@ menu "General Drivers Configuration"
default n
endif
menu "General Purpose I2C"
menuconfig BSP_USING_I2C
bool "Enable I2C"
select RT_USING_I2C
default n
if BSP_USING_I2C
menuconfig BSP_USING_I2C0
bool "Enable I2C0"
default n
if BSP_USING_I2C0
choice
prompt "I2C0 SCL"
default I2C0_SCL_USING_GPIO14
config I2C0_SCL_USING_GPIO0
bool "GPIO_0"
config I2C0_SCL_USING_GPIO2
bool "GPIO_2"
config I2C0_SCL_USING_GPIO4
bool "GPIO_4"
config I2C0_SCL_USING_GPIO6
bool "GPIO_6"
config I2C0_SCL_USING_GPIO8
bool "GPIO_8"
config I2C0_SCL_USING_GPIO8
bool "GPIO_8"
config I2C0_SCL_USING_GPIO10
bool "GPIO_10"
config I2C0_SCL_USING_GPIO12
bool "GPIO_12"
config I2C0_SCL_USING_GPIO14
bool "GPIO_14"
config I2C0_SCL_USING_GPIO16
bool "GPIO_16"
config I2C0_SCL_USING_GPIO18
bool "GPIO_18"
config I2C0_SCL_USING_GPIO20
bool "GPIO_20"
config I2C0_SCL_USING_GPIO22
bool "GPIO_22"
config I2C0_SCL_USING_GPIO24
depends on BSP_USING_BL61X || BSP_USING_BL70X || BSP_USING_BL808
bool "GPIO_8"
config I2C0_SCL_USING_GPIO26
depends on BSP_USING_BL61X || BSP_USING_BL70X || BSP_USING_BL808
bool "GPIO_26"
config I2C0_SCL_USING_GPIO28
depends on BSP_USING_BL61X || BSP_USING_BL70X || BSP_USING_BL808
bool "GPIO_28"
config I2C0_SCL_USING_GPIO30
depends on BSP_USING_BL61X || BSP_USING_BL70X || BSP_USING_BL808
bool "GPIO_30"
config I2C0_SCL_USING_GPIO32
depends on BSP_USING_BL61X || BSP_USING_BL808
bool "GPIO_32"
config I2C0_SCL_USING_GPIO34
depends on BSP_USING_BL61X || BSP_USING_BL808
bool "GPIO_34"
config I2C0_SDA_USING_GPIO36
depends on BSP_USING_BL808
bool "GPIO_36"
config I2C0_SDA_USING_GPIO38
depends on BSP_USING_BL808
bool "GPIO_38"
config I2C0_SDA_USING_GPIO40
depends on BSP_USING_BL808
bool "GPIO_40"
config I2C1_SDA_USING_GPIO42
depends on BSP_USING_BL808
bool "GPIO_42"
config I2C0_SDA_USING_GPIO44
depends on BSP_USING_BL808
bool "GPIO_44"
endchoice
choice
prompt "I2C0 SDA"
default I2C0_SDA_USING_GPIO15
config I2C0_SDA_USING_GPIO1
bool "GPIO_1"
config I2C0_SDA_USING_GPIO3
bool "GPIO_3"
config I2C0_SDA_USING_GPIO5
bool "GPIO_5"
config I2C0_SDA_USING_GPIO7
bool "GPIO_7"
config I2C0_SDA_USING_GPIO9
bool "GPIO_9"
config I2C0_SDA_USING_GPIO11
bool "GPIO_11"
config I2C0_SDA_USING_GPIO13
bool "GPIO_13"
config I2C0_SDA_USING_GPIO15
bool "GPIO_15"
config I2C0_SDA_USING_GPIO17
bool "GPIO_17"
config I2C0_SDA_USING_GPIO19
bool "GPIO_19"
config I2C0_SDA_USING_GPIO21
bool "GPIO_21"
config I2C0_SDA_USING_GPIO23
depends on BSP_USING_BL61X || BSP_USING_BL70X || BSP_USING_BL808
bool "GPIO_23"
config I2C0_SDA_USING_GPIO25
depends on BSP_USING_BL61X || BSP_USING_BL70X || BSP_USING_BL808
bool "GPIO_25"
config I2C0_SDA_USING_GPIO27
depends on BSP_USING_BL61X || BSP_USING_BL70X || BSP_USING_BL808
bool "GPIO_27"
config I2C0_SDA_USING_GPIO29
depends on BSP_USING_BL61X || BSP_USING_BL70X || BSP_USING_BL808
bool "GPIO_29"
config I2C0_SDA_USING_GPIO31
depends on BSP_USING_BL61X || BSP_USING_BL70X || BSP_USING_BL808
bool "GPIO_31"
config I2C0_SDA_USING_GPIO33
depends on BSP_USING_BL61X || BSP_USING_BL808
bool "GPIO_33"
config I2C0_SDA_USING_GPIO35
depends on BSP_USING_BL808
bool "GPIO_35"
config I2C0_SDA_USING_GPIO37
depends on BSP_USING_BL808
bool "GPIO_37"
config I2C0_SDA_USING_GPIO39
depends on BSP_USING_BL808
bool "GPIO_39"
config I2C0_SDA_USING_GPIO41
depends on BSP_USING_BL808
bool "GPIO_41"
config I2C0_SDA_USING_GPIO43
depends on BSP_USING_BL808
bool "GPIO_43"
config I2C0_SDA_USING_GPIO45
depends on BSP_USING_BL808
bool "GPIO_45"
endchoice
config I2C0_FREQUENCY
int "I2C0 Frequency"
default 400000
endif
menuconfig BSP_USING_I2C1
depends on BSP_USING_BL61X || BSP_USING_BL808
bool "Enable I2C1"
default n
select BSP_USING_I2C
select RT_USING_I2C
select RT_USING_I2C_BITOPS
select RT_USING_PIN
if BSP_USING_I2C1
choice
prompt "I2C1 SCL PIN"
default I2C1_SCL_USING_GPIO4 if BSP_USING_BL60X
default I2C1_SCL_USING_GPIO10 if BSP_USING_BL61X
default I2C1_SCL_USING_GPIO08 if BSP_USING_BL70X
default I2C1_SCL_USING_GPIO20 if BSP_USING_BL808
prompt "I2C1 SCL"
default I2C1_SCL_USING_GPIO0
config I2C1_SCL_USING_GPIO0
bool "GPIO_0"
config I2C1_SCL_USING_GPIO2
bool "GPIO_2"
config I2C1_SCL_USING_GPIO4
bool "GPIO_4"
config I2C1_SCL_USING_GPIO6
bool "GPIO_6"
config I2C1_SCL_USING_GPIO8
bool "GPIO_8"
config I2C1_SCL_USING_GPIO8
bool "GPIO_8"
config I2C1_SCL_USING_GPIO10
bool "GPIO_10"
config I2C1_SCL_USING_GPIO12
bool "GPIO_12"
config I2C1_SCL_USING_GPIO14
bool "GPIO_14"
config I2C1_SCL_USING_GPIO16
bool "GPIO_16"
config I2C1_SCL_USING_GPIO18
bool "GPIO_18"
config I2C1_SCL_USING_GPIO20
bool "GPIO_20"
config I2C1_SCL_USING_GPIO22
bool "GPIO_22"
config I2C1_SCL_USING_GPIO24
bool "GPIO_8"
config I2C1_SCL_USING_GPIO26
bool "GPIO_26"
config I2C1_SCL_USING_GPIO28
bool "GPIO_28"
config I2C1_SCL_USING_GPIO30
bool "GPIO_30"
config I2C1_SCL_USING_GPIO32
bool "GPIO_32"
config I2C1_SCL_USING_GPIO34
bool "GPIO_34"
config I2C1_SDA_USING_GPIO36
depends on BSP_USING_BL808
bool "GPIO_36"
config I2C1_SDA_USING_GPIO38
depends on BSP_USING_BL808
bool "GPIO_38"
config I2C1_SDA_USING_GPIO40
depends on BSP_USING_BL808
bool "GPIO_40"
config I2C1_SDA_USING_GPIO42
depends on BSP_USING_BL808
bool "GPIO_42"
config I2C1_SDA_USING_GPIO44
depends on BSP_USING_BL808
bool "GPIO_44"
endchoice
choice
prompt "I2C1 SDA PIN"
default I2C1_SDA_USING_GPIO3 if BSP_USING_BL60X
default I2C1_SDA_USING_GPIO11 if BSP_USING_BL61X
default I2C1_SDA_USING_GPIO7 if BSP_USING_BL70X
default I2C1_SDA_USING_GPIO21 if BSP_USING_BL808
prompt "I2C1 SDA"
default I2C1_SDA_USING_GPIO1
config I2C1_SDA_USING_GPIO1
bool "GPIO_1"
config I2C1_SDA_USING_GPIO3
bool "GPIO_3"
config I2C1_SDA_USING_GPIO5
bool "GPIO_5"
config I2C1_SDA_USING_GPIO7
bool "GPIO_7"
config I2C1_SDA_USING_GPIO9
bool "GPIO_9"
config I2C1_SDA_USING_GPIO11
bool "GPIO_11"
config I2C1_SDA_USING_GPIO13
bool "GPIO_13"
config I2C1_SDA_USING_GPIO15
bool "GPIO_15"
config I2C1_SDA_USING_GPIO17
bool "GPIO_17"
config I2C1_SDA_USING_GPIO19
bool "GPIO_19"
config I2C1_SDA_USING_GPIO21
bool "GPIO_21"
config I2C1_SDA_USING_GPIO23
bool "GPIO_23"
config I2C1_SDA_USING_GPIO25
bool "GPIO_25"
config I2C1_SDA_USING_GPIO27
bool "GPIO_27"
config I2C1_SDA_USING_GPIO29
bool "GPIO_29"
config I2C1_SDA_USING_GPIO31
bool "GPIO_31"
config I2C1_SDA_USING_GPIO33
bool "GPIO_33"
config I2C1_SDA_USING_GPIO35
depends on BSP_USING_BL808
bool "GPIO_35"
config I2C1_SDA_USING_GPIO37
depends on BSP_USING_BL808
bool "GPIO_37"
config I2C1_SDA_USING_GPIO39
depends on BSP_USING_BL808
bool "GPIO_39"
config I2C1_SDA_USING_GPIO41
depends on BSP_USING_BL808
bool "GPIO_41"
config I2C1_SDA_USING_GPIO43
depends on BSP_USING_BL808
bool "GPIO_43"
config I2C1_SDA_USING_GPIO45
depends on BSP_USING_BL808
bool "GPIO_45"
endchoice
config I2C1_FREQUENCY
int "I2C1 Frequency"
default 400000
endif
endif
endmenu
menuconfig BSP_USING_SPI
bool "Enable SPI"
@ -1049,6 +1271,7 @@ menu "General Drivers Configuration"
range 0 4095
endif
endif
config BSP_USING_ON_CHIP_FLASH
bool "Enable On-Chip FLASH"
default n

View File

@ -10,7 +10,7 @@ if GetDepend('BSP_USING_GPIO'):
src += ['drv_gpio.c']
if GetDepend('BSP_USING_I2C'):
src += ['drv_soft_i2c.c']
src += ['drv_i2c.c']
if GetDepend('BSP_USING_ADC'):
src += ['drv_adc.c']

View File

@ -0,0 +1,175 @@
/*
* Copyright (c) 2006-2023, RT-Thread Development Team
*
* SPDX-License-Identifier: Apache-2.0
*
* Change Logs:
* Date Author Notes
* 2023/05/10 flyingcys first version
*/
#include <rthw.h>
#include <rtdevice.h>
#ifdef BSP_USING_I2C
#include "drv_i2c.h"
#define DBG_TAG "DRV.I2C"
#define DBG_LVL DBG_WARNING
#include <rtdbg.h>
struct bl_i2c_bus
{
struct rt_i2c_bus_device parent;
struct bflb_device_s *i2c;
struct rt_mutex lock;
};
static rt_ssize_t _i2c_master_xfer(struct rt_i2c_bus_device *bus, struct rt_i2c_msg *msgs, rt_uint32_t num)
{
struct bl_i2c_bus *_i2c_bus = (struct bl_i2c_bus *)bus;
struct rt_i2c_msg *msg;
struct bflb_i2c_msg_s *bflb_i2c_msg;
int i;
int ret;
bflb_i2c_msg = rt_malloc(sizeof(struct bflb_i2c_msg_s) * num);
if (!bflb_i2c_msg)
{
LOG_E("i2c xfer malloc(%d) failure\n", sizeof(struct bflb_i2c_msg_s) * num);
return -RT_ENOMEM;
}
rt_memset(bflb_i2c_msg, 0, sizeof(struct bflb_i2c_msg_s) * num);
for (i = 0; i < num; i++)
{
msg = &msgs[i];
if (msg->flags & RT_I2C_RD)
{
bflb_i2c_msg[i].flags = I2C_M_READ;
}
else
{
bflb_i2c_msg[i].flags = 0;
}
if (_i2c_bus->parent.flags & RT_I2C_DEV_CTRL_10BIT)
{
bflb_i2c_msg[i].flags |= I2C_M_TEN;
}
bflb_i2c_msg[i].addr = msg->addr;
bflb_i2c_msg[i].length = msg->len;
bflb_i2c_msg[i].buffer = msg->buf;
}
rt_mutex_take(&_i2c_bus->lock, RT_WAITING_FOREVER);
ret = bflb_i2c_transfer(_i2c_bus->i2c, bflb_i2c_msg, num);
rt_mutex_release(&_i2c_bus->lock);
rt_free(bflb_i2c_msg);
bflb_i2c_msg = RT_NULL;
if (ret < 0)
{
i = 0;
LOG_E("i2c xfer failure %d\n", ret);
}
return i;
}
static const struct rt_i2c_bus_device_ops _i2c_ops =
{
_i2c_master_xfer,
RT_NULL,
RT_NULL
};
int rt_hw_i2c_init(void)
{
struct bflb_device_s *gpio;
gpio = bflb_device_get_by_name("gpio");
#ifdef BSP_USING_I2C0
static struct bl_i2c_bus i2c_bus0;
/* I2C0_SCL */
bflb_gpio_init(gpio, I2C0_GPIO_SCL, GPIO_FUNC_I2C0 | GPIO_ALTERNATE | GPIO_PULLUP | GPIO_SMT_EN | GPIO_DRV_1);
/* I2C0_SDA */
bflb_gpio_init(gpio, I2C0_GPIO_SDA, GPIO_FUNC_I2C0 | GPIO_ALTERNATE | GPIO_PULLUP | GPIO_SMT_EN | GPIO_DRV_1);
/* init i2c bus device */
rt_mutex_init(&i2c_bus0.lock, "i2c0_mutex", RT_IPC_FLAG_PRIO);
i2c_bus0.parent.ops = &_i2c_ops;
i2c_bus0.i2c = bflb_device_get_by_name("i2c0");
bflb_i2c_init(i2c_bus0.i2c, I2C0_FREQUENCY);
if (rt_i2c_bus_device_register(&i2c_bus0.parent, "i2c0") != RT_EOK)
LOG_E("i2c bus register:%s failure\n", "i2c0");
#endif
#ifdef BSP_USING_I2C1
static struct bl_i2c_bus i2c_bus1;
/* I2C1_SCL */
bflb_gpio_init(gpio, I2C1_GPIO_SCL, GPIO_FUNC_I2C1 | GPIO_ALTERNATE | GPIO_PULLUP | GPIO_SMT_EN | GPIO_DRV_1);
/* I2C1_SDA */
bflb_gpio_init(gpio, I2C1_GPIO_SDA, GPIO_FUNC_I2C1 | GPIO_ALTERNATE | GPIO_PULLUP | GPIO_SMT_EN | GPIO_DRV_1);
/* init i2c bus device */
rt_mutex_init(&i2c_bus1.lock, "i2c1_mutex", RT_IPC_FLAG_PRIO);
i2c_bus1.parent.ops = &_i2c_ops;
i2c_bus1.i2c = bflb_device_get_by_name("i2c1");
bflb_i2c_init(i2c_bus1.i2c, I2C1_FREQUENCY);
if (rt_i2c_bus_device_register(&i2c_bus1.parent, "i2c1") != RT_EOK)
LOG_E("i2c bus register:%s failure\n", "i2c1");
#endif
#ifdef BSP_USING_I2C2
static struct bl_i2c_bus i2c_bus2;
/* I2C2_SCL */
bflb_gpio_init(gpio, I2C2_GPIO_SCL, GPIO_FUNC_I2C2 | GPIO_ALTERNATE | GPIO_PULLUP | GPIO_SMT_EN | GPIO_DRV_1);
/* I2C2_SDA */
bflb_gpio_init(gpio, I2C2_GPIO_SDA, GPIO_FUNC_I2C2 | GPIO_ALTERNATE | GPIO_PULLUP | GPIO_SMT_EN | GPIO_DRV_1);
/* init i2c bus device */
rt_mutex_init(&i2c_bus2.lock, "i2c2_mutex", RT_IPC_FLAG_PRIO);
i2c_bus2.parent.ops = &_i2c_ops;
i2c_bus2.i2c = bflb_device_get_by_name("i2c2");
bflb_i2c_init(i2c_bus2.i2c, I2C2_FREQUENCY);
if (rt_i2c_bus_device_register(&i2c_bus2.parent, "i2c2") != RT_EOK)
LOG_E("i2c bus register:%s failure\n", "i2c2");
#endif
#ifdef BSP_USING_I2C3
static struct bl_i2c_bus i2c_bus3;
/* I2C3_SCL */
bflb_gpio_init(gpio, I2C3_GPIO_SCL, GPIO_FUNC_I2C3 | GPIO_ALTERNATE | GPIO_PULLUP | GPIO_SMT_EN | GPIO_DRV_1);
/* I2C3_SDA */
bflb_gpio_init(gpio, I2C3_GPIO_SDA, GPIO_FUNC_I2C3 | GPIO_ALTERNATE | GPIO_PULLUP | GPIO_SMT_EN | GPIO_DRV_1);
/* init i2c bus device */
rt_mutex_init(&i2c_bus3.lock, "i2c3_mutex", RT_IPC_FLAG_PRIO);
i2c_bus3.parent.ops = &_i2c_ops;
i2c_bus3.i2c = bflb_device_get_by_name("i2c3");
bflb_i2c_init(i2c_bus3.i2c, I2C3_FREQUENCY);
if (rt_i2c_bus_device_register(&i2c_bus3.parent, "i2c3") != RT_EOK)
LOG_E("i2c bus register:%s failure\n", "i2c3");
#endif
return 0;
}
INIT_BOARD_EXPORT(rt_hw_i2c_init);
#endif /* BSP_USING_I2C */

View File

@ -0,0 +1,411 @@
/*
* Copyright (c) 2006-2023, RT-Thread Development Team
*
* SPDX-License-Identifier: Apache-2.0
*
* Change Logs:
* Date Author Notes
* 2023/05/10 flyingcys first version
*/
#ifndef __DRV_I2C_H__
#define __DRV_I2C_H__
#include <rtthread.h>
#include "rtdevice.h"
#include <rthw.h>
#include "bflb_gpio.h"
#include "bflb_i2c.h"
// I2C0
#ifdef I2C0_SCL_USING_GPIO0
#define I2C0_GPIO_SCL GPIO_PIN_0
#elif defined(I2C0_SCL_USING_GPIO2)
#define I2C0_GPIO_SCL GPIO_PIN_2
#elif defined(I2C0_SCL_USING_GPIO4)
#define I2C0_GPIO_SCL GPIO_PIN_4
#elif defined(I2C0_SCL_USING_GPIO6)
#define I2C0_GPIO_SCL GPIO_PIN_6
#elif defined(I2C0_SCL_USING_GPIO8)
#define I2C0_GPIO_SCL GPIO_PIN_8
#elif defined(I2C0_SCL_USING_GPIO10)
#define I2C0_GPIO_SCL GPIO_PIN_4
#elif defined(I2C0_SCL_USING_GPIO12)
#define I2C0_GPIO_SCL GPIO_PIN_12
#elif defined(I2C0_SCL_USING_GPIO14)
#define I2C0_GPIO_SCL GPIO_PIN_14
#elif defined(I2C0_SCL_USING_GPIO16)
#define I2C0_GPIO_SCL GPIO_PIN_16
#elif defined(I2C0_SCL_USING_GPIO18)
#define I2C0_GPIO_SCL GPIO_PIN_18
#elif defined(I2C0_SCL_USING_GPIO20)
#define I2C0_GPIO_SCL GPIO_PIN_20
#elif defined(I2C0_SCL_USING_GPIO22)
#define I2C0_GPIO_SCL GPIO_PIN_22
#elif defined(I2C0_SCL_USING_GPIO24)
#define I2C0_GPIO_SCL GPIO_PIN_24
#elif defined(I2C0_SCL_USING_GPIO26)
#define I2C0_GPIO_SCL GPIO_PIN_26
#elif defined(I2C0_SCL_USING_GPIO28)
#define I2C0_GPIO_SCL GPIO_PIN_28
#elif defined(I2C0_SCL_USING_GPIO30)
#define I2C0_GPIO_SCL GPIO_PIN_30
#elif defined(I2C0_SCL_USING_GPIO32)
#define I2C0_GPIO_SCL GPIO_PIN_32
#elif defined(I2C0_SCL_USING_GPIO34)
#define I2C0_GPIO_SCL GPIO_PIN_34
#elif defined(I2C0_SCL_USING_GPIO36)
#define I2C0_GPIO_SCL GPIO_PIN_36
#elif defined(I2C0_SCL_USING_GPIO38)
#define I2C0_GPIO_SCL GPIO_PIN_38
#elif defined(I2C0_SCL_USING_GPIO40)
#define I2C0_GPIO_SCL GPIO_PIN_40
#elif defined(I2C0_SCL_USING_GPIO42)
#define I2C0_GPIO_SCL GPIO_PIN_42
#elif defined(I2C0_SCL_USING_GPIO44)
#define I2C0_GPIO_SCL GPIO_PIN_44
#endif
#ifdef I2C0_SDA_USING_GPIO1
#define I2C0_GPIO_SDA GPIO_PIN_1
#elif defined(I2C0_SDA_USING_GPIO3)
#define I2C0_GPIO_SDA GPIO_PIN_3
#elif defined(I2C0_SDA_USING_GPIO5)
#define I2C0_GPIO_SDA GPIO_PIN_5
#elif defined(I2C0_SDA_USING_GPIO7)
#define I2C0_GPIO_SDA GPIO_PIN_7
#elif defined(I2C0_SDA_USING_GPIO9)
#define I2C0_GPIO_SDA GPIO_PIN_9
#elif defined(I2C0_SDA_USING_GPIO11)
#define I2C0_GPIO_SDA GPIO_PIN_11
#elif defined(I2C0_SDA_USING_GPIO13)
#define I2C0_GPIO_SDA GPIO_PIN_13
#elif defined(I2C0_SDA_USING_GPIO15)
#define I2C0_GPIO_SDA GPIO_PIN_15
#elif defined(I2C0_SDA_USING_GPIO17)
#define I2C0_GPIO_SDA GPIO_PIN_17
#elif defined(I2C0_SDA_USING_GPIO19)
#define I2C0_GPIO_SDA GPIO_PIN_19
#elif defined(I2C0_SDA_USING_GPIO21)
#define I2C0_GPIO_SDA GPIO_PIN_21
#elif defined(I2C0_SDA_USING_GPIO23)
#define I2C0_GPIO_SDA GPIO_PIN_23
#elif defined(I2C0_SDA_USING_GPIO25)
#define I2C0_GPIO_SDA GPIO_PIN_25
#elif defined(I2C0_SDA_USING_GPIO27)
#define I2C0_GPIO_SDA GPIO_PIN_27
#elif defined(I2C0_SDA_USING_GPIO29)
#define I2C0_GPIO_SDA GPIO_PIN_29
#elif defined(I2C0_SDA_USING_GPIO31)
#define I2C0_GPIO_SDA GPIO_PIN_31
#elif defined(I2C0_SDA_USING_GPIO33)
#define I2C0_GPIO_SDA GPIO_PIN_33
#elif defined(I2C0_SDA_USING_GPIO35)
#define I2C0_GPIO_SDA GPIO_PIN_35
#elif defined(I2C0_SDA_USING_GPIO37)
#define I2C0_GPIO_SDA GPIO_PIN_37
#elif defined(I2C0_SDA_USING_GPIO39)
#define I2C0_GPIO_SDA GPIO_PIN_39
#elif defined(I2C0_SDA_USING_GPIO41)
#define I2C0_GPIO_SDA GPIO_PIN_41
#elif defined(I2C0_SDA_USING_GPIO43)
#define I2C0_GPIO_SDA GPIO_PIN_43
#elif defined(I2C0_SDA_USING_GPIO45)
#define I2C0_GPIO_SDA GPIO_PIN_45
#endif
// I2C1
#ifdef I2C1_SCL_USING_GPIO0
#define I2C1_GPIO_SCL GPIO_PIN_0
#elif defined(I2C1_SCL_USING_GPIO2)
#define I2C1_GPIO_SCL GPIO_PIN_2
#elif defined(I2C1_SCL_USING_GPIO4)
#define I2C1_GPIO_SCL GPIO_PIN_4
#elif defined(I2C1_SCL_USING_GPIO6)
#define I2C1_GPIO_SCL GPIO_PIN_6
#elif defined(I2C1_SCL_USING_GPIO8)
#define I2C1_GPIO_SCL GPIO_PIN_8
#elif defined(I2C1_SCL_USING_GPIO10)
#define I2C1_GPIO_SCL GPIO_PIN_4
#elif defined(I2C1_SCL_USING_GPIO12)
#define I2C1_GPIO_SCL GPIO_PIN_12
#elif defined(I2C1_SCL_USING_GPIO14)
#define I2C1_GPIO_SCL GPIO_PIN_14
#elif defined(I2C1_SCL_USING_GPIO16)
#define I2C1_GPIO_SCL GPIO_PIN_16
#elif defined(I2C1_SCL_USING_GPIO18)
#define I2C1_GPIO_SCL GPIO_PIN_18
#elif defined(I2C1_SCL_USING_GPIO20)
#define I2C1_GPIO_SCL GPIO_PIN_20
#elif defined(I2C1_SCL_USING_GPIO22)
#define I2C1_GPIO_SCL GPIO_PIN_22
#elif defined(I2C1_SCL_USING_GPIO24)
#define I2C1_GPIO_SCL GPIO_PIN_24
#elif defined(I2C1_SCL_USING_GPIO26)
#define I2C1_GPIO_SCL GPIO_PIN_26
#elif defined(I2C1_SCL_USING_GPIO28)
#define I2C1_GPIO_SCL GPIO_PIN_28
#elif defined(I2C1_SCL_USING_GPIO30)
#define I2C1_GPIO_SCL GPIO_PIN_30
#elif defined(I2C1_SCL_USING_GPIO32)
#define I2C1_GPIO_SCL GPIO_PIN_32
#elif defined(I2C1_SCL_USING_GPIO34)
#define I2C1_GPIO_SCL GPIO_PIN_34
#elif defined(I2C1_SCL_USING_GPIO36)
#define I2C1_GPIO_SCL GPIO_PIN_36
#elif defined(I2C1_SCL_USING_GPIO38)
#define I2C1_GPIO_SCL GPIO_PIN_38
#elif defined(I2C1_SCL_USING_GPIO40)
#define I2C1_GPIO_SCL GPIO_PIN_40
#elif defined(I2C1_SCL_USING_GPIO42)
#define I2C1_GPIO_SCL GPIO_PIN_42
#elif defined(I2C1_SCL_USING_GPIO44)
#define I2C1_GPIO_SCL GPIO_PIN_44
#endif
#ifdef I2C1_SDA_USING_GPIO26
#define I2C1_GPIO_SDA GPIO_PIN_1
#elif defined(I2C1_SDA_USING_GPIO3)
#define I2C1_GPIO_SDA GPIO_PIN_3
#elif defined(I2C1_SDA_USING_GPIO5)
#define I2C1_GPIO_SDA GPIO_PIN_5
#elif defined(I2C1_SDA_USING_GPIO7)
#define I2C1_GPIO_SDA GPIO_PIN_7
#elif defined(I2C1_SDA_USING_GPIO9)
#define I2C1_GPIO_SDA GPIO_PIN_9
#elif defined(I2C1_SDA_USING_GPIO11)
#define I2C1_GPIO_SDA GPIO_PIN_11
#elif defined(I2C1_SDA_USING_GPIO13)
#define I2C1_GPIO_SDA GPIO_PIN_13
#elif defined(I2C1_SDA_USING_GPIO15)
#define I2C1_GPIO_SDA GPIO_PIN_15
#elif defined(I2C1_SDA_USING_GPIO17)
#define I2C1_GPIO_SDA GPIO_PIN_17
#elif defined(I2C1_SDA_USING_GPIO19)
#define I2C1_GPIO_SDA GPIO_PIN_19
#elif defined(I2C1_SDA_USING_GPIO21)
#define I2C1_GPIO_SDA GPIO_PIN_21
#elif defined(I2C1_SDA_USING_GPIO23)
#define I2C1_GPIO_SDA GPIO_PIN_23
#elif defined(I2C1_SDA_USING_GPIO25)
#define I2C1_GPIO_SDA GPIO_PIN_25
#elif defined(I2C1_SDA_USING_GPIO27)
#define I2C1_GPIO_SDA GPIO_PIN_27
#elif defined(I2C1_SDA_USING_GPIO29)
#define I2C1_GPIO_SDA GPIO_PIN_29
#elif defined(I2C1_SDA_USING_GPIO31)
#define I2C1_GPIO_SDA GPIO_PIN_31
#elif defined(I2C1_SDA_USING_GPIO33)
#define I2C1_GPIO_SDA GPIO_PIN_33
#elif defined(I2C1_SDA_USING_GPIO35)
#define I2C1_GPIO_SDA GPIO_PIN_35
#elif defined(I2C1_SDA_USING_GPIO37)
#define I2C1_GPIO_SDA GPIO_PIN_37
#elif defined(I2C1_SDA_USING_GPIO39)
#define I2C1_GPIO_SDA GPIO_PIN_39
#elif defined(I2C1_SDA_USING_GPIO41)
#define I2C1_GPIO_SDA GPIO_PIN_41
#elif defined(I2C1_SDA_USING_GPIO43)
#define I2C1_GPIO_SDA GPIO_PIN_43
#elif defined(I2C1_SDA_USING_GPIO45)
#define I2C1_GPIO_SDA GPIO_PIN_45
#endif
// I2C2
#ifdef I2C2_SCL_USING_GPIO0
#define I2C2_GPIO_SCL GPIO_PIN_0
#elif defined(I2C2_SCL_USING_GPIO2)
#define I2C2_GPIO_SCL GPIO_PIN_2
#elif defined(I2C2_SCL_USING_GPIO4)
#define I2C2_GPIO_SCL GPIO_PIN_4
#elif defined(I2C2_SCL_USING_GPIO6)
#define I2C2_GPIO_SCL GPIO_PIN_6
#elif defined(I2C2_SCL_USING_GPIO8)
#define I2C2_GPIO_SCL GPIO_PIN_8
#elif defined(I2C2_SCL_USING_GPIO10)
#define I2C2_GPIO_SCL GPIO_PIN_4
#elif defined(I2C2_SCL_USING_GPIO12)
#define I2C2_GPIO_SCL GPIO_PIN_12
#elif defined(I2C2_SCL_USING_GPIO14)
#define I2C2_GPIO_SCL GPIO_PIN_14
#elif defined(I2C2_SCL_USING_GPIO16)
#define I2C2_GPIO_SCL GPIO_PIN_16
#elif defined(I2C2_SCL_USING_GPIO18)
#define I2C2_GPIO_SCL GPIO_PIN_18
#elif defined(I2C2_SCL_USING_GPIO20)
#define I2C2_GPIO_SCL GPIO_PIN_20
#elif defined(I2C2_SCL_USING_GPIO22)
#define I2C2_GPIO_SCL GPIO_PIN_22
#elif defined(I2C2_SCL_USING_GPIO24)
#define I2C2_GPIO_SCL GPIO_PIN_24
#elif defined(I2C2_SCL_USING_GPIO26)
#define I2C2_GPIO_SCL GPIO_PIN_26
#elif defined(I2C2_SCL_USING_GPIO28)
#define I2C2_GPIO_SCL GPIO_PIN_28
#elif defined(I2C2_SCL_USING_GPIO30)
#define I2C2_GPIO_SCL GPIO_PIN_30
#elif defined(I2C2_SCL_USING_GPIO32)
#define I2C2_GPIO_SCL GPIO_PIN_32
#elif defined(I2C2_SCL_USING_GPIO34)
#define I2C2_GPIO_SCL GPIO_PIN_34
#elif defined(I2C2_SCL_USING_GPIO36)
#define I2C2_GPIO_SCL GPIO_PIN_36
#elif defined(I2C2_SCL_USING_GPIO38)
#define I2C2_GPIO_SCL GPIO_PIN_38
#elif defined(I2C2_SCL_USING_GPIO40)
#define I2C2_GPIO_SCL GPIO_PIN_40
#elif defined(I2C2_SCL_USING_GPIO42)
#define I2C2_GPIO_SCL GPIO_PIN_42
#elif defined(I2C2_SCL_USING_GPIO44)
#define I2C2_GPIO_SCL GPIO_PIN_44
#endif
#ifdef I2C2_SDA_USING_GPIO26
#define I2C2_GPIO_SDA GPIO_PIN_1
#elif defined(I2C2_SDA_USING_GPIO3)
#define I2C2_GPIO_SDA GPIO_PIN_3
#elif defined(I2C2_SDA_USING_GPIO5)
#define I2C2_GPIO_SDA GPIO_PIN_5
#elif defined(I2C2_SDA_USING_GPIO7)
#define I2C2_GPIO_SDA GPIO_PIN_7
#elif defined(I2C2_SDA_USING_GPIO9)
#define I2C2_GPIO_SDA GPIO_PIN_9
#elif defined(I2C2_SDA_USING_GPIO11)
#define I2C2_GPIO_SDA GPIO_PIN_11
#elif defined(I2C2_SDA_USING_GPIO13)
#define I2C2_GPIO_SDA GPIO_PIN_13
#elif defined(I2C2_SDA_USING_GPIO15)
#define I2C2_GPIO_SDA GPIO_PIN_15
#elif defined(I2C2_SDA_USING_GPIO17)
#define I2C2_GPIO_SDA GPIO_PIN_17
#elif defined(I2C2_SDA_USING_GPIO19)
#define I2C2_GPIO_SDA GPIO_PIN_19
#elif defined(I2C2_SDA_USING_GPIO21)
#define I2C2_GPIO_SDA GPIO_PIN_21
#elif defined(I2C2_SDA_USING_GPIO23)
#define I2C2_GPIO_SDA GPIO_PIN_23
#elif defined(I2C2_SDA_USING_GPIO25)
#define I2C2_GPIO_SDA GPIO_PIN_25
#elif defined(I2C2_SDA_USING_GPIO27)
#define I2C2_GPIO_SDA GPIO_PIN_27
#elif defined(I2C2_SDA_USING_GPIO29)
#define I2C2_GPIO_SDA GPIO_PIN_29
#elif defined(I2C2_SDA_USING_GPIO31)
#define I2C2_GPIO_SDA GPIO_PIN_31
#elif defined(I2C2_SDA_USING_GPIO33)
#define I2C2_GPIO_SDA GPIO_PIN_33
#elif defined(I2C2_SDA_USING_GPIO35)
#define I2C2_GPIO_SDA GPIO_PIN_35
#elif defined(I2C2_SDA_USING_GPIO37)
#define I2C2_GPIO_SDA GPIO_PIN_37
#elif defined(I2C2_SDA_USING_GPIO39)
#define I2C2_GPIO_SDA GPIO_PIN_39
#elif defined(I2C2_SDA_USING_GPIO41)
#define I2C2_GPIO_SDA GPIO_PIN_41
#elif defined(I2C2_SDA_USING_GPIO43)
#define I2C2_GPIO_SDA GPIO_PIN_43
#elif defined(I2C2_SDA_USING_GPIO45)
#define I2C2_GPIO_SDA GPIO_PIN_45
#endif
// I2C3
#ifdef I2C3_SCL_USING_GPIO0
#define I2C3_GPIO_SCL GPIO_PIN_0
#elif defined(I2C3_SCL_USING_GPIO2)
#define I2C3_GPIO_SCL GPIO_PIN_2
#elif defined(I2C3_SCL_USING_GPIO4)
#define I2C3_GPIO_SCL GPIO_PIN_4
#elif defined(I2C3_SCL_USING_GPIO6)
#define I2C3_GPIO_SCL GPIO_PIN_6
#elif defined(I2C3_SCL_USING_GPIO8)
#define I2C3_GPIO_SCL GPIO_PIN_8
#elif defined(I2C3_SCL_USING_GPIO10)
#define I2C3_GPIO_SCL GPIO_PIN_4
#elif defined(I2C3_SCL_USING_GPIO12)
#define I2C3_GPIO_SCL GPIO_PIN_12
#elif defined(I2C3_SCL_USING_GPIO14)
#define I2C3_GPIO_SCL GPIO_PIN_14
#elif defined(I2C3_SCL_USING_GPIO16)
#define I2C3_GPIO_SCL GPIO_PIN_16
#elif defined(I2C3_SCL_USING_GPIO18)
#define I2C3_GPIO_SCL GPIO_PIN_18
#elif defined(I2C3_SCL_USING_GPIO20)
#define I2C3_GPIO_SCL GPIO_PIN_20
#elif defined(I2C3_SCL_USING_GPIO22)
#define I2C3_GPIO_SCL GPIO_PIN_22
#elif defined(I2C3_SCL_USING_GPIO24)
#define I2C3_GPIO_SCL GPIO_PIN_24
#elif defined(I2C3_SCL_USING_GPIO26)
#define I2C3_GPIO_SCL GPIO_PIN_26
#elif defined(I2C3_SCL_USING_GPIO28)
#define I2C3_GPIO_SCL GPIO_PIN_28
#elif defined(I2C3_SCL_USING_GPIO30)
#define I2C3_GPIO_SCL GPIO_PIN_30
#elif defined(I2C3_SCL_USING_GPIO32)
#define I2C3_GPIO_SCL GPIO_PIN_32
#elif defined(I2C3_SCL_USING_GPIO34)
#define I2C3_GPIO_SCL GPIO_PIN_34
#elif defined(I2C3_SCL_USING_GPIO36)
#define I2C3_GPIO_SCL GPIO_PIN_36
#elif defined(I2C3_SCL_USING_GPIO38)
#define I2C3_GPIO_SCL GPIO_PIN_38
#elif defined(I2C3_SCL_USING_GPIO40)
#define I2C3_GPIO_SCL GPIO_PIN_40
#elif defined(I2C3_SCL_USING_GPIO42)
#define I2C3_GPIO_SCL GPIO_PIN_42
#elif defined(I2C3_SCL_USING_GPIO44)
#define I2C3_GPIO_SCL GPIO_PIN_44
#endif
#ifdef I2C3_SDA_USING_GPIO26
#define I2C3_GPIO_SDA GPIO_PIN_1
#elif defined(I2C3_SDA_USING_GPIO3)
#define I2C3_GPIO_SDA GPIO_PIN_3
#elif defined(I2C3_SDA_USING_GPIO5)
#define I2C3_GPIO_SDA GPIO_PIN_5
#elif defined(I2C3_SDA_USING_GPIO7)
#define I2C3_GPIO_SDA GPIO_PIN_7
#elif defined(I2C3_SDA_USING_GPIO9)
#define I2C3_GPIO_SDA GPIO_PIN_9
#elif defined(I2C3_SDA_USING_GPIO11)
#define I2C3_GPIO_SDA GPIO_PIN_11
#elif defined(I2C3_SDA_USING_GPIO13)
#define I2C3_GPIO_SDA GPIO_PIN_13
#elif defined(I2C3_SDA_USING_GPIO15)
#define I2C3_GPIO_SDA GPIO_PIN_15
#elif defined(I2C3_SDA_USING_GPIO17)
#define I2C3_GPIO_SDA GPIO_PIN_17
#elif defined(I2C3_SDA_USING_GPIO19)
#define I2C3_GPIO_SDA GPIO_PIN_19
#elif defined(I2C3_SDA_USING_GPIO21)
#define I2C3_GPIO_SDA GPIO_PIN_21
#elif defined(I2C3_SDA_USING_GPIO23)
#define I2C3_GPIO_SDA GPIO_PIN_23
#elif defined(I2C3_SDA_USING_GPIO25)
#define I2C3_GPIO_SDA GPIO_PIN_25
#elif defined(I2C3_SDA_USING_GPIO27)
#define I2C3_GPIO_SDA GPIO_PIN_27
#elif defined(I2C3_SDA_USING_GPIO29)
#define I2C3_GPIO_SDA GPIO_PIN_29
#elif defined(I2C3_SDA_USING_GPIO31)
#define I2C3_GPIO_SDA GPIO_PIN_31
#elif defined(I2C3_SDA_USING_GPIO33)
#define I2C3_GPIO_SDA GPIO_PIN_33
#elif defined(I2C3_SDA_USING_GPIO35)
#define I2C3_GPIO_SDA GPIO_PIN_35
#elif defined(I2C3_SDA_USING_GPIO37)
#define I2C3_GPIO_SDA GPIO_PIN_37
#elif defined(I2C3_SDA_USING_GPIO39)
#define I2C3_GPIO_SDA GPIO_PIN_39
#elif defined(I2C3_SDA_USING_GPIO41)
#define I2C3_GPIO_SDA GPIO_PIN_41
#elif defined(I2C3_SDA_USING_GPIO43)
#define I2C3_GPIO_SDA GPIO_PIN_43
#elif defined(I2C3_SDA_USING_GPIO45)
#define I2C3_GPIO_SDA GPIO_PIN_45
#endif
int rt_hw_i2c_init(void);
#endif /* __DRV_I2C_H__ */