Skip to content

Commit 4784db2

Browse files
committed
bsp: k230: add i2c driver
Requirement: The BSP for the k230 platform in the RT-Thread repository does not yet have an I2C driver. Solution: Provide I2C drivers for the k230 platform in the RT-Thread repository. 1. support i2c master mode 2. support i2c slave mode Signed-off-by: Ze-Hou <[email protected]>
1 parent 0cf096e commit 4784db2

File tree

8 files changed

+2048
-2
lines changed

8 files changed

+2048
-2
lines changed

bsp/k230/.config

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,7 @@ CONFIG_FINSH_THREAD_STACK_SIZE=8192
227227
CONFIG_FINSH_USING_HISTORY=y
228228
CONFIG_FINSH_HISTORY_LINES=5
229229
# CONFIG_FINSH_USING_WORD_OPERATION is not set
230+
# CONFIG_FINSH_USING_FUNC_EXT is not set
230231
CONFIG_FINSH_USING_SYMTAB=y
231232
CONFIG_FINSH_CMD_SIZE=80
232233
CONFIG_MSH_USING_BUILT_IN_COMMANDS=y
@@ -313,7 +314,11 @@ CONFIG_RT_USING_SERIAL_BYPASS=y
313314
CONFIG_RT_USING_CPUTIME=y
314315
CONFIG_RT_USING_CPUTIME_RISCV=y
315316
CONFIG_CPUTIME_TIMER_FREQ=25000000
316-
# CONFIG_RT_USING_I2C is not set
317+
CONFIG_RT_USING_I2C=y
318+
# CONFIG_RT_I2C_DEBUG is not set
319+
CONFIG_RT_USING_I2C_BITOPS=y
320+
# CONFIG_RT_I2C_BITOPS_DEBUG is not set
321+
# CONFIG_RT_USING_SOFT_I2C is not set
317322
# CONFIG_RT_USING_PHY is not set
318323
# CONFIG_RT_USING_PHY_V2 is not set
319324
# CONFIG_RT_USING_ADC is not set
@@ -425,6 +430,7 @@ CONFIG_RT_USING_POSIX_TIMER=y
425430
#
426431
CONFIG_RT_USING_SAL=y
427432
CONFIG_SAL_INTERNET_CHECK=y
433+
CONFIG_SOCKET_TABLE_STEP_LEN=4
428434

429435
#
430436
# Docking with protocol stacks
@@ -1617,6 +1623,7 @@ CONFIG_PKG_ZLIB_VER="latest"
16171623
#
16181624
# Drivers Configuration
16191625
#
1626+
# CONFIG_BSP_USING_I2C is not set
16201627
# CONFIG_BSP_USING_RTC is not set
16211628
# CONFIG_BSP_USING_ADC is not set
16221629
# CONFIG_BSP_USING_TS is not set

bsp/k230/board/Kconfig

Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,110 @@
11
menu "Drivers Configuration"
2+
menuconfig BSP_USING_I2C
3+
bool "Enable I2C"
4+
select RT_USING_I2C
5+
default n
6+
7+
if BSP_USING_I2C
8+
menuconfig BSP_USING_I2C0
9+
bool "Enable I2C0"
10+
default n
11+
12+
if BSP_USING_I2C0
13+
choice BSP_I2C0_DEV_MODE
14+
prompt "Select I2C0 device mode"
15+
default BSP_USING_I2C0_MASTER
16+
help
17+
Select the I2C0 device mode to be used.
18+
19+
config BSP_USING_I2C0_MASTER
20+
bool "Enable I2C0 Master Mode"
21+
22+
config BSP_USING_I2C0_SLAVE
23+
bool "Enable I2C0 Slave Mode"
24+
25+
endchoice
26+
endif
27+
28+
menuconfig BSP_USING_I2C1
29+
bool "Enable I2C1"
30+
default n
31+
32+
if BSP_USING_I2C1
33+
choice BSP_I2C1_DEV_MODE
34+
prompt "Select I2C1 device mode"
35+
default BSP_USING_I2C1_MASTER
36+
help
37+
Select the I2C1 device mode to be used.
38+
39+
config BSP_USING_I2C1_MASTER
40+
bool "Enable I2C1 Master Mode"
41+
42+
config BSP_USING_I2C1_SLAVE
43+
bool "Enable I2C1 Slave Mode"
44+
45+
endchoice
46+
endif
47+
48+
menuconfig BSP_USING_I2C2
49+
bool "Enable I2C2"
50+
default n
51+
52+
if BSP_USING_I2C2
53+
choice BSP_I2C2_DEV_MODE
54+
prompt "Select I2C2 device mode"
55+
default BSP_USING_I2C2_MASTER
56+
help
57+
Select the I2C2 device mode to be used.
58+
59+
config BSP_USING_I2C2_MASTER
60+
bool "Enable I2C2 Master Mode"
61+
62+
config BSP_USING_I2C2_SLAVE
63+
bool "Enable I2C2 Slave Mode"
64+
65+
endchoice
66+
endif
67+
68+
menuconfig BSP_USING_I2C3
69+
bool "Enable I2C3"
70+
default n
71+
72+
if BSP_USING_I2C3
73+
choice BSP_I2C3_DEV_MODE
74+
prompt "Select I2C3 device mode"
75+
default BSP_USING_I2C3_MASTER
76+
help
77+
Select the I2C3 device mode to be used.
78+
79+
config BSP_USING_I2C3_MASTER
80+
bool "Enable I2C3 Master Mode"
81+
82+
config BSP_USING_I2C3_SLAVE
83+
bool "Enable I2C3 Slave Mode"
84+
85+
endchoice
86+
endif
87+
88+
menuconfig BSP_USING_I2C4
89+
bool "Enable I2C4"
90+
default n
91+
92+
if BSP_USING_I2C4
93+
choice BSP_I2C4_DEV_MODE
94+
prompt "Select I2C4 device mode"
95+
default BSP_USING_I2C4_MASTER
96+
help
97+
Select the I2C4 device mode to be used.
98+
99+
config BSP_USING_I2C4_MASTER
100+
bool "Enable I2C4 Master Mode"
101+
102+
config BSP_USING_I2C4_SLAVE
103+
bool "Enable I2C4 Slave Mode"
104+
105+
endchoice
106+
endif
107+
endif
2108

3109
config BSP_USING_RTC
4110
bool "Enable RTC"
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# RT-Thread building script for RTC component
2+
3+
from building import *
4+
5+
cwd = GetCurrentDir()
6+
src = Glob('*.c')
7+
CPPPATH = [cwd]
8+
9+
group = DefineGroup('I2C', src, depend = ['BSP_USING_I2C'], CPPPATH = CPPPATH)
10+
11+
Return('group')

0 commit comments

Comments
 (0)