mirror of
https://github.com/FunKey-Project/FunKey-GPIO-Mapping.git
synced 2025-12-12 09:48:51 +01:00
fix multi I2C GPIO expander detection
Signed-off-by: Michel-FK <michel.stempin@funkey-project.com>
This commit is contained in:
parent
66fc9ce9d9
commit
44035d48c2
1
.gitignore
vendored
1
.gitignore
vendored
@ -4,3 +4,4 @@
|
|||||||
###################
|
###################
|
||||||
*.o
|
*.o
|
||||||
funkey_gpio_management
|
funkey_gpio_management
|
||||||
|
termfix
|
||||||
|
|||||||
@ -50,25 +50,25 @@ bool pcal6416a_init(void) {
|
|||||||
i2c_expander_addr = 0;
|
i2c_expander_addr = 0;
|
||||||
|
|
||||||
/// Probing PCAL9539A chip
|
/// Probing PCAL9539A chip
|
||||||
if (!i2c_expander_addr && ioctl(fd_i2c_expander, I2C_SLAVE_FORCE, PCAL9539A_I2C_ADDR) < 0) {
|
if (ioctl(fd_i2c_expander, I2C_SLAVE_FORCE, PCAL9539A_I2C_ADDR) < 0 ||
|
||||||
|
pcal6416a_read_mask_interrupts() < 0) {
|
||||||
printf("In %s - Failed to acquire bus access and/or talk to slave PCAL9539A_I2C_ADDR 0x%02X.\n",
|
printf("In %s - Failed to acquire bus access and/or talk to slave PCAL9539A_I2C_ADDR 0x%02X.\n",
|
||||||
__func__, PCAL9539A_I2C_ADDR);
|
__func__, PCAL9539A_I2C_ADDR);
|
||||||
}
|
|
||||||
else{
|
/// Probing PCAL6416A chip
|
||||||
|
if (ioctl(fd_i2c_expander, I2C_SLAVE_FORCE, PCAL6416A_I2C_ADDR) < 0 ||
|
||||||
|
pcal6416a_read_mask_interrupts() < 0) {
|
||||||
|
printf("In %s - Failed to acquire bus access and/or talk to slave PCAL6416A_I2C_ADDR 0x%02X.\n",
|
||||||
|
__func__, PCAL6416A_I2C_ADDR);
|
||||||
|
} else {
|
||||||
|
DEBUG_PRINTF("Found I2C gpio expander chip: PCAL6416A\n");
|
||||||
|
i2c_expander_addr = PCAL6416A_I2C_ADDR;
|
||||||
|
}
|
||||||
|
} else{
|
||||||
DEBUG_PRINTF("Found I2C gpio expander chip: PCAL9539A\n");
|
DEBUG_PRINTF("Found I2C gpio expander chip: PCAL9539A\n");
|
||||||
i2c_expander_addr = PCAL9539A_I2C_ADDR;
|
i2c_expander_addr = PCAL9539A_I2C_ADDR;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Probing PCAL6416A chip
|
|
||||||
if (!i2c_expander_addr && ioctl(fd_i2c_expander, I2C_SLAVE_FORCE, PCAL6416A_I2C_ADDR) < 0) {
|
|
||||||
printf("In %s - Failed to acquire bus access and/or talk to slave PCAL6416A_I2C_ADDR 0x%02X.\n",
|
|
||||||
__func__, PCAL6416A_I2C_ADDR);
|
|
||||||
}
|
|
||||||
else{
|
|
||||||
DEBUG_PRINTF("Found I2C gpio expander chip: PCAL6416A\n");
|
|
||||||
i2c_expander_addr = PCAL6416A_I2C_ADDR;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// GPIO expander chip found?
|
/// GPIO expander chip found?
|
||||||
if(!i2c_expander_addr){
|
if(!i2c_expander_addr){
|
||||||
printf("In %s - Failed to acquire bus access and/or talk to slave, exit\n", __func__);
|
printf("In %s - Failed to acquire bus access and/or talk to slave, exit\n", __func__);
|
||||||
|
|||||||
@ -491,4 +491,3 @@ int listen_gpios_interrupts(void)
|
|||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user