mirror of
https://github.com/FunKey-Project/FunKey-GPIO-Mapping.git
synced 2025-12-14 02:38:55 +01:00
added support for PCAL9539A
This commit is contained in:
parent
e2b637f3bd
commit
254f91c2b3
@ -30,6 +30,7 @@
|
|||||||
* Static variables
|
* Static variables
|
||||||
****************************************************************/
|
****************************************************************/
|
||||||
static int fd_i2c_expander;
|
static int fd_i2c_expander;
|
||||||
|
static unsigned int i2c_expander_addr;
|
||||||
static char i2c0_sysfs_filename[] = "/dev/i2c-0";
|
static char i2c0_sysfs_filename[] = "/dev/i2c-0";
|
||||||
|
|
||||||
/****************************************************************
|
/****************************************************************
|
||||||
@ -46,14 +47,31 @@ bool pcal6416a_init(void) {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ioctl(fd_i2c_expander,I2C_SLAVE,PCAL6416A_I2C_ADDR) < 0) {
|
i2c_expander_addr = 0;
|
||||||
printf("In pcal6416a_init - Failed to acquire bus access and/or talk to slave.\n");
|
|
||||||
// ERROR HANDLING; you can check errno to see what went wrong
|
/// Probing PCAL9539A chip
|
||||||
if (ioctl(fd_i2c_expander, I2C_SLAVE_FORCE, PCAL6416A_I2C_ADDR) < 0) {
|
if (ioctl(!i2c_expander_addr && fd_i2c_expander, I2C_SLAVE_FORCE, PCAL9539A_I2C_ADDR) < 0) {
|
||||||
printf("In pcal6416a_init - Failed to acquire FORCED bus access and/or talk to slave.\n");
|
printf("In %s - Failed to acquire bus access and/or talk to slave PCAL9539A_I2C_ADDR 0x%02X.\n",
|
||||||
// ERROR HANDLING; you can check errno to see what went wrong
|
__func__, PCAL9539A_I2C_ADDR);
|
||||||
return false;
|
}
|
||||||
}
|
else{
|
||||||
|
DEBUG_PRINTF("Found I2C gpio expander chip: PCAL9539A\n");
|
||||||
|
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?
|
||||||
|
if(!i2c_expander_addr){
|
||||||
|
printf("In %s - Failed to acquire bus access and/or talk to slave, exit\n");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -12,6 +12,7 @@
|
|||||||
****************************************************************/
|
****************************************************************/
|
||||||
// Chip physical address
|
// Chip physical address
|
||||||
#define PCAL6416A_I2C_ADDR 0x20
|
#define PCAL6416A_I2C_ADDR 0x20
|
||||||
|
#define PCAL9539A_I2C_ADDR 0x76
|
||||||
|
|
||||||
// Chip registers adresses
|
// Chip registers adresses
|
||||||
#define PCAL6416A_INPUT 0x00 /* Input port [RO] */
|
#define PCAL6416A_INPUT 0x00 /* Input port [RO] */
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user