diff --git a/bsp/ESP32_C3/drivers/drv_hw_i2c.c b/bsp/ESP32_C3/drivers/drv_hw_i2c.c index 031b8c1174..1597039eaa 100644 --- a/bsp/ESP32_C3/drivers/drv_hw_i2c.c +++ b/bsp/ESP32_C3/drivers/drv_hw_i2c.c @@ -96,7 +96,7 @@ static rt_size_t _slave_xfer(struct rt_i2c_bus_device *bus, struct rt_i2c_msg ms return -RT_ENOSYS; } -static rt_err_t _i2c_bus_control(struct rt_i2c_bus_device *bus, rt_uint32_t cmd, rt_uint32_t arg) +static rt_err_t _i2c_bus_control(struct rt_i2c_bus_device *bus, int cmd, void *args) { return -RT_EINVAL; } @@ -130,4 +130,4 @@ int rt_hw_i2c_init(void) return RT_EOK; } INIT_BOARD_EXPORT(rt_hw_i2c_init); -#endif /* RT_USING_I2C */ \ No newline at end of file +#endif /* RT_USING_I2C */ diff --git a/bsp/airm2m/air105/libraries/rt_drivers/drv_i2c.c b/bsp/airm2m/air105/libraries/rt_drivers/drv_i2c.c index eba4b3c826..8f34c1856d 100644 --- a/bsp/airm2m/air105/libraries/rt_drivers/drv_i2c.c +++ b/bsp/airm2m/air105/libraries/rt_drivers/drv_i2c.c @@ -21,8 +21,8 @@ static rt_ssize_t air105_i2c_slv_xfer(struct rt_i2c_bus_device *bus, struct rt_i2c_msg msgs[], rt_uint32_t num); static rt_err_t air105_i2c_bus_control(struct rt_i2c_bus_device *bus, - rt_uint32_t, - rt_uint32_t); + int cmd, + void *args); static const struct rt_i2c_bus_device_ops air105_i2c_ops = { @@ -88,8 +88,8 @@ static rt_ssize_t air105_i2c_slv_xfer(struct rt_i2c_bus_device *bus, return -RT_ENOSYS; } static rt_err_t air105_i2c_bus_control(struct rt_i2c_bus_device *bus, - rt_uint32_t cmd, - rt_uint32_t arg) + int cmd, + void *args) { RT_ASSERT(bus != RT_NULL); @@ -97,7 +97,7 @@ static rt_err_t air105_i2c_bus_control(struct rt_i2c_bus_device *bus, switch (cmd) { case RT_I2C_DEV_CTRL_CLK: - I2C_MasterSetup(i2c_id, arg); + I2C_MasterSetup(i2c_id, *(rt_uint32_t *)args); break; default: return -RT_EIO; diff --git a/bsp/apollo2/board/i2c.c b/bsp/apollo2/board/i2c.c index 0a1311d7e6..09e6d4ed4e 100644 --- a/bsp/apollo2/board/i2c.c +++ b/bsp/apollo2/board/i2c.c @@ -90,11 +90,11 @@ rt_size_t rt_i2c_master_xfer(struct rt_i2c_bus_device *bus, } rt_err_t rt_i2c_bus_control(struct rt_i2c_bus_device *bus, - rt_uint32_t cmd, - rt_uint32_t arg) + int cmd, + void *args) { struct am_i2c_bus * am_i2c_bus = (struct am_i2c_bus *)bus; - //rt_uint32_t ctrl_arg = (rt_uint32_t)(arg); + //rt_uint32_t ctrl_arg = *(rt_uint32_t *)args; RT_ASSERT(bus != RT_NULL); am_i2c_bus = (struct am_i2c_bus *)bus->parent.user_data; diff --git a/bsp/imxrt/libraries/drivers/drv_i2c.c b/bsp/imxrt/libraries/drivers/drv_i2c.c index 40a3f62441..7210421c31 100644 --- a/bsp/imxrt/libraries/drivers/drv_i2c.c +++ b/bsp/imxrt/libraries/drivers/drv_i2c.c @@ -141,8 +141,8 @@ static rt_ssize_t imxrt_i2c_slv_xfer(struct rt_i2c_bus_device *bus, struct rt_i2c_msg msgs[], rt_uint32_t num); static rt_err_t imxrt_i2c_bus_control(struct rt_i2c_bus_device *bus, - rt_uint32_t, - rt_uint32_t); + int cmd, + void *args); static const struct rt_i2c_bus_device_ops imxrt_i2c_ops = { @@ -372,8 +372,8 @@ static rt_ssize_t imxrt_i2c_slv_xfer(struct rt_i2c_bus_device *bus, return 0; } static rt_err_t imxrt_i2c_bus_control(struct rt_i2c_bus_device *bus, - rt_uint32_t cmd, - rt_uint32_t arg) + int cmd, + void *args) { return -RT_ERROR; } diff --git a/bsp/loongson/ls1cdev/drivers/hw_i2c.c b/bsp/loongson/ls1cdev/drivers/hw_i2c.c index 2498bb5386..5f3143eabf 100644 --- a/bsp/loongson/ls1cdev/drivers/hw_i2c.c +++ b/bsp/loongson/ls1cdev/drivers/hw_i2c.c @@ -57,8 +57,8 @@ rt_size_t rt_i2c_master_xfer(struct rt_i2c_bus_device *bus, } rt_err_t rt_i2c_bus_control(struct rt_i2c_bus_device *bus, - rt_uint32_t cmd, - rt_uint32_t arg) + int cmd, + void *args) { struct ls1c_i2c_bus * i2c_bus = (struct ls1c_i2c_bus *)bus; diff --git a/bsp/lpc54114-lite/drivers/drv_i2c.c b/bsp/lpc54114-lite/drivers/drv_i2c.c index 1291e3ab2d..c98e3c9cc6 100644 --- a/bsp/lpc54114-lite/drivers/drv_i2c.c +++ b/bsp/lpc54114-lite/drivers/drv_i2c.c @@ -87,7 +87,7 @@ static rt_ssize_t slave_xfer(struct rt_i2c_bus_device *bus, struct rt_i2c_msg ms return -RT_ENOSYS; } -static rt_err_t i2c_bus_control(struct rt_i2c_bus_device *bus, rt_uint32_t cmd, rt_uint32_t arg) +static rt_err_t i2c_bus_control(struct rt_i2c_bus_device *bus, int cmd, void *args) { return -RT_EINVAL; } diff --git a/bsp/microchip/common/board/sam_i2c.c b/bsp/microchip/common/board/sam_i2c.c index 5620b0b04a..671b16b5a2 100644 --- a/bsp/microchip/common/board/sam_i2c.c +++ b/bsp/microchip/common/board/sam_i2c.c @@ -37,7 +37,7 @@ static rt_ssize_t sam_i2c_slave_xfer(struct rt_i2c_bus_device *bus, struct rt_i2c_msg msgs[], rt_uint32_t num); static rt_err_t sam_i2c_bus_control(struct rt_i2c_bus_device *bus, - rt_uint32_t, rt_uint32_t); + int cmd, void *args); static const struct rt_i2c_bus_device_ops sam_i2c_ops = { @@ -90,8 +90,8 @@ static rt_ssize_t sam_i2c_slave_xfer(struct rt_i2c_bus_device *bus, } static rt_err_t sam_i2c_bus_control(struct rt_i2c_bus_device *bus, - rt_uint32_t cmd, - rt_uint32_t arg) + int cmd, + void *args) { return -RT_ERROR; struct sam_i2c_bus *sam_i2c = (struct sam_i2c_bus *)bus; @@ -101,7 +101,7 @@ static rt_err_t sam_i2c_bus_control(struct rt_i2c_bus_device *bus, switch (cmd) { case RT_I2C_DEV_CTRL_CLK: - i2c_m_sync_set_baudrate(sam_i2c->i2c_desc, 0, arg); + i2c_m_sync_set_baudrate(sam_i2c->i2c_desc, 0, *(rt_uint32_t *)args); break; default: return -RT_EIO; diff --git a/bsp/nuvoton/libraries/m031/rtt_port/drv_i2c.c b/bsp/nuvoton/libraries/m031/rtt_port/drv_i2c.c index 35582a80f2..87a89b29ac 100644 --- a/bsp/nuvoton/libraries/m031/rtt_port/drv_i2c.c +++ b/bsp/nuvoton/libraries/m031/rtt_port/drv_i2c.c @@ -73,8 +73,8 @@ static rt_ssize_t nu_i2c_mst_xfer(struct rt_i2c_bus_device *bus, struct rt_i2c_msg msgs[], rt_uint32_t num); static rt_err_t nu_i2c_bus_control(struct rt_i2c_bus_device *bus, - rt_uint32_t u32Cmd, - rt_uint32_t u32Value); + int cmd, + void *args); static const struct rt_i2c_bus_device_ops nu_i2c_ops = { @@ -83,17 +83,17 @@ static const struct rt_i2c_bus_device_ops nu_i2c_ops = .i2c_bus_control = nu_i2c_bus_control }; -static rt_err_t nu_i2c_bus_control(struct rt_i2c_bus_device *bus, rt_uint32_t u32Cmd, rt_uint32_t u32Value) +static rt_err_t nu_i2c_bus_control(struct rt_i2c_bus_device *bus, int cmd, void *args) { nu_i2c_bus_t *nu_i2c; RT_ASSERT(bus != RT_NULL); nu_i2c = (nu_i2c_bus_t *) bus; - switch (u32Cmd) + switch (cmd) { case RT_I2C_DEV_CTRL_CLK: - I2C_SetBusClockFreq(nu_i2c->I2C, u32Value); + I2C_SetBusClockFreq(nu_i2c->I2C, *(rt_uint32_t *)args); break; default: return -RT_EIO; diff --git a/bsp/nuvoton/libraries/m2354/rtt_port/drv_i2c.c b/bsp/nuvoton/libraries/m2354/rtt_port/drv_i2c.c index e1c15c32c7..5df4279b95 100644 --- a/bsp/nuvoton/libraries/m2354/rtt_port/drv_i2c.c +++ b/bsp/nuvoton/libraries/m2354/rtt_port/drv_i2c.c @@ -82,8 +82,8 @@ static rt_ssize_t nu_i2c_mst_xfer(struct rt_i2c_bus_device *bus, struct rt_i2c_msg msgs[], rt_uint32_t num); static rt_err_t nu_i2c_bus_control(struct rt_i2c_bus_device *bus, - rt_uint32_t u32Cmd, - rt_uint32_t u32Value); + int cmd, + void *args); static const struct rt_i2c_bus_device_ops nu_i2c_ops = { @@ -92,17 +92,17 @@ static const struct rt_i2c_bus_device_ops nu_i2c_ops = .i2c_bus_control = nu_i2c_bus_control }; -static rt_err_t nu_i2c_bus_control(struct rt_i2c_bus_device *bus, rt_uint32_t u32Cmd, rt_uint32_t u32Value) +static rt_err_t nu_i2c_bus_control(struct rt_i2c_bus_device *bus, int cmd, void *args) { nu_i2c_bus_t *nu_i2c; RT_ASSERT(bus != RT_NULL); nu_i2c = (nu_i2c_bus_t *) bus; - switch (u32Cmd) + switch (cmd) { case RT_I2C_DEV_CTRL_CLK: - I2C_SetBusClockFreq(nu_i2c->I2C, u32Value); + I2C_SetBusClockFreq(nu_i2c->I2C, *(rt_uint32_t *)args); break; default: return -RT_EIO; diff --git a/bsp/nuvoton/libraries/m460/rtt_port/drv_i2c.c b/bsp/nuvoton/libraries/m460/rtt_port/drv_i2c.c index c051fdfba1..ef9b6be078 100644 --- a/bsp/nuvoton/libraries/m460/rtt_port/drv_i2c.c +++ b/bsp/nuvoton/libraries/m460/rtt_port/drv_i2c.c @@ -94,8 +94,8 @@ static rt_ssize_t nu_i2c_mst_xfer(struct rt_i2c_bus_device *bus, struct rt_i2c_msg msgs[], rt_uint32_t num); static rt_err_t nu_i2c_bus_control(struct rt_i2c_bus_device *bus, - rt_uint32_t u32Cmd, - rt_uint32_t u32Value); + int cmd, + void *args); static const struct rt_i2c_bus_device_ops nu_i2c_ops = { @@ -104,17 +104,17 @@ static const struct rt_i2c_bus_device_ops nu_i2c_ops = .i2c_bus_control = nu_i2c_bus_control }; -static rt_err_t nu_i2c_bus_control(struct rt_i2c_bus_device *bus, rt_uint32_t u32Cmd, rt_uint32_t u32Value) +static rt_err_t nu_i2c_bus_control(struct rt_i2c_bus_device *bus, int cmd, void *args) { nu_i2c_bus_t nu_i2c; RT_ASSERT(bus); nu_i2c = (nu_i2c_bus_t) bus; - switch (u32Cmd) + switch (cmd) { case RT_I2C_DEV_CTRL_CLK: - I2C_SetBusClockFreq(nu_i2c->I2C, u32Value); + I2C_SetBusClockFreq(nu_i2c->I2C, *(rt_uint32_t *)args); break; default: return -RT_EIO; diff --git a/bsp/nuvoton/libraries/m460/rtt_port/drv_ui2c.c b/bsp/nuvoton/libraries/m460/rtt_port/drv_ui2c.c index 85783a53d3..3822ca3e94 100644 --- a/bsp/nuvoton/libraries/m460/rtt_port/drv_ui2c.c +++ b/bsp/nuvoton/libraries/m460/rtt_port/drv_ui2c.c @@ -61,8 +61,8 @@ static rt_ssize_t nu_ui2c_mst_xfer(struct rt_i2c_bus_device *bus, rt_uint32_t num); static rt_err_t nu_ui2c_bus_control(struct rt_i2c_bus_device *bus, - rt_uint32_t u32Cmd, - rt_uint32_t u32Value); + int cmd, + void *args); static const struct rt_i2c_bus_device_ops nu_ui2c_ops = { @@ -71,17 +71,17 @@ static const struct rt_i2c_bus_device_ops nu_ui2c_ops = .i2c_bus_control = nu_ui2c_bus_control, }; -static rt_err_t nu_ui2c_bus_control(struct rt_i2c_bus_device *bus, rt_uint32_t u32Cmd, rt_uint32_t u32Value) +static rt_err_t nu_ui2c_bus_control(struct rt_i2c_bus_device *bus, int cmd, void *args) { nu_ui2c_bus_t nu_ui2c; RT_ASSERT(bus); nu_ui2c = (nu_ui2c_bus_t) bus; - switch (u32Cmd) + switch (cmd) { case RT_I2C_DEV_CTRL_CLK: - UI2C_SetBusClockFreq(nu_ui2c->UI2C, u32Value); + UI2C_SetBusClockFreq(nu_ui2c->UI2C, *(rt_uint32_t *)args); break; default: return -RT_EIO; diff --git a/bsp/nuvoton/libraries/m480/rtt_port/drv_i2c.c b/bsp/nuvoton/libraries/m480/rtt_port/drv_i2c.c index 52b6baa02b..770541c36b 100644 --- a/bsp/nuvoton/libraries/m480/rtt_port/drv_i2c.c +++ b/bsp/nuvoton/libraries/m480/rtt_port/drv_i2c.c @@ -82,8 +82,8 @@ static rt_ssize_t nu_i2c_mst_xfer(struct rt_i2c_bus_device *bus, struct rt_i2c_msg msgs[], rt_uint32_t num); static rt_err_t nu_i2c_bus_control(struct rt_i2c_bus_device *bus, - rt_uint32_t u32Cmd, - rt_uint32_t u32Value); + int cmd, + void *args); static const struct rt_i2c_bus_device_ops nu_i2c_ops = { @@ -92,17 +92,17 @@ static const struct rt_i2c_bus_device_ops nu_i2c_ops = .i2c_bus_control = nu_i2c_bus_control }; -static rt_err_t nu_i2c_bus_control(struct rt_i2c_bus_device *bus, rt_uint32_t u32Cmd, rt_uint32_t u32Value) +static rt_err_t nu_i2c_bus_control(struct rt_i2c_bus_device *bus, int cmd, void *args) { nu_i2c_bus_t *nu_i2c; RT_ASSERT(bus != RT_NULL); nu_i2c = (nu_i2c_bus_t *) bus; - switch (u32Cmd) + switch (cmd) { case RT_I2C_DEV_CTRL_CLK: - I2C_SetBusClockFreq(nu_i2c->I2C, u32Value); + I2C_SetBusClockFreq(nu_i2c->I2C, *(rt_uint32_t *)args); break; default: return -RT_EIO; diff --git a/bsp/nuvoton/libraries/ma35/rtt_port/drv_i2c.c b/bsp/nuvoton/libraries/ma35/rtt_port/drv_i2c.c index e6fdb4675a..5c68651c34 100644 --- a/bsp/nuvoton/libraries/ma35/rtt_port/drv_i2c.c +++ b/bsp/nuvoton/libraries/ma35/rtt_port/drv_i2c.c @@ -103,8 +103,8 @@ static rt_ssize_t nu_i2c_mst_xfer(struct rt_i2c_bus_device *bus, struct rt_i2c_msg msgs[], rt_uint32_t num); static rt_err_t nu_i2c_bus_control(struct rt_i2c_bus_device *bus, - rt_uint32_t u32Cmd, - rt_uint32_t u32Value); + int cmd, + void *args); static const struct rt_i2c_bus_device_ops nu_i2c_ops = { @@ -113,17 +113,17 @@ static const struct rt_i2c_bus_device_ops nu_i2c_ops = .i2c_bus_control = nu_i2c_bus_control }; -static rt_err_t nu_i2c_bus_control(struct rt_i2c_bus_device *bus, rt_uint32_t u32Cmd, rt_uint32_t u32Value) +static rt_err_t nu_i2c_bus_control(struct rt_i2c_bus_device *bus, int u32Cmd, void *args) { nu_i2c_bus_t *nu_i2c; RT_ASSERT(bus != RT_NULL); nu_i2c = (nu_i2c_bus_t *) bus; - switch (u32Cmd) + switch (cmd) { case RT_I2C_DEV_CTRL_CLK: - I2C_SetBusClockFreq(nu_i2c->I2C, u32Value); + I2C_SetBusClockFreq(nu_i2c->I2C, *(rt_uint32_t *)args); break; default: return -RT_EIO; diff --git a/bsp/nuvoton/libraries/n9h30/rtt_port/drv_i2c.c b/bsp/nuvoton/libraries/n9h30/rtt_port/drv_i2c.c index 9196a6f550..24ab78abcc 100644 --- a/bsp/nuvoton/libraries/n9h30/rtt_port/drv_i2c.c +++ b/bsp/nuvoton/libraries/n9h30/rtt_port/drv_i2c.c @@ -506,7 +506,7 @@ static rt_ssize_t nu_i2c_mst_xfer(struct rt_i2c_bus_device *bus, return i; } -static rt_err_t nu_i2c_bus_control(struct rt_i2c_bus_device *bus, rt_uint32_t u32Cmd, rt_uint32_t u32Value) +static rt_err_t nu_i2c_bus_control(struct rt_i2c_bus_device *bus, int cmd, void *args) { nu_i2c_bus_t psNuI2cBus; nu_i2c_dev_t psNuI2cDev; @@ -516,10 +516,10 @@ static rt_err_t nu_i2c_bus_control(struct rt_i2c_bus_device *bus, rt_uint32_t u3 psNuI2cBus = (nu_i2c_bus_t) bus; psNuI2cDev = &psNuI2cBus->dev; - switch (u32Cmd) + switch (cmd) { case RT_I2C_DEV_CTRL_CLK: - nu_i2c_set_speed(psNuI2cDev, (int32_t)u32Value); + nu_i2c_set_speed(psNuI2cDev, *(int32_t *)args); break; default: return -RT_EIO; diff --git a/bsp/nuvoton/libraries/nuc980/rtt_port/drv_i2c.c b/bsp/nuvoton/libraries/nuc980/rtt_port/drv_i2c.c index 79249bedfc..1753ce4849 100644 --- a/bsp/nuvoton/libraries/nuc980/rtt_port/drv_i2c.c +++ b/bsp/nuvoton/libraries/nuc980/rtt_port/drv_i2c.c @@ -101,8 +101,8 @@ static rt_ssize_t nu_i2c_mst_xfer(struct rt_i2c_bus_device *bus, struct rt_i2c_msg msgs[], rt_uint32_t num); static rt_err_t nu_i2c_bus_control(struct rt_i2c_bus_device *bus, - rt_uint32_t u32Cmd, - rt_uint32_t u32Value); + int cmd, + void *args); static const struct rt_i2c_bus_device_ops nu_i2c_ops = { @@ -111,17 +111,17 @@ static const struct rt_i2c_bus_device_ops nu_i2c_ops = .i2c_bus_control = nu_i2c_bus_control }; -static rt_err_t nu_i2c_bus_control(struct rt_i2c_bus_device *bus, rt_uint32_t u32Cmd, rt_uint32_t u32Value) +static rt_err_t nu_i2c_bus_control(struct rt_i2c_bus_device *bus, int cmd, void *args) { nu_i2c_bus_t *nu_i2c; RT_ASSERT(bus != RT_NULL); nu_i2c = (nu_i2c_bus_t *) bus; - switch (u32Cmd) + switch (cmd) { case RT_I2C_DEV_CTRL_CLK: - I2C_SetBusClockFreq(nu_i2c->I2C, u32Value); + I2C_SetBusClockFreq(nu_i2c->I2C, *(rt_uint32_t *)args); break; default: return -RT_EIO; diff --git a/bsp/raspberry-pi/raspi3-32/driver/drv_i2c.c b/bsp/raspberry-pi/raspi3-32/driver/drv_i2c.c index 3cf4cd2402..2dc5db6a69 100644 --- a/bsp/raspberry-pi/raspi3-32/driver/drv_i2c.c +++ b/bsp/raspberry-pi/raspi3-32/driver/drv_i2c.c @@ -110,8 +110,8 @@ static rt_ssize_t raspi_i2c_slv_xfer(struct rt_i2c_bus_device *bus, struct rt_i2c_msg msgs[], rt_uint32_t num); static rt_err_t raspi_i2c_bus_control(struct rt_i2c_bus_device *bus, - rt_uint32_t, - rt_uint32_t); + int cmd, + void *args); static rt_uint32_t i2c_byte_wait_us = 0; static rt_ssize_t raspi_i2c_mst_xfer(struct rt_i2c_bus_device *bus, @@ -148,8 +148,8 @@ static rt_ssize_t raspi_i2c_slv_xfer(struct rt_i2c_bus_device *bus, return 0; } static rt_err_t raspi_i2c_bus_control(struct rt_i2c_bus_device *bus, - rt_uint32_t cmd, - rt_uint32_t arg) + int cmd, + void *args) { return RT_EOK; } diff --git a/bsp/raspberry-pi/raspi3-64/driver/drv_i2c.c b/bsp/raspberry-pi/raspi3-64/driver/drv_i2c.c index 07ea8087e6..4648f880e7 100644 --- a/bsp/raspberry-pi/raspi3-64/driver/drv_i2c.c +++ b/bsp/raspberry-pi/raspi3-64/driver/drv_i2c.c @@ -115,8 +115,8 @@ static rt_ssize_t raspi_i2c_slv_xfer(struct rt_i2c_bus_device *bus, struct rt_i2c_msg msgs[], rt_uint32_t num); static rt_err_t raspi_i2c_bus_control(struct rt_i2c_bus_device *bus, - rt_uint32_t, - rt_uint32_t); + int cmd, + void *args); static rt_uint32_t i2c_byte_wait_us = 0; static rt_ssize_t raspi_i2c_mst_xfer(struct rt_i2c_bus_device *bus, @@ -153,8 +153,8 @@ static rt_ssize_t raspi_i2c_slv_xfer(struct rt_i2c_bus_device *bus, return 0; } static rt_err_t raspi_i2c_bus_control(struct rt_i2c_bus_device *bus, - rt_uint32_t cmd, - rt_uint32_t arg) + int cmd, + void *args) { return RT_EOK; } diff --git a/bsp/raspberry-pi/raspi4-32/driver/drv_i2c.c b/bsp/raspberry-pi/raspi4-32/driver/drv_i2c.c index 0a9b93b99f..54d2d1950b 100644 --- a/bsp/raspberry-pi/raspi4-32/driver/drv_i2c.c +++ b/bsp/raspberry-pi/raspi4-32/driver/drv_i2c.c @@ -162,8 +162,8 @@ static rt_ssize_t raspi_i2c_slv_xfer(struct rt_i2c_bus_device *bus, } static rt_err_t raspi_i2c_bus_control(struct rt_i2c_bus_device *bus, - rt_uint32_t cmd, - rt_uint32_t arg) + int cmd, + void *args) { return RT_EOK; } diff --git a/bsp/w60x/drivers/drv_i2c.c b/bsp/w60x/drivers/drv_i2c.c index aedc99af64..caf50ee9d3 100644 --- a/bsp/w60x/drivers/drv_i2c.c +++ b/bsp/w60x/drivers/drv_i2c.c @@ -37,8 +37,8 @@ static rt_ssize_t wm_i2c_slv_xfer(struct rt_i2c_bus_device *bus, struct rt_i2c_msg msgs[], rt_uint32_t num); static rt_err_t wm_i2c_bus_control(struct rt_i2c_bus_device *bus, - rt_uint32_t, - rt_uint32_t); + int cmd, + void *args); static const struct rt_i2c_bus_device_ops wm_i2c_ops = { @@ -132,8 +132,8 @@ static rt_ssize_t wm_i2c_slv_xfer(struct rt_i2c_bus_device *bus, return 0; } static rt_err_t wm_i2c_bus_control(struct rt_i2c_bus_device *bus, - rt_uint32_t cmd, - rt_uint32_t arg) + int cmd, + void *args) { return -RT_ERROR; } 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 {