-
Notifications
You must be signed in to change notification settings - Fork 5k
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
[components][i2c]增加通用的软件模拟 I2C #7850
Conversation
实现无需直接操作任何底层硬件的通用软件 I2C ,并提级到设备框架层,用于替代所有 BSP 的软件模拟 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.
建议还是保留之前的分层结构,这样维护代码会方便一些~,也可以解一些耦合~也便于维护
好的,我再改一下 |
已改好 |
@@ -55,9 +56,9 @@ struct rt_i2c_bus_device | |||
struct rt_device parent; | |||
const struct rt_i2c_bus_device_ops *ops; | |||
rt_uint16_t flags; | |||
rt_uint16_t retries; |
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.h 修改理由?
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.
一个操作的重试次数没必要用32位数值,16位数值更有利于字节对齐。
这个修改探讨一下
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.
你在哪里用到这个变量了?
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-bit-ops.c 这个文件用到的
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.
哦,你改了下位置。
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.
是的
@@ -55,9 +56,9 @@ struct rt_i2c_bus_device | |||
struct rt_device parent; | |||
const struct rt_i2c_bus_device_ops *ops; | |||
rt_uint16_t flags; | |||
rt_uint16_t retries; |
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.h 不建议修改。 |
文件 i2c.h 的更改是很谨慎的,已检索过所有代码确认是完全兼容的且无不良影响才改的。 |
i2c.h可以另外提PR |
好的,已改好 |
请耐心等待一下 这个PR还在决策怎么合入比较好 |
kconfig 处使用问题反馈与建议 config RT_SOFT_I2C1_SCL_PIN
int "SCL pin number"
range 0 32767
default 1
config RT_SOFT_I2C1_SDA_PIN
int "SDA pin number"
range 0 32767
default 2 pin引脚配置项采用的 int 类型 这样不方便引脚标号写入,建议更换为hex 方式更加友好 config RT_SOFT_I2C1_SCL_PIN
hex "SCL pin number"
range 0x00 0xFF
default 1
config RT_SOFT_I2C1_SDA_PIN
hex "SDA pin number"
range 0x00 0xFF
default 2 |
这个问题已讨论过,见上面有关 components/drivers/Kconfig 的讨论记录。 |
实现无需直接操作任何底层硬件的通用软件 I2C ,并提级到设备框架层,用于替代所有 BSP 的软件模拟 I2C 。
拉取/合并请求描述:(PR description)
[
为什么提交这份PR (why to submit this PR)
使用 pin 设备和软延时就可以实现软件模拟 I2C ,没必要每一个BSP都要实现一次。
#7725
你的解决方案是什么 (what is your solution)
在什么测试环境下测试通过 (what is the test environment)
使用 HK32F030 和 HC32F460 通过本软件模拟 I2C 读写 24C02 和 KT06XX 等。
]
当前拉取/合并请求的状态 Intent for your PR
必须选择一项 Choose one (Mandatory):
代码质量 Code Quality:
我在这个拉取/合并请求中已经考虑了 As part of this pull request, I've considered the following:
#if 0
代码,不包含已经被注释了的代码 All redundant code is removed and cleaned up