Hi,  
I am facing an i2c problem on orange pi 3.  
The i2c0 is enabled in armbian-config.  
The i2cdetect output is correct, as I know my two slave boards connecting to gpio pin3 (SDA) and pin5(SCL) have the addresses 0x20 and 0x23.  pi@orangepi3:~$ sudo i2cdetect -y 0 
     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f 
00:          -- -- -- -- -- -- -- -- -- -- -- -- --  
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --  
20: 20 -- -- 23 -- -- -- -- -- -- -- -- -- -- -- --  
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --  
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --  
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --  
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --  
70: -- -- -- -- -- -- -- --                          
pi@orangepi3:~$  
  However, when I use wiringOP library to access(read and write) slave i2c chip(mcp23008) registers, it always return -1.  
int main(int argc, char** argv) 
{ 
    int fd_s1 = wiringPiI2CSetup(SLAVE_1_DEVICE_ID); //0x20 
    if (fd_s1 == -1) 
    { 
        std::cout << "Failed to init I2C Slave 1 communication." << std::endl; 
        return -1; 
    }     int fd_s2 = wiringPiI2CSetup(SLAVE_2_DEVICE_ID); //0x23 
    if (fd_s2 == -1) 
    { 
        std::cout << "Failed to init I2C Slave 2 communication." << std::endl; 
        return -1; 
    }     std::cout << "I2C communication successfully setup." << std::endl;     int reg_read; 
    reg_read = wiringPiI2CReadReg8(fd_s1, REG_IODIR); //The register address is correct, as this code ran on raspberry Pi correctly 
    std::cout << reg_read << std::endl; 
}  
Run output: I2C communication successfully setup. -1  
 
In the wiringPi library (in wiringOP), the code in wiringPiI2C.c shows that all APIs return -1, if the ioctl system call returns fault.  
Not sure what I should investigate next step to solve this problem.  
Thanks.  
 |