请教i2c驱动测试 Linux交流区 ARM9之家论坛

发布网友 发布时间:2022-04-21 15:56

我来回答

2个回答

热心网友 时间:2022-07-10 03:52

这是IIC驱动中ioctl()的处理函数(源代码在drivers/i2c/i2c-dev.c)

static long i2cdev_ioctl(struct file *file, unsigned int cmd, unsigned long
arg)

{
struct i2c_client *client = (struct i2c_client *)file->private_data;
unsigned long funcs;

dev_dbg(&client->adapter->dev, "ioctl, cmd=0x%02x,
arg=0x%02lx\n",
cmd, arg);

switch ( cmd ) {
case I2C_SLAVE:
case I2C_SLAVE_FORCE:
/* NOTE: devices set up to work with "new style" drivers
* can't use I2C_SLAVE, even when the device node is not
* bound to a driver. Only I2C_SLAVE_FORCE will work.
*
* Setting the PEC flag here won't affect kernel drivers,
* which will be using the i2c_client node registered with
* the driver model core. Likewise, when that client has
* the PEC flag already set, the i2c-dev driver won't see
* (or use) this setting.
*/
if ((arg > 0x3ff) ||
(((client->flags & I2C_M_TEN) == 0) && arg >
0x7f))
return -EINVAL;
if (cmd == I2C_SLAVE &&
i2cdev_check_addr(client->adapter, arg))
return -EBUSY;
/* REVISIT: address could become busy later */
client->addr = arg;
return 0;

热心网友 时间:2022-07-10 03:53

好像有i2c工具的

声明声明:本网页内容为用户发布,旨在传播知识,不代表本网认同其观点,若有侵权等问题请及时与本网联系,我们将在第一时间删除处理。E-MAIL:11247931@qq.com