[bsp][bl]update: drv_soft_i2c

This commit is contained in:
褚仕成 2023-05-12 17:38:25 +08:00 committed by Man, Jianting (Meco)
parent f36a1bb514
commit 5991990b6a
5 changed files with 478 additions and 284 deletions

View File

@ -708,275 +708,400 @@ menu "General Drivers Configuration"
endif endif
menuconfig BSP_USING_I2C menuconfig BSP_USING_I2C
bool "Enable I2C" bool "Enable I2C BUS"
select RT_USING_I2C
default n default n
select RT_USING_I2C
if BSP_USING_I2C if BSP_USING_I2C
menuconfig BSP_USING_I2C0 config BSP_USING_HW_I2C
bool "Enable I2C0" bool "Enable Hardware I2C BUS"
default n default n
if BSP_USING_I2C0 if BSP_USING_HW_I2C
choice menuconfig BSP_USING_I2C0
prompt "I2C0 SCL" bool "Enable I2C0 (hardware)"
default I2C0_SCL_USING_GPIO14 default n
if BSP_USING_I2C0
choice
prompt "I2C0 SCL"
default I2C0_SCL_USING_GPIO14
config I2C0_SCL_USING_GPIO0 config I2C0_SCL_USING_GPIO0
bool "GPIO_0" bool "GPIO_0"
config I2C0_SCL_USING_GPIO2 config I2C0_SCL_USING_GPIO2
bool "GPIO_2" bool "GPIO_2"
config I2C0_SCL_USING_GPIO4 config I2C0_SCL_USING_GPIO4
bool "GPIO_4" bool "GPIO_4"
config I2C0_SCL_USING_GPIO6 config I2C0_SCL_USING_GPIO6
bool "GPIO_6" bool "GPIO_6"
config I2C0_SCL_USING_GPIO8 config I2C0_SCL_USING_GPIO8
bool "GPIO_8" bool "GPIO_8"
config I2C0_SCL_USING_GPIO8 config I2C0_SCL_USING_GPIO10
bool "GPIO_8" bool "GPIO_10"
config I2C0_SCL_USING_GPIO10 config I2C0_SCL_USING_GPIO12
bool "GPIO_10" bool "GPIO_12"
config I2C0_SCL_USING_GPIO12 config I2C0_SCL_USING_GPIO14
bool "GPIO_12" bool "GPIO_14"
config I2C0_SCL_USING_GPIO14 config I2C0_SCL_USING_GPIO16
bool "GPIO_14" bool "GPIO_16"
config I2C0_SCL_USING_GPIO16 config I2C0_SCL_USING_GPIO18
bool "GPIO_16" bool "GPIO_18"
config I2C0_SCL_USING_GPIO18 config I2C0_SCL_USING_GPIO20
bool "GPIO_18" bool "GPIO_20"
config I2C0_SCL_USING_GPIO20 config I2C0_SCL_USING_GPIO22
bool "GPIO_20" bool "GPIO_22"
config I2C0_SCL_USING_GPIO22 config I2C0_SCL_USING_GPIO24
bool "GPIO_22" depends on BSP_USING_BL61X || BSP_USING_BL70X || BSP_USING_BL808
config I2C0_SCL_USING_GPIO24 bool "GPIO_8"
depends on BSP_USING_BL61X || BSP_USING_BL70X || BSP_USING_BL808 config I2C0_SCL_USING_GPIO26
bool "GPIO_8" depends on BSP_USING_BL61X || BSP_USING_BL70X || BSP_USING_BL808
config I2C0_SCL_USING_GPIO26 bool "GPIO_26"
depends on BSP_USING_BL61X || BSP_USING_BL70X || BSP_USING_BL808 config I2C0_SCL_USING_GPIO28
bool "GPIO_26" depends on BSP_USING_BL61X || BSP_USING_BL70X || BSP_USING_BL808
config I2C0_SCL_USING_GPIO28 bool "GPIO_28"
depends on BSP_USING_BL61X || BSP_USING_BL70X || BSP_USING_BL808 config I2C0_SCL_USING_GPIO30
bool "GPIO_28" depends on BSP_USING_BL61X || BSP_USING_BL70X || BSP_USING_BL808
config I2C0_SCL_USING_GPIO30 bool "GPIO_30"
depends on BSP_USING_BL61X || BSP_USING_BL70X || BSP_USING_BL808 config I2C0_SCL_USING_GPIO32
bool "GPIO_30" depends on BSP_USING_BL61X || BSP_USING_BL808
config I2C0_SCL_USING_GPIO32 bool "GPIO_32"
depends on BSP_USING_BL61X || BSP_USING_BL808 config I2C0_SCL_USING_GPIO34
bool "GPIO_32" depends on BSP_USING_BL61X || BSP_USING_BL808
config I2C0_SCL_USING_GPIO34 bool "GPIO_34"
depends on BSP_USING_BL61X || BSP_USING_BL808 config I2C0_SDA_USING_GPIO36
bool "GPIO_34" depends on BSP_USING_BL808
config I2C0_SDA_USING_GPIO36 bool "GPIO_36"
depends on BSP_USING_BL808 config I2C0_SDA_USING_GPIO38
bool "GPIO_36" depends on BSP_USING_BL808
config I2C0_SDA_USING_GPIO38 bool "GPIO_38"
depends on BSP_USING_BL808 config I2C0_SDA_USING_GPIO40
bool "GPIO_38" depends on BSP_USING_BL808
config I2C0_SDA_USING_GPIO40 bool "GPIO_40"
depends on BSP_USING_BL808 config I2C1_SDA_USING_GPIO42
bool "GPIO_40" depends on BSP_USING_BL808
config I2C1_SDA_USING_GPIO42 bool "GPIO_42"
depends on BSP_USING_BL808 config I2C0_SDA_USING_GPIO44
bool "GPIO_42" depends on BSP_USING_BL808
config I2C0_SDA_USING_GPIO44 bool "GPIO_44"
depends on BSP_USING_BL808 endchoice
bool "GPIO_44"
endchoice
choice choice
prompt "I2C0 SDA" prompt "I2C0 SDA"
default I2C0_SDA_USING_GPIO15 default I2C0_SDA_USING_GPIO15
config I2C0_SDA_USING_GPIO1 config I2C0_SDA_USING_GPIO1
bool "GPIO_1" bool "GPIO_1"
config I2C0_SDA_USING_GPIO3 config I2C0_SDA_USING_GPIO3
bool "GPIO_3" bool "GPIO_3"
config I2C0_SDA_USING_GPIO5 config I2C0_SDA_USING_GPIO5
bool "GPIO_5" bool "GPIO_5"
config I2C0_SDA_USING_GPIO7 config I2C0_SDA_USING_GPIO7
bool "GPIO_7" bool "GPIO_7"
config I2C0_SDA_USING_GPIO9 config I2C0_SDA_USING_GPIO9
bool "GPIO_9" bool "GPIO_9"
config I2C0_SDA_USING_GPIO11 config I2C0_SDA_USING_GPIO11
bool "GPIO_11" bool "GPIO_11"
config I2C0_SDA_USING_GPIO13 config I2C0_SDA_USING_GPIO13
bool "GPIO_13" bool "GPIO_13"
config I2C0_SDA_USING_GPIO15 config I2C0_SDA_USING_GPIO15
bool "GPIO_15" bool "GPIO_15"
config I2C0_SDA_USING_GPIO17 config I2C0_SDA_USING_GPIO17
bool "GPIO_17" bool "GPIO_17"
config I2C0_SDA_USING_GPIO19 config I2C0_SDA_USING_GPIO19
bool "GPIO_19" bool "GPIO_19"
config I2C0_SDA_USING_GPIO21 config I2C0_SDA_USING_GPIO21
bool "GPIO_21" bool "GPIO_21"
config I2C0_SDA_USING_GPIO23 config I2C0_SDA_USING_GPIO23
depends on BSP_USING_BL61X || BSP_USING_BL70X || BSP_USING_BL808 depends on BSP_USING_BL61X || BSP_USING_BL70X || BSP_USING_BL808
bool "GPIO_23" bool "GPIO_23"
config I2C0_SDA_USING_GPIO25 config I2C0_SDA_USING_GPIO25
depends on BSP_USING_BL61X || BSP_USING_BL70X || BSP_USING_BL808 depends on BSP_USING_BL61X || BSP_USING_BL70X || BSP_USING_BL808
bool "GPIO_25" bool "GPIO_25"
config I2C0_SDA_USING_GPIO27 config I2C0_SDA_USING_GPIO27
depends on BSP_USING_BL61X || BSP_USING_BL70X || BSP_USING_BL808 depends on BSP_USING_BL61X || BSP_USING_BL70X || BSP_USING_BL808
bool "GPIO_27" bool "GPIO_27"
config I2C0_SDA_USING_GPIO29 config I2C0_SDA_USING_GPIO29
depends on BSP_USING_BL61X || BSP_USING_BL70X || BSP_USING_BL808 depends on BSP_USING_BL61X || BSP_USING_BL70X || BSP_USING_BL808
bool "GPIO_29" bool "GPIO_29"
config I2C0_SDA_USING_GPIO31 config I2C0_SDA_USING_GPIO31
depends on BSP_USING_BL61X || BSP_USING_BL70X || BSP_USING_BL808 depends on BSP_USING_BL61X || BSP_USING_BL70X || BSP_USING_BL808
bool "GPIO_31" bool "GPIO_31"
config I2C0_SDA_USING_GPIO33 config I2C0_SDA_USING_GPIO33
depends on BSP_USING_BL61X || BSP_USING_BL808 depends on BSP_USING_BL61X || BSP_USING_BL808
bool "GPIO_33" bool "GPIO_33"
config I2C0_SDA_USING_GPIO35 config I2C0_SDA_USING_GPIO35
depends on BSP_USING_BL808 depends on BSP_USING_BL808
bool "GPIO_35" bool "GPIO_35"
config I2C0_SDA_USING_GPIO37 config I2C0_SDA_USING_GPIO37
depends on BSP_USING_BL808 depends on BSP_USING_BL808
bool "GPIO_37" bool "GPIO_37"
config I2C0_SDA_USING_GPIO39 config I2C0_SDA_USING_GPIO39
depends on BSP_USING_BL808 depends on BSP_USING_BL808
bool "GPIO_39" bool "GPIO_39"
config I2C0_SDA_USING_GPIO41 config I2C0_SDA_USING_GPIO41
depends on BSP_USING_BL808 depends on BSP_USING_BL808
bool "GPIO_41" bool "GPIO_41"
config I2C0_SDA_USING_GPIO43 config I2C0_SDA_USING_GPIO43
depends on BSP_USING_BL808 depends on BSP_USING_BL808
bool "GPIO_43" bool "GPIO_43"
config I2C0_SDA_USING_GPIO45 config I2C0_SDA_USING_GPIO45
depends on BSP_USING_BL808 depends on BSP_USING_BL808
bool "GPIO_45" bool "GPIO_45"
endchoice endchoice
config I2C0_FREQUENCY config I2C0_FREQUENCY
int "I2C0 Frequency" int "I2C0 Frequency"
default 400000 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 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 config SOFT_I2C1_SCL_USING_GPIO0
depends on BSP_USING_BL61X || BSP_USING_BL808 bool "GPIO_0"
bool "Enable I2C1" config SOFT_I2C1_SCL_USING_GPIO2
default n bool "GPIO_2"
if BSP_USING_I2C1 config SOFT_I2C1_SCL_USING_GPIO4
choice bool "GPIO_4"
prompt "I2C1 SCL" config SOFT_I2C1_SCL_USING_GPIO6
default I2C1_SCL_USING_GPIO0 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 choice
bool "GPIO_0" prompt "I2C1 SDA"
config I2C1_SCL_USING_GPIO2 default SOFT_I2C1_SDA_USING_GPIO1
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 config SOFT_I2C1_SDA_USING_GPIO1
prompt "I2C1 SDA" bool "GPIO_1"
default I2C1_SDA_USING_GPIO1 config SOFT_I2C1_SDA_USING_GPIO3
bool "GPIO_3"
config I2C1_SDA_USING_GPIO1 config SOFT_I2C1_SDA_USING_GPIO5
bool "GPIO_1" bool "GPIO_5"
config I2C1_SDA_USING_GPIO3 config SOFT_I2C1_SDA_USING_GPIO7
bool "GPIO_3" bool "GPIO_7"
config I2C1_SDA_USING_GPIO5 config SOFT_I2C1_SDA_USING_GPIO9
bool "GPIO_5" bool "GPIO_9"
config I2C1_SDA_USING_GPIO7 config SOFT_I2C1_SDA_USING_GPIO11
bool "GPIO_7" bool "GPIO_11"
config I2C1_SDA_USING_GPIO9 config SOFT_I2C1_SDA_USING_GPIO13
bool "GPIO_9" bool "GPIO_13"
config I2C1_SDA_USING_GPIO11 config SOFT_I2C1_SDA_USING_GPIO15
bool "GPIO_11" bool "GPIO_15"
config I2C1_SDA_USING_GPIO13 config SOFT_I2C1_SDA_USING_GPIO17
bool "GPIO_13" bool "GPIO_17"
config I2C1_SDA_USING_GPIO15 config SOFT_I2C1_SDA_USING_GPIO19
bool "GPIO_15" bool "GPIO_19"
config I2C1_SDA_USING_GPIO17 config SOFT_I2C1_SDA_USING_GPIO21
bool "GPIO_17" bool "GPIO_21"
config I2C1_SDA_USING_GPIO19 config SOFT_I2C1_SDA_USING_GPIO23
bool "GPIO_19" bool "GPIO_23"
config I2C1_SDA_USING_GPIO21 config SOFT_I2C1_SDA_USING_GPIO25
bool "GPIO_21" bool "GPIO_25"
config I2C1_SDA_USING_GPIO23 config SOFT_I2C1_SDA_USING_GPIO27
bool "GPIO_23" bool "GPIO_27"
config I2C1_SDA_USING_GPIO25 config SOFT_I2C1_SDA_USING_GPIO29
bool "GPIO_25" bool "GPIO_29"
config I2C1_SDA_USING_GPIO27 config SOFT_I2C1_SDA_USING_GPIO31
bool "GPIO_27" bool "GPIO_31"
config I2C1_SDA_USING_GPIO29 config SOFT_I2C1_SDA_USING_GPIO33
bool "GPIO_29" bool "GPIO_33"
config I2C1_SDA_USING_GPIO31 config SOFT_I2C1_SDA_USING_GPIO35
bool "GPIO_31" depends on BSP_USING_BL808
config I2C1_SDA_USING_GPIO33 bool "GPIO_35"
bool "GPIO_33" config SOFT_I2C1_SDA_USING_GPIO37
config I2C1_SDA_USING_GPIO35 depends on BSP_USING_BL808
depends on BSP_USING_BL808 bool "GPIO_37"
bool "GPIO_35" config SOFT_I2C1_SDA_USING_GPIO39
config I2C1_SDA_USING_GPIO37 depends on BSP_USING_BL808
depends on BSP_USING_BL808 bool "GPIO_39"
bool "GPIO_37" config SOFT_I2C1_SDA_USING_GPIO41
config I2C1_SDA_USING_GPIO39 depends on BSP_USING_BL808
depends on BSP_USING_BL808 bool "GPIO_41"
bool "GPIO_39" config SOFT_I2C1_SDA_USING_GPIO43
config I2C1_SDA_USING_GPIO41 depends on BSP_USING_BL808
depends on BSP_USING_BL808 bool "GPIO_43"
bool "GPIO_41" config SOFT_I2C1_SDA_USING_GPIO45
config I2C1_SDA_USING_GPIO43 depends on BSP_USING_BL808
depends on BSP_USING_BL808 bool "GPIO_45"
bool "GPIO_43" endchoice
config I2C1_SDA_USING_GPIO45 endif
depends on BSP_USING_BL808 endif
bool "GPIO_45"
endchoice
config I2C1_FREQUENCY
int "I2C1 Frequency"
default 400000
endif
endif endif
menuconfig BSP_USING_SPI menuconfig BSP_USING_SPI
@ -1290,4 +1415,3 @@ menu "General Drivers Configuration"
default n default n
endif endif
endmenu endmenu

