87 lines
3.1 KiB
Diff
87 lines
3.1 KiB
Diff
diff --git a/tools/i2cget.c b/tools/i2cget.c
|
|
index 38bd44a..15ea57c 100644
|
|
--- a/tools/i2cget.c
|
|
+++ b/tools/i2cget.c
|
|
@@ -41,9 +41,10 @@ static void help(void) __attribute__ ((noreturn));
|
|
static void help(void)
|
|
{
|
|
fprintf(stderr,
|
|
- "Usage: i2cget [-f] [-y] [-a] I2CBUS CHIP-ADDRESS [DATA-ADDRESS [MODE [LENGTH]]]\n"
|
|
+ "Usage: i2cget [-f] [-y] [-a] [-t] I2CBUS CHIP-ADDRESS [DATA-ADDRESS [MODE [LENGTH]]]\n"
|
|
" I2CBUS is an integer or an I2C bus name\n"
|
|
- " ADDRESS is an integer (0x08 - 0x77, or 0x00 - 0x7f if -a is given)\n"
|
|
+ " ADDRESS is an integer (0x08 - 0x77, or 0x00 - 0x3ff if slave is 10bit)\n"
|
|
+ " If you want to transfer with 10bit slave add the parameter -t\n"
|
|
" MODE is one of:\n"
|
|
" b (read byte data, default)\n"
|
|
" w (read word data)\n"
|
|
@@ -183,6 +184,7 @@ int main(int argc, char *argv[])
|
|
int flags = 0;
|
|
int force = 0, yes = 0, version = 0, all_addrs = 0;
|
|
int length;
|
|
+ int use_10bit_mode = 0;
|
|
unsigned char block_data[I2C_SMBUS_BLOCK_MAX];
|
|
|
|
/* handle (optional) flags first */
|
|
@@ -192,6 +194,7 @@ int main(int argc, char *argv[])
|
|
case 'f': force = 1; break;
|
|
case 'y': yes = 1; break;
|
|
case 'a': all_addrs = 1; break;
|
|
+ case 't': use_10bit_mode = 1; break;
|
|
default:
|
|
fprintf(stderr, "Error: Unsupported option "
|
|
"\"%s\"!\n", argv[1+flags]);
|
|
@@ -260,8 +263,9 @@ int main(int argc, char *argv[])
|
|
} else {
|
|
length = I2C_SMBUS_BLOCK_MAX;
|
|
}
|
|
-
|
|
file = open_i2c_dev(i2cbus, filename, sizeof(filename), 0);
|
|
+ if (use_10bit_mode == 1)
|
|
+ ioctl(file, I2C_TENBIT, 1);
|
|
if (file < 0
|
|
|| check_funcs(file, size, daddress, pec)
|
|
|| set_slave_addr(file, address, force))
|
|
diff --git a/tools/i2cset.c b/tools/i2cset.c
|
|
index 4a3f597..432642e 100644
|
|
--- a/tools/i2cset.c
|
|
+++ b/tools/i2cset.c
|
|
@@ -38,9 +38,10 @@ static void help(void) __attribute__ ((noreturn));
|
|
static void help(void)
|
|
{
|
|
fprintf(stderr,
|
|
- "Usage: i2cset [-f] [-y] [-m MASK] [-r] [-a] I2CBUS CHIP-ADDRESS DATA-ADDRESS [VALUE] ... [MODE]\n"
|
|
+ "Usage: i2cset [-f] [-y] [-m MASK] [-r] [-a] [-t] I2CBUS CHIP-ADDRESS DATA-ADDRESS [VALUE] ... [MODE]\n"
|
|
" I2CBUS is an integer or an I2C bus name\n"
|
|
- " ADDRESS is an integer (0x08 - 0x77, or 0x00 - 0x7f if -a is given)\n"
|
|
+ " ADDRESS is an integer (0x08 - 0x77,0x00 - 0x3ff if slave is 10bit)\n"
|
|
+ " If you want to transfer with 10bit slave add the parameter -t\n"
|
|
" MODE is one of:\n"
|
|
" c (byte, no value)\n"
|
|
" b (byte data, default)\n"
|
|
@@ -164,6 +165,7 @@ int main(int argc, char *argv[])
|
|
int pec = 0;
|
|
int flags = 0;
|
|
int force = 0, yes = 0, version = 0, readback = 0, all_addrs = 0;
|
|
+ int use_10bit_mode = 0;
|
|
unsigned char block[I2C_SMBUS_BLOCK_MAX];
|
|
int len;
|
|
|
|
@@ -173,6 +175,7 @@ int main(int argc, char *argv[])
|
|
case 'V': version = 1; break;
|
|
case 'f': force = 1; break;
|
|
case 'y': yes = 1; break;
|
|
+ case 't': use_10bit_mode = 1; break;
|
|
case 'm':
|
|
if (2+flags < argc)
|
|
maskp = argv[2+flags];
|
|
@@ -316,6 +319,8 @@ int main(int argc, char *argv[])
|
|
}
|
|
|
|
file = open_i2c_dev(i2cbus, filename, sizeof(filename), 0);
|
|
+ if (use_10bit_mode == 1)
|
|
+ ioctl(file, I2C_TENBIT, 1);
|
|
if (file < 0
|
|
|| check_funcs(file, size, pec)
|
|
|| set_slave_addr(file, address, force))
|