|
|
|
@ -18,6 +18,7 @@ void i2cloop(I2C *i2c);
|
|
|
|
|
void i2cscan(I2C *i2c);
|
|
|
|
|
void i2ccfgprint();
|
|
|
|
|
int i2ccfgload(const char *fname);
|
|
|
|
|
int debug = 0;
|
|
|
|
|
void help();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -41,6 +42,10 @@ int main (int argc, char **argv) {
|
|
|
|
|
exit (0);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (strcmp (argv[i], "-debug") == 0) {
|
|
|
|
|
debug = 1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (strcmp (argv[i], "-config") == 0) {
|
|
|
|
|
i++;
|
|
|
|
|
cfgfile = argv[i];
|
|
|
|
@ -85,9 +90,14 @@ void i2cloop (I2C *i2c) {
|
|
|
|
|
// digital in
|
|
|
|
|
for (index = 0; index < RBUS_MAXSENSORBYTES; index++) {
|
|
|
|
|
if (rbus[index].i2c_addr != 0) {
|
|
|
|
|
if (!i2c->ReadByte(rbus[index].i2c_addr, rbus[index].i2c_reg, &rbus[index].status))
|
|
|
|
|
if (!i2c->ReadByte(rbus[index].i2c_addr, rbus[index].i2c_reg, &rbus[index].status)) {
|
|
|
|
|
if (debug) printf ("i2cloop: Read ADDR:%02x REG:%02x Value:%2x Error\n", rbus[index].i2c_addr, rbus[index].i2c_reg, rbus[index].status);
|
|
|
|
|
rbus[index].status = 0xFF; // error
|
|
|
|
|
}
|
|
|
|
|
else if (debug) {
|
|
|
|
|
printf ("i2cloop: Read ADDR:%02x REG:%02x Value:%2x\n", rbus[index].i2c_addr, rbus[index].i2c_reg, rbus[index].status);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
@ -268,6 +278,7 @@ void help () {
|
|
|
|
|
printf ("parameters: without any parameters the config will be read from file.\n");
|
|
|
|
|
printf (" if no file is found, autoscan is used first.\n");
|
|
|
|
|
printf (" -scan scanning i2c bus and print out a sample device config\n");
|
|
|
|
|
printf (" -debug enabling debugging\n");
|
|
|
|
|
printf (" -config FILE finename used for configuration (default %s/\n", DEFAULT_CONFIG);
|
|
|
|
|
printf ("\n");
|
|
|
|
|
}
|
|
|
|
|