View File

@ -9,9 +9,12 @@ CPPPATH = [cwd]
if GetDepend('BSP_USING_GPIO'): if GetDepend('BSP_USING_GPIO'):
src += ['drv_gpio.c'] src += ['drv_gpio.c']
if GetDepend('BSP_USING_I2C'): if GetDepend('BSP_USING_HW_I2C'):
src += ['drv_i2c.c'] src += ['drv_i2c.c']
if GetDepend('BSP_USING_SOFT_I2C1'):
src += ['drv_soft_i2c.c']
if GetDepend('BSP_USING_ADC'): if GetDepend('BSP_USING_ADC'):
src += ['drv_adc.c'] src += ['drv_adc.c']

View File

@ -12,7 +12,7 @@
#include "drv_gpio.h" #include "drv_gpio.h"
#include <stdbool.h> #include <stdbool.h>
#ifdef BSP_USING_PIN #ifdef BSP_USING_GPIO
#define DBG_TAG "drv.gpio" #define DBG_TAG "drv.gpio"
#define DBG_LVL DBG_INFO #define DBG_LVL DBG_INFO
@ -227,4 +227,4 @@ int rt_hw_pin_init(void)
} }
INIT_BOARD_EXPORT(rt_hw_pin_init); INIT_BOARD_EXPORT(rt_hw_pin_init);
#endif /*BSP_USING_PIN */ #endif /*BSP_USING_GPIO */

