Browse Source

added access i2c by I2C_SLAVE_FORCE in case access by I2C_SLAVE not authorized (copied from busybox drivers)

Vincent-FK 4 years ago
parent
commit
8a756e9008
2 changed files with 11 additions and 2 deletions
  1. 5 1
      driver_axp209.c
  2. 6 1
      driver_pcal6416a.c

+ 5 - 1
driver_axp209.c

@@ -49,7 +49,11 @@ bool axp209_init(void) {
     if (ioctl(fd_axp209, I2C_SLAVE, AXP209_I2C_ADDR) < 0) {
         printf("In axp209_init - Failed to acquire bus access and/or talk to slave.\n");
         // ERROR HANDLING; you can check errno to see what went wrong 
-        return false;
+        if (ioctl(fd_axp209, I2C_SLAVE_FORCE, AXP209_I2C_ADDR) < 0) {
+            printf("In axp209_init - Failed to acquire FORCED bus access and/or talk to slave.\n");
+            // ERROR HANDLING; you can check errno to see what went wrong 
+            return false;
+        }
     }	
 
     // Enable only chosen interrupts (PEK short and long presses)

+ 6 - 1
driver_pcal6416a.c

@@ -47,8 +47,13 @@ bool pcal6416a_init(void) {
     }
 
     if (ioctl(fd_i2c_expander,I2C_SLAVE,PCAL6416A_I2C_ADDR) < 0) {
-        printf("Failed to acquire bus access and/or talk to slave.\n");
+        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 
+        if (ioctl(fd_i2c_expander, I2C_SLAVE_FORCE, PCAL6416A_I2C_ADDR) < 0) {
+            printf("In pcal6416a_init - Failed to acquire FORCED bus access and/or talk to slave.\n");
+            // ERROR HANDLING; you can check errno to see what went wrong 
+            return false;
+        }
         return false;
     }