Please select To the mobile version | Continue to access the desktop computer version

OrangePi

 Login            
 Register            
Search
Hot search: orangepi
View: 486|Reply: 0

I2C on Orange Pi 3, Armbian buster

[Copy link]

2

Threads

2

Posts

12

Credits

Novice

Rank: 1

Credits
12
Post time 2020-1-9 07:46:04 | Show all posts |Read mode

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.

You have to log in before you can reply Login | Register

Points Rules

Archiver|Mobile edition|Darkroom|OrangePi En ( 粤ICP备14086627号-2

2020-5-31 18:21 GMT+8 , Processed in 0.026408 second(s), 23 queries .

Powered by Discuz! X3.2

© 2014-2015 orangepibbs en.

Quick Reply To Top Return to the list