diff options
| author | sp-cai <[email protected]> | 2023-07-14 09:57:40 +0800 |
|---|---|---|
| committer | GitHub <[email protected]> | 2023-07-13 21:57:40 -0400 |
| commit | 0ebec472e16cc88d5ed5453d99059af0031998d1 (patch) | |
| tree | ac7869e2d5ed60465836a88c92bb6769df7a19f5 /components/drivers/i2c | |
| parent | 350626841a3baea98e0bb8737d844dbd814a50c1 (diff) | |
[components][i2c] 优化 controt 接口格式,增加可用命令 (#7806)
原来 rt_i2c_control 只能执行 RT_I2C_DEV_CTRL_CLK 单一命令,通过此修改可以支持更多可用命令
Diffstat (limited to 'components/drivers/i2c')
| -rw-r--r-- | components/drivers/i2c/i2c_core.c | 6 | ||||
| -rw-r--r-- | components/drivers/i2c/i2c_dev.c | 11 |
2 files changed, 4 insertions, 13 deletions
diff --git a/components/drivers/i2c/i2c_core.c b/components/drivers/i2c/i2c_core.c index 17671ea241..127fdd25a4 100644 --- a/components/drivers/i2c/i2c_core.c +++ b/components/drivers/i2c/i2c_core.c @@ -89,14 +89,14 @@ rt_ssize_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) + int cmd, + void *args) { rt_err_t ret; if(bus->ops->i2c_bus_control) { - ret = bus->ops->i2c_bus_control(bus, cmd, arg); + ret = bus->ops->i2c_bus_control(bus, cmd, args); return ret; } else diff --git a/components/drivers/i2c/i2c_dev.c b/components/drivers/i2c/i2c_dev.c index f492d470a5..96110b9e7d 100644 --- a/components/drivers/i2c/i2c_dev.c +++ b/components/drivers/i2c/i2c_dev.c @@ -67,7 +67,6 @@ 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); @@ -88,16 +87,8 @@ 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; + return rt_i2c_control(bus, cmd, args); } return RT_EOK; |
