Ktam3874/pitx software guide – Kontron KTAM3874-pITX User Manual
Page 47

KTD-S0057-I
Page 43 Linux® Programming Examples (DebianTM)
KTAM3874/pITX Software Guide
#define I2C_FUNC_SMBUS_READ_BLOCK_DATA
0x01000000
#define I2C_FUNC_SMBUS_WRITE_BLOCK_DATA
0x02000000
#define I2C_FUNC_SMBUS_READ_I2C_BLOCK
0x04000000
#define I2C_FUNC_SMBUS_WRITE_I2C_BLOCK
0x08000000
#define I2C_SMBUS_READ
1
#define I2C_SMBUS_BYTE
1
#define I2C_SLAVE
0x0703
#define I2C_FUNCS
0x0705
#define I2C_SMBUS
0x0720
#define I2C_SMBUS_BLOCK_MAX
32
struct func
{
long
value;
const char* name;
};
union i2c_smbus_data
{
__u8
byte;
__u16
word;
__u8 block[I2C_SMBUS_BLOCK_MAX + 2];
};
struct i2c_smbus_ioctl_data
{
char
read_write;
__u8
command;
int
size;
union i2c_smbus_data *data;
};
static void help (void)
{
fprintf (stderr, "Usage: i2cdetect [I2CBUS] [FIRST LAST]\n"
" i2cdetect -F [I2CBUS]\n"
" I2CBUS is an integer or an I2C bus name\n"
" If provided, FIRST and LAST limit the probing range.\n");
}
static inline __s32 i2c_smbus_access (int file, char read_write, __u8 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);
}