代码拉取完成,页面将自动刷新
// Helper functions that are not present in the i2c-dev.h file on
// all platforms. They fill in the parameters and call the appropriate
// ioctl() and then package info for return.
// Ensure that we don't include i2c.h on platforms like Raspberry Pi
// where they pulled these definitions into i2c-dev.h rather than just
// doing #include i2c.h, and where they also did not define _LINUX_I2C_H
// to guard against its future inclusion. Here, we pick one of the
// things that are defined in that file and check for it.
#ifndef I2C_M_TEN
#include <linux/i2c.h>
#endif
static inline vrpn_int32 vrpn_i2c_smbus_access(
int file, char read_write, vrpn_uint8 command,
int size, union i2c_smbus_data *data)
{
struct i2c_smbus_ioctl_data args;
args.read_write = read_write;
args.command = command;
args.size = size;
args.data = data;
return ioctl(file,I2C_SMBUS,&args);
}
static inline vrpn_int32 vrpn_i2c_smbus_write_byte_data(
int file, vrpn_uint8 command, vrpn_uint8 value)
{
union i2c_smbus_data data;
data.byte = value;
return vrpn_i2c_smbus_access(file,I2C_SMBUS_WRITE,command,
I2C_SMBUS_BYTE_DATA, &data);
}
static inline vrpn_int32 vrpn_i2c_smbus_read_i2c_block_data(
int file, vrpn_uint8 command,
vrpn_uint8 length, vrpn_uint8 *values)
{
union i2c_smbus_data data;
int i;
if (length > 32) { length = 32; }
data.block[0] = length;
if (vrpn_i2c_smbus_access(file,I2C_SMBUS_READ,command,
length == 32 ? I2C_SMBUS_I2C_BLOCK_BROKEN :
I2C_SMBUS_I2C_BLOCK_DATA,&data)) {
return -1;
} else {
for (i = 0; i < data.block[0]; i++) {
values[i] = data.block[i+1];
}
return data.block[0];
}
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。