[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
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

View File

@ -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']

View File

@ -12,7 +12,7 @@
#include "drv_gpio.h"
#include <stdbool.h>
#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 */

View File

@ -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 <rtdbg.h>
#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 */

View File

@ -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, \