From 5991990b6ae60293649557e7731886be1bca8669 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=A4=9A=E4=BB=95=E6=88=90?= <1468559561@qq.com> Date: Fri, 12 May 2023 17:38:25 +0800 Subject: [PATCH] [bsp][bl]update: drv_soft_i2c --- bsp/bouffalo_lab/libraries/rt_drivers/Kconfig | 644 +++++++++++------- .../libraries/rt_drivers/SConscript | 5 +- .../libraries/rt_drivers/drv_gpio.c | 4 +- .../libraries/rt_drivers/drv_soft_i2c.c | 107 ++- .../libraries/rt_drivers/drv_soft_i2c.h | 2 +- 5 files changed, 478 insertions(+), 284 deletions(-) diff --git a/bsp/bouffalo_lab/libraries/rt_drivers/Kconfig b/bsp/bouffalo_lab/libraries/rt_drivers/Kconfig index ee727489c6..7564dd622e 100755 --- a/bsp/bouffalo_lab/libraries/rt_drivers/Kconfig +++ b/bsp/bouffalo_lab/libraries/rt_drivers/Kconfig @@ -708,275 +708,400 @@ menu "General Drivers Configuration" endif menuconfig BSP_USING_I2C - bool "Enable I2C" - select RT_USING_I2C + bool "Enable I2C BUS" default n - + select RT_USING_I2C 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 BSP_USING_HW_I2C + bool "Enable Hardware I2C BUS" + default n + if BSP_USING_HW_I2C + menuconfig BSP_USING_I2C0 + bool "Enable I2C0 (hardware)" + 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 + 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_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 + 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_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 + config I2C0_FREQUENCY + int "I2C0 Frequency" + default 400000 + endif + + + menuconfig BSP_USING_I2C1 + depends on BSP_USING_BL61X || BSP_USING_BL808 + bool "Enable I2C1 (hardware)" + default n + if BSP_USING_I2C1 + choice + 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_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_24" + 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" + 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 + if !BSP_USING_HW_I2C + menuconfig BSP_USING_SOFT_I2C1 + bool "Enable I2C1 BUS (software simulation)" + select RT_USING_I2C_BITOPS + select BSP_USING_GPIO + default n + if BSP_USING_SOFT_I2C1 + choice + prompt "I2C1 SCL" + default SOFT_I2C1_SCL_USING_GPIO0 - menuconfig BSP_USING_I2C1 - depends on BSP_USING_BL61X || BSP_USING_BL808 - bool "Enable I2C1" - default n - if BSP_USING_I2C1 - choice - prompt "I2C1 SCL" - default I2C1_SCL_USING_GPIO0 + config SOFT_I2C1_SCL_USING_GPIO0 + bool "GPIO_0" + config SOFT_I2C1_SCL_USING_GPIO2 + bool "GPIO_2" + config SOFT_I2C1_SCL_USING_GPIO4 + bool "GPIO_4" + config SOFT_I2C1_SCL_USING_GPIO6 + bool "GPIO_6" + config SOFT_I2C1_SCL_USING_GPIO8 + bool "GPIO_8" + config SOFT_I2C1_SCL_USING_GPIO10 + bool "GPIO_10" + config SOFT_I2C1_SCL_USING_GPIO12 + bool "GPIO_12" + config SOFT_I2C1_SCL_USING_GPIO14 + bool "GPIO_14" + config SOFT_I2C1_SCL_USING_GPIO16 + bool "GPIO_16" + config SOFT_I2C1_SCL_USING_GPIO18 + bool "GPIO_18" + config SOFT_I2C1_SCL_USING_GPIO20 + bool "GPIO_20" + config SOFT_I2C1_SCL_USING_GPIO22 + bool "GPIO_22" + config SOFT_I2C1_SCL_USING_GPIO24 + bool "GPIO_8" + config SOFT_I2C1_SCL_USING_GPIO26 + bool "GPIO_26" + config SOFT_I2C1_SCL_USING_GPIO28 + bool "GPIO_28" + config SOFT_I2C1_SCL_USING_GPIO30 + bool "GPIO_30" + config SOFT_I2C1_SCL_USING_GPIO32 + bool "GPIO_32" + config SOFT_I2C1_SCL_USING_GPIO34 + bool "GPIO_34" + config SOFT_I2C1_SDA_USING_GPIO36 + depends on BSP_USING_BL808 + bool "GPIO_36" + config SOFT_I2C1_SDA_USING_GPIO38 + depends on BSP_USING_BL808 + bool "GPIO_38" + config SOFT_I2C1_SDA_USING_GPIO40 + depends on BSP_USING_BL808 + bool "GPIO_40" + config SOFT_I2C1_SDA_USING_GPIO42 + depends on BSP_USING_BL808 + bool "GPIO_42" + config SOFT_I2C1_SDA_USING_GPIO44 + depends on BSP_USING_BL808 + bool "GPIO_44" + endchoice - 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" + default SOFT_I2C1_SDA_USING_GPIO1 - choice - 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 + config SOFT_I2C1_SDA_USING_GPIO1 + bool "GPIO_1" + config SOFT_I2C1_SDA_USING_GPIO3 + bool "GPIO_3" + config SOFT_I2C1_SDA_USING_GPIO5 + bool "GPIO_5" + config SOFT_I2C1_SDA_USING_GPIO7 + bool "GPIO_7" + config SOFT_I2C1_SDA_USING_GPIO9 + bool "GPIO_9" + config SOFT_I2C1_SDA_USING_GPIO11 + bool "GPIO_11" + config SOFT_I2C1_SDA_USING_GPIO13 + bool "GPIO_13" + config SOFT_I2C1_SDA_USING_GPIO15 + bool "GPIO_15" + config SOFT_I2C1_SDA_USING_GPIO17 + bool "GPIO_17" + config SOFT_I2C1_SDA_USING_GPIO19 + bool "GPIO_19" + config SOFT_I2C1_SDA_USING_GPIO21 + bool "GPIO_21" + config SOFT_I2C1_SDA_USING_GPIO23 + bool "GPIO_23" + config SOFT_I2C1_SDA_USING_GPIO25 + bool "GPIO_25" + config SOFT_I2C1_SDA_USING_GPIO27 + bool "GPIO_27" + config SOFT_I2C1_SDA_USING_GPIO29 + bool "GPIO_29" + config SOFT_I2C1_SDA_USING_GPIO31 + bool "GPIO_31" + config SOFT_I2C1_SDA_USING_GPIO33 + bool "GPIO_33" + config SOFT_I2C1_SDA_USING_GPIO35 + depends on BSP_USING_BL808 + bool "GPIO_35" + config SOFT_I2C1_SDA_USING_GPIO37 + depends on BSP_USING_BL808 + bool "GPIO_37" + config SOFT_I2C1_SDA_USING_GPIO39 + depends on BSP_USING_BL808 + bool "GPIO_39" + config SOFT_I2C1_SDA_USING_GPIO41 + depends on BSP_USING_BL808 + bool "GPIO_41" + config SOFT_I2C1_SDA_USING_GPIO43 + depends on BSP_USING_BL808 + bool "GPIO_43" + config SOFT_I2C1_SDA_USING_GPIO45 + depends on BSP_USING_BL808 + bool "GPIO_45" + endchoice + endif + endif endif menuconfig BSP_USING_SPI @@ -1290,4 +1415,3 @@ menu "General Drivers Configuration" default n endif endmenu - diff --git a/bsp/bouffalo_lab/libraries/rt_drivers/SConscript b/bsp/bouffalo_lab/libraries/rt_drivers/SConscript index be35a8776b..bbfa1a0a76 100755 --- a/bsp/bouffalo_lab/libraries/rt_drivers/SConscript +++ b/bsp/bouffalo_lab/libraries/rt_drivers/SConscript @@ -9,9 +9,12 @@ CPPPATH = [cwd] if GetDepend('BSP_USING_GPIO'): src += ['drv_gpio.c'] -if GetDepend('BSP_USING_I2C'): +if GetDepend('BSP_USING_HW_I2C'): src += ['drv_i2c.c'] +if GetDepend('BSP_USING_SOFT_I2C1'): + src += ['drv_soft_i2c.c'] + if GetDepend('BSP_USING_ADC'): src += ['drv_adc.c'] diff --git a/bsp/bouffalo_lab/libraries/rt_drivers/drv_gpio.c b/bsp/bouffalo_lab/libraries/rt_drivers/drv_gpio.c index 0a1969038b..406cf3e384 100755 --- a/bsp/bouffalo_lab/libraries/rt_drivers/drv_gpio.c +++ b/bsp/bouffalo_lab/libraries/rt_drivers/drv_gpio.c @@ -12,7 +12,7 @@ #include "drv_gpio.h" #include -#ifdef BSP_USING_PIN +#ifdef BSP_USING_GPIO #define DBG_TAG "drv.gpio" #define DBG_LVL DBG_INFO @@ -227,4 +227,4 @@ int rt_hw_pin_init(void) } INIT_BOARD_EXPORT(rt_hw_pin_init); -#endif /*BSP_USING_PIN */ +#endif /*BSP_USING_GPIO */ diff --git a/bsp/bouffalo_lab/libraries/rt_drivers/drv_soft_i2c.c b/bsp/bouffalo_lab/libraries/rt_drivers/drv_soft_i2c.c index 8ffb6dab9b..5278a927f4 100644 --- a/bsp/bouffalo_lab/libraries/rt_drivers/drv_soft_i2c.c +++ b/bsp/bouffalo_lab/libraries/rt_drivers/drv_soft_i2c.c @@ -12,45 +12,112 @@ #include "bflb_gpio.h" #include "bflb_common.h" -#ifdef BSP_USING_I2C +#ifdef BSP_USING_SOFT_I2C1 #define DBG_LEVEL DBG_LOG #include #define LOG_TAG "DRV.I2C" -#if !defined(BSP_USING_I2C1) && !defined(BSP_USING_I2C2) -#error "Please define at least one BSP_USING_I2Cx" -/* this driver can be disabled at menuconfig -> RT-Thread Components -> Device Drivers */ -#endif - -// uart1 -#ifdef I2C1_SCL_USING_GPIO0 +// i2c1 +#ifdef SOFT_I2C1_SCL_USING_GPIO0 #define BSP_I2C1_SCL_PIN GPIO_PIN_0 -#elif defined(I2C1_SCL_USING_GPIO4) +#elif defined(SOFT_I2C1_SCL_USING_GPIO2) +#define BSP_I2C1_SCL_PIN GPIO_PIN_2 +#elif defined(SOFT_I2C1_SCL_USING_GPIO4) #define BSP_I2C1_SCL_PIN GPIO_PIN_4 -#elif defined(I2C1_SCL_USING_GPIO8) +#elif defined(SOFT_I2C1_SCL_USING_GPIO6) +#define BSP_I2C1_SCL_PIN GPIO_PIN_6 +#elif defined(SOFT_I2C1_SCL_USING_GPIO8) #define BSP_I2C1_SCL_PIN GPIO_PIN_8 -#elif defined(I2C1_SCL_USING_GPIO10) +#elif defined(SOFT_I2C1_SCL_USING_GPIO10) #define BSP_I2C1_SCL_PIN GPIO_PIN_10 -#elif defined(I2C1_SCL_USING_GPIO20) +#elif defined(SOFT_I2C1_SCL_USING_GPIO12) +#define BSP_I2C1_SCL_PIN GPIO_PIN_12 +#elif defined(SOFT_I2C1_SCL_USING_GPIO14) +#define BSP_I2C1_SCL_PIN GPIO_PIN_14 +#elif defined(SOFT_I2C1_SCL_USING_GPIO16) +#define BSP_I2C1_SCL_PIN GPIO_PIN_16 +#elif defined(SOFT_I2C1_SCL_USING_GPIO18) +#define BSP_I2C1_SCL_PIN GPIO_PIN_18 +#elif defined(SOFT_I2C1_SCL_USING_GPIO20) #define BSP_I2C1_SCL_PIN GPIO_PIN_20 +#elif defined(SOFT_I2C1_SCL_USING_GPIO22) +#define BSP_I2C1_SCL_PIN GPIO_PIN_22 +#elif defined(SOFT_I2C1_SCL_USING_GPIO24) +#define BSP_I2C1_SCL_PIN GPIO_PIN_24 +#elif defined(SOFT_I2C1_SCL_USING_GPIO26) +#define BSP_I2C1_SCL_PIN GPIO_PIN_26 +#elif defined(SOFT_I2C1_SCL_USING_GPIO28) +#define BSP_I2C1_SCL_PIN GPIO_PIN_28 +#elif defined(SOFT_I2C1_SCL_USING_GPIO30) +#define BSP_I2C1_SCL_PIN GPIO_PIN_30 +#elif defined(SOFT_I2C1_SCL_USING_GPIO32) +#define BSP_I2C1_SCL_PIN GPIO_PIN_32 +#elif defined(SOFT_I2C1_SCL_USING_GPIO34) +#define BSP_I2C1_SCL_PIN GPIO_PIN_34 +#elif defined(SOFT_I2C1_SCL_USING_GPIO36) +#define BSP_I2C1_SCL_PIN GPIO_PIN_36 +#elif defined(SOFT_I2C1_SCL_USING_GPIO38) +#define BSP_I2C1_SCL_PIN GPIO_PIN_38 +#elif defined(SOFT_I2C1_SCL_USING_GPIO40) +#define BSP_I2C1_SCL_PIN GPIO_PIN_40 +#elif defined(SOFT_I2C1_SCL_USING_GPIO42) +#define BSP_I2C1_SCL_PIN GPIO_PIN_42 +#elif defined(SOFT_I2C1_SCL_USING_GPIO44) +#define BSP_I2C1_SCL_PIN GPIO_PIN_44 #endif -#ifdef I2C1_SDA_USING_GPIO1 +#ifdef SOFT_I2C1_SDA_USING_GPIO1 #define BSP_I2C1_SDA_PIN GPIO_PIN_1 -#elif defined(I2C1_SDA_USING_GPIO3) +#elif defined(SOFT_I2C1_SDA_USING_GPIO3) #define BSP_I2C1_SDA_PIN GPIO_PIN_3 -#elif defined(I2C1_SDA_USING_GPIO7) +#elif defined(SOFT_I2C1_SDA_USING_GPIO5) +#define BSP_I2C1_SDA_PIN GPIO_PIN_5 +#elif defined(SOFT_I2C1_SDA_USING_GPIO7) #define BSP_I2C1_SDA_PIN GPIO_PIN_7 -#elif defined(I2C1_SDA_USING_GPIO11) +#elif defined(SOFT_I2C1_SDA_USING_GPIO9) +#define BSP_I2C1_SDA_PIN GPIO_PIN_9 +#elif defined(SOFT_I2C1_SDA_USING_GPIO11) #define BSP_I2C1_SDA_PIN GPIO_PIN_11 -#elif defined(I2C1_SDA_USING_GPIO21) +#elif defined(SOFT_I2C1_SDA_USING_GPIO13) +#define BSP_I2C1_SDA_PIN GPIO_PIN_13 +#elif defined(SOFT_I2C1_SDA_USING_GPIO15) +#define BSP_I2C1_SDA_PIN GPIO_PIN_15 +#elif defined(SOFT_I2C1_SDA_USING_GPIO17) +#define BSP_I2C1_SDA_PIN GPIO_PIN_17 +#elif defined(SOFT_I2C1_SDA_USING_GPIO19) +#define BSP_I2C1_SDA_PIN GPIO_PIN_19 +#elif defined(SOFT_I2C1_SDA_USING_GPIO21) #define BSP_I2C1_SDA_PIN GPIO_PIN_21 +#elif defined(SOFT_I2C1_SDA_USING_GPIO23) +#define BSP_I2C1_SDA_PIN GPIO_PIN_23 +#elif defined(SOFT_I2C1_SDA_USING_GPIO25) +#define BSP_I2C1_SDA_PIN GPIO_PIN_25 +#elif defined(SOFT_I2C1_SDA_USING_GPIO27) +#define BSP_I2C1_SDA_PIN GPIO_PIN_27 +#elif defined(SOFT_I2C1_SDA_USING_GPIO29) +#define BSP_I2C1_SDA_PIN GPIO_PIN_29 +#elif defined(SOFT_I2C1_SDA_USING_GPIO31) +#define BSP_I2C1_SDA_PIN GPIO_PIN_31 +#elif defined(SOFT_I2C1_SDA_USING_GPIO33) +#define BSP_I2C1_SDA_PIN GPIO_PIN_33 +#elif defined(SOFT_I2C1_SDA_USING_GPIO35) +#define BSP_I2C1_SDA_PIN GPIO_PIN_35 +#elif defined(SOFT_I2C1_SDA_USING_GPIO37) +#define BSP_I2C1_SDA_PIN GPIO_PIN_37 +#elif defined(SOFT_I2C1_SDA_USING_GPIO39) +#define BSP_I2C1_SDA_PIN GPIO_PIN_39 +#elif defined(SOFT_I2C1_SDA_USING_GPIO41) +#define BSP_I2C1_SDA_PIN GPIO_PIN_41 +#elif defined(SOFT_I2C1_SDA_USING_GPIO43) +#define BSP_I2C1_SDA_PIN GPIO_PIN_43 +#elif defined(SOFT_I2C1_SDA_USING_GPIO45) +#define BSP_I2C1_SDA_PIN GPIO_PIN_45 #endif static const struct bl_soft_i2c_config soft_i2c_config[] = { -#ifdef BSP_USING_I2C1 +#ifdef BSP_USING_SOFT_I2C1 I2C1_BUS_CONFIG, #endif }; @@ -140,7 +207,7 @@ static rt_int32_t bl_get_scl(void *data) */ static void bl_udelay(rt_uint32_t us) { - arch_delay_us(us); + bflb_mtimer_delay_us(us); } static const struct rt_i2c_bit_ops bl_bit_ops_default = @@ -209,4 +276,4 @@ int rt_hw_i2c_init(void) } INIT_BOARD_EXPORT(rt_hw_i2c_init); -#endif /* BSP_USING_I2C */ +#endif /* BSP_USING_SOFT_I2C1 */ diff --git a/bsp/bouffalo_lab/libraries/rt_drivers/drv_soft_i2c.h b/bsp/bouffalo_lab/libraries/rt_drivers/drv_soft_i2c.h index f25488c4e3..07896eb399 100644 --- a/bsp/bouffalo_lab/libraries/rt_drivers/drv_soft_i2c.h +++ b/bsp/bouffalo_lab/libraries/rt_drivers/drv_soft_i2c.h @@ -30,7 +30,7 @@ struct bl_soft_i2c_config const char *bus_name; }; -#ifdef BSP_USING_I2C1 +#ifdef BSP_USING_SOFT_I2C1 #define I2C1_BUS_CONFIG \ { \ .scl = BSP_I2C1_SCL_PIN, \