summaryrefslogtreecommitdiff
path: root/components
diff options
context:
space:
mode:
Diffstat (limited to 'components')
-rw-r--r--components/drivers/i2c/i2c_core.c6
-rw-r--r--components/drivers/i2c/i2c_dev.c11
-rw-r--r--components/drivers/include/drivers/i2c.h8
-rw-r--r--components/drivers/include/drivers/i2c_dev.h4
4 files changed, 12 insertions, 17 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;
diff --git a/components/drivers/include/drivers/i2c.h b/components/drivers/include/drivers/i2c.h
index 2a900536df..ed87425260 100644
--- a/components/drivers/include/drivers/i2c.h
+++ b/components/drivers/include/drivers/i2c.h
@@ -45,8 +45,8 @@ struct rt_i2c_bus_device_ops
struct rt_i2c_msg msgs[],
rt_uint32_t num);
rt_err_t (*i2c_bus_control)(struct rt_i2c_bus_device *bus,
- rt_uint32_t,
- rt_uint32_t);
+ int cmd,
+ void *args);
};
/*for i2c bus driver*/
@@ -74,8 +74,8 @@ rt_ssize_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);
+ int cmd,
+ void *args);
rt_ssize_t rt_i2c_master_send(struct rt_i2c_bus_device *bus,
rt_uint16_t addr,
rt_uint16_t flags,
diff --git a/components/drivers/include/drivers/i2c_dev.h b/components/drivers/include/drivers/i2c_dev.h
index 60bbad0507..6744fa142d 100644
--- a/components/drivers/include/drivers/i2c_dev.h
+++ b/components/drivers/include/drivers/i2c_dev.h
@@ -23,6 +23,10 @@ extern "C" {
#define RT_I2C_DEV_CTRL_TIMEOUT (RT_DEVICE_CTRL_BASE(I2CBUS) + 0x03)
#define RT_I2C_DEV_CTRL_RW (RT_DEVICE_CTRL_BASE(I2CBUS) + 0x04)
#define RT_I2C_DEV_CTRL_CLK (RT_DEVICE_CTRL_BASE(I2CBUS) + 0x05)
+#define RT_I2C_DEV_CTRL_UNLOCK (RT_DEVICE_CTRL_BASE(I2CBUS) + 0x06)
+#define RT_I2C_DEV_CTRL_GET_STATE (RT_DEVICE_CTRL_BASE(I2CBUS) + 0x07)
+#define RT_I2C_DEV_CTRL_GET_MODE (RT_DEVICE_CTRL_BASE(I2CBUS) + 0x08)
+#define RT_I2C_DEV_CTRL_GET_ERROR (RT_DEVICE_CTRL_BASE(I2CBUS) + 0x09)
struct rt_i2c_priv_data
{