Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions bsp/k230/.ci/attachconfig/ci.attachconfig.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
scons.args: &scons
scons_arg:
- '--strict'
devices.i2c:
<<: *scons
kconfig:
- CONFIG_RT_USING_I2C=y
- CONFIG_BSP_USING_I2C=y
- CONFIG_BSP_USING_I2C0=y
devices.i2c.master:
<<: *scons
depends:
- devices.i2c
kconfig:
- CONFIG_BSP_USING_I2C0_MASTER=y
devices.i2c.slave:
<<: *scons
depends:
- devices.i2c
kconfig:
- CONFIG_BSP_USING_I2C0_SLAVE=y
9 changes: 8 additions & 1 deletion bsp/k230/.config
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,7 @@ CONFIG_FINSH_THREAD_STACK_SIZE=8192
CONFIG_FINSH_USING_HISTORY=y
CONFIG_FINSH_HISTORY_LINES=5
# CONFIG_FINSH_USING_WORD_OPERATION is not set
# CONFIG_FINSH_USING_FUNC_EXT is not set
CONFIG_FINSH_USING_SYMTAB=y
CONFIG_FINSH_CMD_SIZE=80
CONFIG_MSH_USING_BUILT_IN_COMMANDS=y
Expand Down Expand Up @@ -313,7 +314,11 @@ CONFIG_RT_USING_SERIAL_BYPASS=y
CONFIG_RT_USING_CPUTIME=y
CONFIG_RT_USING_CPUTIME_RISCV=y
CONFIG_CPUTIME_TIMER_FREQ=25000000
# CONFIG_RT_USING_I2C is not set
CONFIG_RT_USING_I2C=y
# CONFIG_RT_I2C_DEBUG is not set
CONFIG_RT_USING_I2C_BITOPS=y
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CONFIG_RT_USING_I2C 和 CONFIG_RT_USING_I2C_BITOPS 为何会新增?是不是本地测试后 commit 时忘记清除了?
请最终提交时确保回退所有 .configrtconfig.h 的改动,然后只执行过一次 scons --menuconfig

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这个我提交之前把.config重置了,然后打开menuconfig,然后保存一下

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这个我提交之前把.config重置了,然后打开menuconfig,然后保存一下

你想说明什么问题我没有看懂,但实际问题就是这些 I2C 的配置默认就是关的,你这里开了是不对的。

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

提交之前回退过,可能是又测试过,我改了之后处理一下

# CONFIG_RT_I2C_BITOPS_DEBUG is not set
# CONFIG_RT_USING_SOFT_I2C is not set
# CONFIG_RT_USING_PHY is not set
# CONFIG_RT_USING_PHY_V2 is not set
# CONFIG_RT_USING_ADC is not set
Expand Down Expand Up @@ -425,6 +430,7 @@ CONFIG_RT_USING_POSIX_TIMER=y
#
CONFIG_RT_USING_SAL=y
CONFIG_SAL_INTERNET_CHECK=y
CONFIG_SOCKET_TABLE_STEP_LEN=4
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这个选项为何会新增?是因为执行 scons --menuconfig 自动加上的还是自己手动加上的结果?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这确认了,就是自动加的


#
# Docking with protocol stacks
Expand Down Expand Up @@ -1617,6 +1623,7 @@ CONFIG_PKG_ZLIB_VER="latest"
#
# Drivers Configuration
#
# CONFIG_BSP_USING_I2C is not set
# CONFIG_BSP_USING_RTC is not set
# CONFIG_BSP_USING_ADC is not set
# CONFIG_BSP_USING_TS is not set
Expand Down
106 changes: 106 additions & 0 deletions bsp/k230/board/Kconfig
Original file line number Diff line number Diff line change
@@ -1,4 +1,110 @@
menu "Drivers Configuration"
menuconfig BSP_USING_I2C
bool "Enable I2C"
select RT_USING_I2C
default n

if BSP_USING_I2C
menuconfig BSP_USING_I2C0
bool "Enable I2C0"
default n

if BSP_USING_I2C0
choice BSP_I2C0_DEV_MODE
prompt "Select I2C0 device mode"
default BSP_USING_I2C0_MASTER
help
Select the I2C0 device mode to be used.
Comment on lines +16 to +17
Copy link

