Skip to content

Commit 23f91e8

Browse files
authored
[bsp/bouffalo_lab]add drv_i2c (#7473)
1 parent 4f8d453 commit 23f91e8

File tree

4 files changed

+853
-44
lines changed

4 files changed

+853
-44
lines changed

Diff for: bsp/bouffalo_lab/libraries/rt_drivers/Kconfig

+266-43
Original file line numberDiff line numberDiff line change
@@ -707,55 +707,277 @@ menu "General Drivers Configuration"
707707
default n
708708
endif
709709

710-
menu "General Purpose I2C"
711-
menuconfig BSP_USING_I2C1
712-
bool "Enable I2C1"
713-
default n
714-
select BSP_USING_I2C
710+
menuconfig BSP_USING_I2C
711+
bool "Enable I2C"
715712
select RT_USING_I2C
716-
select RT_USING_I2C_BITOPS
717-
select RT_USING_PIN
718-
if BSP_USING_I2C1
719-
choice
720-
prompt "I2C1 SCL PIN"
721-
default I2C1_SCL_USING_GPIO4 if BSP_USING_BL60X
722-
default I2C1_SCL_USING_GPIO10 if BSP_USING_BL61X
723-
default I2C1_SCL_USING_GPIO08 if BSP_USING_BL70X
724-
default I2C1_SCL_USING_GPIO20 if BSP_USING_BL808
713+
default n
725714

726-
config I2C1_SCL_USING_GPIO0
727-
bool "GPIO_0"
728-
config I2C1_SCL_USING_GPIO4
729-
bool "GPIO_4"
730-
config I2C1_SCL_USING_GPIO8
731-
bool "GPIO_8"
732-
config I2C1_SCL_USING_GPIO10
733-
bool "GPIO_10"
734-
config I2C1_SCL_USING_GPIO20
735-
bool "GPIO_20"
715+
if BSP_USING_I2C
716+
menuconfig BSP_USING_I2C0
717+
bool "Enable I2C0"
718+
default n
719+
if BSP_USING_I2C0
720+
choice
721+
prompt "I2C0 SCL"
722+
default I2C0_SCL_USING_GPIO14
736723

737-
endchoice
738-
choice
739-
prompt "I2C1 SDA PIN"
740-
default I2C1_SDA_USING_GPIO3 if BSP_USING_BL60X
741-
default I2C1_SDA_USING_GPIO11 if BSP_USING_BL61X
742-
default I2C1_SDA_USING_GPIO7 if BSP_USING_BL70X
743-
default I2C1_SDA_USING_GPIO21 if BSP_USING_BL808
724+
config I2C0_SCL_USING_GPIO0
725+
bool "GPIO_0"
726+
config I2C0_SCL_USING_GPIO2
727+
bool "GPIO_2"
728+
config I2C0_SCL_USING_GPIO4
729+
bool "GPIO_4"
730+
config I2C0_SCL_USING_GPIO6
731+
bool "GPIO_6"
732+
config I2C0_SCL_USING_GPIO8
733+
bool "GPIO_8"
734+
config I2C0_SCL_USING_GPIO8
735+
bool "GPIO_8"
736+
config I2C0_SCL_USING_GPIO10
737+
bool "GPIO_10"
738+
config I2C0_SCL_USING_GPIO12
739+
bool "GPIO_12"
740+
config I2C0_SCL_USING_GPIO14
741+
bool "GPIO_14"
742+
config I2C0_SCL_USING_GPIO16
743+
bool "GPIO_16"
744+
config I2C0_SCL_USING_GPIO18
745+
bool "GPIO_18"
746+
config I2C0_SCL_USING_GPIO20
747+
bool "GPIO_20"
748+
config I2C0_SCL_USING_GPIO22
749+
bool "GPIO_22"
750+
config I2C0_SCL_USING_GPIO24
751+
depends on BSP_USING_BL61X || BSP_USING_BL70X || BSP_USING_BL808
752+
bool "GPIO_8"
753+
config I2C0_SCL_USING_GPIO26
754+
depends on BSP_USING_BL61X || BSP_USING_BL70X || BSP_USING_BL808
755+
bool "GPIO_26"
756+
config I2C0_SCL_USING_GPIO28
757+
depends on BSP_USING_BL61X || BSP_USING_BL70X || BSP_USING_BL808
758+
bool "GPIO_28"
759+
config I2C0_SCL_USING_GPIO30
760+
depends on BSP_USING_BL61X || BSP_USING_BL70X || BSP_USING_BL808
761+
bool "GPIO_30"
762+
config I2C0_SCL_USING_GPIO32
763+
depends on BSP_USING_BL61X || BSP_USING_BL808
764+
bool "GPIO_32"
765+
config I2C0_SCL_USING_GPIO34
766+
depends on BSP_USING_BL61X || BSP_USING_BL808
767+
bool "GPIO_34"
768+
config I2C0_SDA_USING_GPIO36
769+
depends on BSP_USING_BL808
770+
bool "GPIO_36"
771+
config I2C0_SDA_USING_GPIO38
772+
depends on BSP_USING_BL808
773+
bool "GPIO_38"
774+
config I2C0_SDA_USING_GPIO40
775+
depends on BSP_USING_BL808
776+
bool "GPIO_40"
777+
config I2C1_SDA_USING_GPIO42
778+
depends on BSP_USING_BL808
779+
bool "GPIO_42"
780+
config I2C0_SDA_USING_GPIO44
781+
depends on BSP_USING_BL808
782+
bool "GPIO_44"
783+
endchoice
744784

745-
config I2C1_SDA_USING_GPIO1
746-
bool "GPIO_1"
747-
config I2C1_SDA_USING_GPIO3
748-
bool "GPIO_3"
749-
config I2C1_SDA_USING_GPIO7
750-
bool "GPIO_7"
751-
config I2C1_SDA_USING_GPIO11
752-
bool "GPIO_11"
753-
config I2C1_SDA_USING_GPIO21
754-
bool "GPIO_21"
785+
choice
786+
prompt "I2C0 SDA"
787+
default I2C0_SDA_USING_GPIO15
755788

756-
endchoice
789+
config I2C0_SDA_USING_GPIO1
790+
bool "GPIO_1"
791+
config I2C0_SDA_USING_GPIO3
792+
bool "GPIO_3"
793+
config I2C0_SDA_USING_GPIO5
794+
bool "GPIO_5"
795+
config I2C0_SDA_USING_GPIO7
796+
bool "GPIO_7"
797+
config I2C0_SDA_USING_GPIO9
798+
bool "GPIO_9"
799+
config I2C0_SDA_USING_GPIO11
800+
bool "GPIO_11"
801+
config I2C0_SDA_USING_GPIO13
802+
bool "GPIO_13"
803+
config I2C0_SDA_USING_GPIO15
804+
bool "GPIO_15"
805+
config I2C0_SDA_USING_GPIO17
806+
bool "GPIO_17"
807+
config I2C0_SDA_USING_GPIO19
808+
bool "GPIO_19"
809+
config I2C0_SDA_USING_GPIO21
810+
bool "GPIO_21"
811+
config I2C0_SDA_USING_GPIO23
812+
depends on BSP_USING_BL61X || BSP_USING_BL70X || BSP_USING_BL808
813+
bool "GPIO_23"
814+
config I2C0_SDA_USING_GPIO25
815+
depends on BSP_USING_BL61X || BSP_USING_BL70X || BSP_USING_BL808
816+
bool "GPIO_25"
817+
config I2C0_SDA_USING_GPIO27
818+
depends on BSP_USING_BL61X || BSP_USING_BL70X || BSP_USING_BL808
819+
bool "GPIO_27"
820+
config I2C0_SDA_USING_GPIO29
821+
depends on BSP_USING_BL61X || BSP_USING_BL70X || BSP_USING_BL808
822+
bool "GPIO_29"
823+
config I2C0_SDA_USING_GPIO31
824+
depends on BSP_USING_BL61X || BSP_USING_BL70X || BSP_USING_BL808
825+
bool "GPIO_31"
826+
config I2C0_SDA_USING_GPIO33
827+
depends on BSP_USING_BL61X || BSP_USING_BL808
828+
bool "GPIO_33"
829+
config I2C0_SDA_USING_GPIO35
830+
depends on BSP_USING_BL808
831+
bool "GPIO_35"
832+
config I2C0_SDA_USING_GPIO37
833+
depends on BSP_USING_BL808
834+
bool "GPIO_37"
835+
config I2C0_SDA_USING_GPIO39
836+
depends on BSP_USING_BL808
837+
bool "GPIO_39"
838+
config I2C0_SDA_USING_GPIO41
839+
depends on BSP_USING_BL808
840+
bool "GPIO_41"
841+
config I2C0_SDA_USING_GPIO43
842+
depends on BSP_USING_BL808
843+
bool "GPIO_43"
844+
config I2C0_SDA_USING_GPIO45
845+
depends on BSP_USING_BL808
846+
bool "GPIO_45"
847+
endchoice
848+
849+
config I2C0_FREQUENCY
850+
int "I2C0 Frequency"
851+
default 400000
852+
endif
853+
854+
menuconfig BSP_USING_I2C1
855+
depends on BSP_USING_BL61X || BSP_USING_BL808
856+
bool "Enable I2C1"
857+
default n
858+
if BSP_USING_I2C1
859+
choice
860+
prompt "I2C1 SCL"
861+
default I2C1_SCL_USING_GPIO0
862+
863+
config I2C1_SCL_USING_GPIO0
864+
bool "GPIO_0"
865+
config I2C1_SCL_USING_GPIO2
866+
bool "GPIO_2"
867+
config I2C1_SCL_USING_GPIO4
868+
bool "GPIO_4"
869+
config I2C1_SCL_USING_GPIO6
870+
bool "GPIO_6"
871+
config I2C1_SCL_USING_GPIO8
872+
bool "GPIO_8"
873+
config I2C1_SCL_USING_GPIO8
874+
bool "GPIO_8"
875+
config I2C1_SCL_USING_GPIO10
876+
bool "GPIO_10"
877+
config I2C1_SCL_USING_GPIO12
878+
bool "GPIO_12"
879+
config I2C1_SCL_USING_GPIO14
880+
bool "GPIO_14"
881+
config I2C1_SCL_USING_GPIO16
882+
bool "GPIO_16"
883+
config I2C1_SCL_USING_GPIO18
884+
bool "GPIO_18"
885+
config I2C1_SCL_USING_GPIO20
886+
bool "GPIO_20"
887+
config I2C1_SCL_USING_GPIO22
888+
bool "GPIO_22"
889+
config I2C1_SCL_USING_GPIO24
890+
bool "GPIO_8"
891+
config I2C1_SCL_USING_GPIO26
892+
bool "GPIO_26"
893+
config I2C1_SCL_USING_GPIO28
894+
bool "GPIO_28"
895+
config I2C1_SCL_USING_GPIO30
896+
bool "GPIO_30"
897+
config I2C1_SCL_USING_GPIO32
898+
bool "GPIO_32"
899+
config I2C1_SCL_USING_GPIO34
900+
bool "GPIO_34"
901+
config I2C1_SDA_USING_GPIO36
902+
depends on BSP_USING_BL808
903+
bool "GPIO_36"
904+
config I2C1_SDA_USING_GPIO38
905+
depends on BSP_USING_BL808
906+
bool "GPIO_38"
907+
config I2C1_SDA_USING_GPIO40
908+
depends on BSP_USING_BL808
909+
bool "GPIO_40"
910+
config I2C1_SDA_USING_GPIO42
911+
depends on BSP_USING_BL808
912+
bool "GPIO_42"
913+
config I2C1_SDA_USING_GPIO44
914+
depends on BSP_USING_BL808
915+
bool "GPIO_44"
916+
endchoice
917+
918+
choice
919+
prompt "I2C1 SDA"
920+
default I2C1_SDA_USING_GPIO1
921+
922+
config I2C1_SDA_USING_GPIO1
923+
bool "GPIO_1"
924+
config I2C1_SDA_USING_GPIO3
925+
bool "GPIO_3"
926+
config I2C1_SDA_USING_GPIO5
927+
bool "GPIO_5"
928+
config I2C1_SDA_USING_GPIO7
929+
bool "GPIO_7"
930+
config I2C1_SDA_USING_GPIO9
931+
bool "GPIO_9"
932+
config I2C1_SDA_USING_GPIO11
933+
bool "GPIO_11"
934+
config I2C1_SDA_USING_GPIO13
935+
bool "GPIO_13"
936+
config I2C1_SDA_USING_GPIO15
937+
bool "GPIO_15"
938+
config I2C1_SDA_USING_GPIO17
939+
bool "GPIO_17"
940+
config I2C1_SDA_USING_GPIO19
941+
bool "GPIO_19"
942+
config I2C1_SDA_USING_GPIO21
943+
bool "GPIO_21"
944+
config I2C1_SDA_USING_GPIO23
945+
bool "GPIO_23"
946+
config I2C1_SDA_USING_GPIO25
947+
bool "GPIO_25"
948+
config I2C1_SDA_USING_GPIO27
949+
bool "GPIO_27"
950+
config I2C1_SDA_USING_GPIO29
951+
bool "GPIO_29"
952+
config I2C1_SDA_USING_GPIO31
953+
bool "GPIO_31"
954+
config I2C1_SDA_USING_GPIO33
955+
bool "GPIO_33"
956+
config I2C1_SDA_USING_GPIO35
957+
depends on BSP_USING_BL808
958+
bool "GPIO_35"
959+
config I2C1_SDA_USING_GPIO37
960+
depends on BSP_USING_BL808
961+
bool "GPIO_37"
962+
config I2C1_SDA_USING_GPIO39
963+
depends on BSP_USING_BL808
964+
bool "GPIO_39"
965+
config I2C1_SDA_USING_GPIO41
966+
depends on BSP_USING_BL808
967+
bool "GPIO_41"
968+
config I2C1_SDA_USING_GPIO43
969+
depends on BSP_USING_BL808
970+
bool "GPIO_43"
971+
config I2C1_SDA_USING_GPIO45
972+
depends on BSP_USING_BL808
973+
bool "GPIO_45"
974+
endchoice
975+
976+
config I2C1_FREQUENCY
977+
int "I2C1 Frequency"
978+
default 400000
979+
endif
757980
endif
758-
endmenu
759981

760982
menuconfig BSP_USING_SPI
761983
bool "Enable SPI"
@@ -1049,6 +1271,7 @@ menu "General Drivers Configuration"
10491271
range 0 4095
10501272
endif
10511273
endif
1274+
10521275
config BSP_USING_ON_CHIP_FLASH
10531276
bool "Enable On-Chip FLASH"
10541277
default n

Diff for: bsp/bouffalo_lab/libraries/rt_drivers/SConscript

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ if GetDepend('BSP_USING_GPIO'):
1010
src += ['drv_gpio.c']
1111

1212
if GetDepend('BSP_USING_I2C'):
13-
src += ['drv_soft_i2c.c']
13+
src += ['drv_i2c.c']
1414

1515
if GetDepend('BSP_USING_ADC'):
1616
src += ['drv_adc.c']

0 commit comments

Comments
 (0)