Skip to content
This repository was archived by the owner on Apr 28, 2021. It is now read-only.

Commit c008cbf

Browse files
committed
added break if chip found and passes not found messages as debug_printf when probing
1 parent 87d400a commit c008cbf

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

driver_pcal6416a.c

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -62,18 +62,20 @@ bool pcal6416a_init(void) {
6262
// ERROR HANDLING; you can check errno to see what went wrong
6363
return false;
6464
}
65+
66+
/// Probing known I2C GPIO expander chips
6567
for (i = 0, i2c_expander_addr = 0; i2c_chip[i].address; i++) {
6668

67-
/// Probing I2C GPIO expander chip
6869
if (ioctl(fd_i2c_expander, I2C_SLAVE_FORCE, i2c_chip[i]) < 0 ||
6970
pcal6416a_read_mask_interrupts() < 0) {
70-
printf("In %s - Failed to acquire bus access and/or talk to slave %s at address 0x%02X.\n",
71+
DEBUG_PRINTF("In %s - Failed to acquire bus access and/or talk to slave %s at address 0x%02X.\n",
7172
__func__, i2c_chip[i].name, i2c_chip[i].address);
72-
} else {
73-
DEBUG_PRINTF("Found I2C gpio expander chip %s at address 0x%02X\n",
74-
i2c_chip[i].name, i2c_chip[i].address);
75-
i2c_expander_addr = i2c_chip[i].address;
76-
}
73+
} else {
74+
DEBUG_PRINTF("Found I2C gpio expander chip %s at address 0x%02X\n",
75+
i2c_chip[i].name, i2c_chip[i].address);
76+
i2c_expander_addr = i2c_chip[i].address;
77+
break;
78+
}
7779
}
7880

7981
/// GPIO expander chip found?

0 commit comments

Comments
 (0)