-
Notifications
You must be signed in to change notification settings - Fork 5.3k
bsp: k230: add i2c driver #10851
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
bsp: k230: add i2c driver #10851
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| 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 |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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 | ||
|
|
@@ -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 | ||
| # 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 | ||
|
|
@@ -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 | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 这个选项为何会新增?是因为执行 scons --menuconfig 自动加上的还是自己手动加上的结果?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 这确认了,就是自动加的 |
||
|
|
||
| # | ||
| # Docking with protocol stacks | ||
|
|
@@ -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 | ||
|
|
||
| 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
|
||
|
|
||
| config BSP_USING_I2C0_MASTER | ||
| bool "Enable I2C0 Master Mode" | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 会简单很多,譬如: 代码中只要判断
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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" | ||
|
|
||
| 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') |
There was a problem hiding this comment.
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 时忘记清除了?
请最终提交时确保回退所有
.config和rtconfig.h的改动,然后只执行过一次scons --menuconfig。There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这个我提交之前把.config重置了,然后打开menuconfig,然后保存一下
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
你想说明什么问题我没有看懂,但实际问题就是这些 I2C 的配置默认就是关的,你这里开了是不对的。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
提交之前回退过,可能是又测试过,我改了之后处理一下