圍紀實驗室

(working on I2C control for VX900)



I2CTools - a great I2C tool for the Linux OS.
(Referred to by this wiki page)

I2C & Python on the Raspberry Pi is also an interesting article.




By studying the code in i2c-tools (e.g. i2cdetect.c in the tools/ subdirectory), I found the API functions, e.g. i2c_smbus_read_byte(), etc, are implemented in <linux kernel source>/drivers/i2c/i2c-core.c

The code snippet below is copied from this LXR page

/** 
* i2c_smbus_read_byte - SMBus "receive byte" protocol
* @client: Handle to slave device
*
* This executes the SMBus "receive byte" protocol, returning negative errno
* else the byte received from the device.
*/
s32 i2c_smbus_read_byte(const struct i2c_client *client)
{
union i2c_smbus_data data;
int status;

status = i2c_smbus_xfer(client->adapter, client->addr, client->flags,
I2C_SMBUS_READ, 0,
I2C_SMBUS_BYTE, &data);
return (status < 0) ? status : data.byte;
}
EXPORT_SYMBOL(i2c_smbus_read_byte);