Skip to content

Commit

Permalink
Merge pull request #116 from RoboSchmied/RoboSchmied-i2cdetect
Browse files Browse the repository at this point in the history
include last byte in i2cdetect output
  • Loading branch information
dimerr committed Mar 18, 2024
2 parents cc2849e + a006247 commit 8e41e80
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/i2cspi.c
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,9 @@ static int i2cdetect(int argc, char **argv, bool script_mode) {
unsigned char i2c_addr;

printf(" 0 1 2 3 4 5 6 7 8 9 a b c d e f\n");
for (i2c_addr = 0x0; i2c_addr < 0xff; ++i2c_addr) {
i2c_addr = 0xff; // will be 0x00 after first increment
do {
++i2c_addr;
int fd = prepare_i2c_sensor(i2c_addr);
int res = i2c_read_register(fd, i2c_addr, 0, SELECT_WIDE(0), 1);

Expand All @@ -221,7 +223,8 @@ static int i2cdetect(int argc, char **argv, bool script_mode) {

close_sensor_fd(fd);
hal_cleanup();
}
} while (i2c_addr != 0xff);

printf("\n");

return EXIT_SUCCESS;
Expand Down

0 comments on commit 8e41e80

Please sign in to comment.