View File

@ -12,45 +12,112 @@
#include "bflb_gpio.h" #include "bflb_gpio.h"
#include "bflb_common.h" #include "bflb_common.h"
#ifdef BSP_USING_I2C #ifdef BSP_USING_SOFT_I2C1
#define DBG_LEVEL DBG_LOG #define DBG_LEVEL DBG_LOG
#include <rtdbg.h> #include <rtdbg.h>
#define LOG_TAG "DRV.I2C" #define LOG_TAG "DRV.I2C"
#if !defined(BSP_USING_I2C1) && !defined(BSP_USING_I2C2) // i2c1
#error "Please define at least one BSP_USING_I2Cx" #ifdef SOFT_I2C1_SCL_USING_GPIO0
/* this driver can be disabled at menuconfig -> RT-Thread Components -> Device Drivers */
#endif
// uart1
#ifdef I2C1_SCL_USING_GPIO0
#define BSP_I2C1_SCL_PIN GPIO_PIN_0 #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 #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 #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 #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 #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 #endif
#ifdef I2C1_SDA_USING_GPIO1 #ifdef SOFT_I2C1_SDA_USING_GPIO1
#define BSP_I2C1_SDA_PIN GPIO_PIN_1 #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 #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 #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 #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 #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 #endif
static const struct bl_soft_i2c_config soft_i2c_config[] = static const struct bl_soft_i2c_config soft_i2c_config[] =
{ {
#ifdef BSP_USING_I2C1 #ifdef BSP_USING_SOFT_I2C1
I2C1_BUS_CONFIG, I2C1_BUS_CONFIG,
#endif #endif
}; };
@ -140,7 +207,7 @@ static rt_int32_t bl_get_scl(void *data)
*/ */
static void bl_udelay(rt_uint32_t us) 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 = 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); INIT_BOARD_EXPORT(rt_hw_i2c_init);
#endif /* BSP_USING_I2C */ #endif /* BSP_USING_SOFT_I2C1 */

View File

@ -30,7 +30,7 @@ struct bl_soft_i2c_config
const char *bus_name; const char *bus_name;
}; };
#ifdef BSP_USING_I2C1 #ifdef BSP_USING_SOFT_I2C1
#define I2C1_BUS_CONFIG \ #define I2C1_BUS_CONFIG \
{ \ { \
.scl = BSP_I2C1_SCL_PIN, \ .scl = BSP_I2C1_SCL_PIN, \