Advantech RSB-4210 Evaluation Kit User Manual Page 68

  • Download
  • Add to my manuals
  • Print
  • Page
    / 104
  • Table of contents
  • BOOKMARKS
  • Rated. / 5. Based on customer reviews
Page view 67
RSB-4210 User Manual 60
Do combined read/write transaction without stop in between.
Only valid if the adapter has I2C_FUNC_I2C. The argument is a
pointer to a
struct i2c_rdwr_ioctl_data {
struct i2c_msg *msgs; /* ptr to array of simple messages
*/
int nmsgs; /* number of messages to exchange
*/
}
The msgs[] themselves contain further pointers into data buffers. The function will
write or read data to or from that buffers depending on whether the I2C_M_RD flag is
set in a particular message or not. The slave address and whether to use ten bit
address mode has to be set in each message, overriding the values set with the
above ioctl's.
ioctl(file, I2C_SMBUS, struct i2c_smbus_ioctl_data *args)
Not meant to be called directly; instead, use the access
functions
below.
You can do plain i2c transactions by using read(2) and write(2) calls. You do not need
to pass the address byte; instead, set it through ioctl I2C_SLAVE before you try to
access the device.
You can do SMBus level transactions (see documentation file smbus-protocol for
details) through the following functions:
__s32 i2c_smbus_write_quick(int file, __u8 value);
__s32 i2c_smbus_read_byte(int file);
__s32 i2c_smbus_write_byte(int file, __u8 value);
__s32 i2c_smbus_read_byte_data(int file, __u8 command);
__s32 i2c_smbus_write_byte_data(int file, __u8 command, __u8 value);
__s32 i2c_smbus_read_word_data(int file, __u8 command);
__s32 i2c_smbus_write_word_data(int file, __u8 command, __u16 value);
__s32 i2c_smbus_process_call(int file, __u8 command, __u16 value);
__s32 i2c_smbus_read_block_data(int file, __u8 command, __u8 *values);
__s32 i2c_smbus_write_block_data(int file, __u8 command, __u8 length, __u8 *val-
ues);
All these transactions return -1 on failure; you can read errno to see what happened.
The 'write' transactions return 0 on success; the 'read' transactions return the read
value, except for read_block, which returns the number of values read. The block
buffers need not be longer than 32 bytes.
The above functions are all inline functions, that resolve to calls to the
i2c_smbus_access function, that on its turn calls a specific ioctl with the data in a
specific format. Read the source code if you want to know what happens behind the
screens.
Page view 67
1 2 ... 63 64 65 66 67 68 69 70 71 72 73 ... 103 104

Comments to this Manuals

No comments