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

KTD-S0057-I
Page 47 Linux® Programming Examples (DebianTM)
KTAM3874/pITX Software Guide
/* Read address range if present */
if (argc == flags + 4 && mode != MODE_FUNC)
{
int
tmp;
tmp = (int) strtoul (argv[flags+2], NULL, 16);
if ((tmp < first) || (tmp > last))
{
fprintf (stderr, "Error: FIRST argument out of range (0x%02x-0x%02x)!\n", first, last);
return
-1;
}
first = tmp;
tmp = (int) strtoul (argv[flags+3], NULL, 16);
if ((tmp < first) || (tmp > last))
{
fprintf (stderr, "Error: FIRST argument out of range (0x%02x-0x%02x)!\n", first, last);
return
-1;
}
last = tmp;
}
file = open_i2c_dev (i2cbus, filename, 0);
if (file < 0)
return
-1;
/* Special case, we only list the implemented functionalities */
if (mode == MODE_FUNC)
{
if (ioctl (file, I2C_FUNCS, &funcs) < 0)
{
fprintf (stderr, "Error: Could not get the adapter functionality matrix: %s\n", strerror (errno));
close
(file);
return
-1;
}
close
(file);
printf ("Functionalities implemented by %s:\n", filename);
print_functionality
(funcs);
return
0;
}
res = scan_i2c_bus (file, mode, first, last);
close
(file);
exit
(res?1:0);
}
Further information about the I
2
C
TM
bus is available on
https://www.kernel.org/doc/Documentation/i2c/
dev-interface
.