Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
u010088926
rt-thread
提交
75e13c68
R
rt-thread
项目概览
u010088926
/
rt-thread
与 Fork 源项目一致
Fork自
RT-Thread / rt-thread
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
R
rt-thread
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
75e13c68
编写于
4月 25, 2021
作者:
B
Bernard Xiong
提交者:
GitHub
4月 25, 2021
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #4631 from rtthread-bot/rtt_bot
[update] RT-Thread Robot automatic submission
上级
f251cf15
82788987
变更
4
显示空白变更内容
内联
并排
Showing
4 changed file
with
37 addition
and
0 deletion
+37
-0
components/drivers/i2c/i2c_core.c
components/drivers/i2c/i2c_core.c
+21
-0
components/drivers/i2c/i2c_dev.c
components/drivers/i2c/i2c_dev.c
+10
-0
components/drivers/include/drivers/i2c.h
components/drivers/include/drivers/i2c.h
+4
-0
components/drivers/include/drivers/i2c_dev.h
components/drivers/include/drivers/i2c_dev.h
+2
-0
未找到文件。
components/drivers/i2c/i2c_core.c
浏览文件 @
75e13c68
...
...
@@ -6,6 +6,7 @@
* Change Logs:
* Date Author Notes
* 2012-04-25 weety first version
* 2021-04-20 RiceChen added support for bus control api
*/
#include <rtdevice.h>
...
...
@@ -81,6 +82,26 @@ rt_size_t rt_i2c_transfer(struct rt_i2c_bus_device *bus,
}
}
rt_err_t
rt_i2c_control
(
struct
rt_i2c_bus_device
*
bus
,
rt_uint32_t
cmd
,
rt_uint32_t
arg
)
{
rt_err_t
ret
;
if
(
bus
->
ops
->
i2c_bus_control
)
{
ret
=
bus
->
ops
->
i2c_bus_control
(
bus
,
cmd
,
arg
);
return
ret
;
}
else
{
LOG_E
(
"I2C bus operation not supported"
);
return
0
;
}
}
rt_size_t
rt_i2c_master_send
(
struct
rt_i2c_bus_device
*
bus
,
rt_uint16_t
addr
,
rt_uint16_t
flags
,
...
...
components/drivers/i2c/i2c_dev.c
浏览文件 @
75e13c68
...
...
@@ -7,6 +7,7 @@
* Date Author Notes
* 2012-04-25 weety first version
* 2014-08-03 bernard fix some compiling warning
* 2021-04-20 RiceChen added support for bus clock control
*/
#include <rtdevice.h>
...
...
@@ -66,6 +67,7 @@ static rt_err_t i2c_bus_device_control(rt_device_t dev,
rt_err_t
ret
;
struct
rt_i2c_priv_data
*
priv_data
;
struct
rt_i2c_bus_device
*
bus
=
(
struct
rt_i2c_bus_device
*
)
dev
->
user_data
;
rt_uint32_t
bus_clock
;
RT_ASSERT
(
bus
!=
RT_NULL
);
...
...
@@ -89,6 +91,14 @@ static rt_err_t i2c_bus_device_control(rt_device_t dev,
return
-
RT_EIO
;
}
break
;
case
RT_I2C_DEV_CTRL_CLK
:
bus_clock
=
*
(
rt_uint32_t
*
)
args
;
ret
=
rt_i2c_control
(
bus
,
cmd
,
bus_clock
);
if
(
ret
<
0
)
{
return
-
RT_EIO
;
}
break
;
default:
break
;
}
...
...
components/drivers/include/drivers/i2c.h
浏览文件 @
75e13c68
...
...
@@ -6,6 +6,7 @@
* Change Logs:
* Date Author Notes
* 2012-04-25 weety first version
* 2021-04-20 RiceChen added support for bus control api
*/
#ifndef __I2C_H__
...
...
@@ -74,6 +75,9 @@ struct rt_i2c_bus_device *rt_i2c_bus_device_find(const char *bus_name);
rt_size_t
rt_i2c_transfer
(
struct
rt_i2c_bus_device
*
bus
,
struct
rt_i2c_msg
msgs
[],
rt_uint32_t
num
);
rt_err_t
rt_i2c_control
(
struct
rt_i2c_bus_device
*
bus
,
rt_uint32_t
cmd
,
rt_uint32_t
arg
);
rt_size_t
rt_i2c_master_send
(
struct
rt_i2c_bus_device
*
bus
,
rt_uint16_t
addr
,
rt_uint16_t
flags
,
...
...
components/drivers/include/drivers/i2c_dev.h
浏览文件 @
75e13c68
...
...
@@ -6,6 +6,7 @@
* Change Logs:
* Date Author Notes
* 2012-04-25 weety first version
* 2021-04-20 RiceChen added bus clock command
*/
#ifndef __I2C_DEV_H__
...
...
@@ -21,6 +22,7 @@ extern "C" {
#define RT_I2C_DEV_CTRL_ADDR 0x21
#define RT_I2C_DEV_CTRL_TIMEOUT 0x22
#define RT_I2C_DEV_CTRL_RW 0x23
#define RT_I2C_DEV_CTRL_CLK 0x24
struct
rt_i2c_priv_data
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录