Copilot AI Oct 27, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

English: The help text should be bilingual (English and Chinese) to maintain consistency with RT-Thread's internationalization practices, similar to other BSP configurations in the project.
中文:帮助文本应使用双语(英文和中文)以保持与 RT-Thread 国际化实践的一致性,类似于项目中其他 BSP 配置。

Copilot uses AI. Check for mistakes.

config BSP_USING_I2C0_MASTER
bool "Enable I2C0 Master Mode"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

建议去掉这里提示里的 I2C0,此时处于 I2C0 的域中不会歧义,二来提示语也可以简短些。

下同,其他也一并修改。

另外有个疑问,既然这里 Mode 是一个简单的二选一类型,要么 master,要么 slave,为何不用简单的 bool 型,用 choice + 两个 config 看上去比较啰嗦,而且定义了两个 BSP_USING_I2C0_MASTER 和 BSP_USING_I2C0_SLAVE 也容易引起歧义,譬如现在搜索 drv_i2c.c 是找不到 BSP_USING_I2C0_MASTER 的,只有 BSP_USING_I2C0_SLAVE,让人有些迷惑。

直接用 bool 会简单很多,譬如:

if BSP_USING_I2C0
    config BSP_I2C0_MASTER
    bool "Master OR Slave"
    default y
    help
    Selected if Master, else Slave
endif

代码中只要判断 #ifdef BSP_I2C0_MASTER, 这个和目前代码中的逻辑也一致,但不会引入二意性

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

好的


config BSP_USING_I2C0_SLAVE
bool "Enable I2C0 Slave Mode"

endchoice
endif

menuconfig BSP_USING_I2C1
bool "Enable I2C1"
default n

if BSP_USING_I2C1
choice BSP_I2C1_DEV_MODE
prompt "Select I2C1 device mode"
default BSP_USING_I2C1_MASTER
help
Select the I2C1 device mode to be used.

config BSP_USING_I2C1_MASTER
bool "Enable I2C1 Master Mode"

config BSP_USING_I2C1_SLAVE
bool "Enable I2C1 Slave Mode"

endchoice
endif

menuconfig BSP_USING_I2C2
bool "Enable I2C2"
default n

if BSP_USING_I2C2
choice BSP_I2C2_DEV_MODE
prompt "Select I2C2 device mode"
default BSP_USING_I2C2_MASTER
help
Select the I2C2 device mode to be used.

config BSP_USING_I2C2_MASTER
bool "Enable I2C2 Master Mode"

config BSP_USING_I2C2_SLAVE
bool "Enable I2C2 Slave Mode"

endchoice
endif

menuconfig BSP_USING_I2C3
bool "Enable I2C3"
default n

if BSP_USING_I2C3
choice BSP_I2C3_DEV_MODE
prompt "Select I2C3 device mode"
default BSP_USING_I2C3_MASTER
help
Select the I2C3 device mode to be used.

config BSP_USING_I2C3_MASTER
bool "Enable I2C3 Master Mode"

config BSP_USING_I2C3_SLAVE
bool "Enable I2C3 Slave Mode"

endchoice
endif

menuconfig BSP_USING_I2C4
bool "Enable I2C4"
default n

if BSP_USING_I2C4
choice BSP_I2C4_DEV_MODE
prompt "Select I2C4 device mode"
default BSP_USING_I2C4_MASTER
help
Select the I2C4 device mode to be used.

config BSP_USING_I2C4_MASTER
bool "Enable I2C4 Master Mode"

config BSP_USING_I2C4_SLAVE
bool "Enable I2C4 Slave Mode"

endchoice
endif
endif

config BSP_USING_RTC
bool "Enable RTC"
Expand Down
11 changes: 11 additions & 0 deletions bsp/k230/drivers/interdrv/i2c/SConscript
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# RT-Thread building script for I2C component

from building import *

cwd = GetCurrentDir()
src = Glob('*.c')
CPPPATH = [cwd]

group = DefineGroup('I2C', src, depend = ['BSP_USING_I2C'], CPPPATH = CPPPATH)

Return('group')
Loading