I have used the WiringPi I2C library to perform simple byte transfers between a Raspberry Pi and an Arduino (using function wiringPiI2CRead).
I want to get the Arduino to return 16bit word values, but am at somewhat of a loss.
Arduino has `Wire.write(data, length)` which I could use; WiringPi has `int wiringPiI2CReadReg16 (int fd, int reg)` but I am somewhat confused by the `reg`. There seems to be no definition of device registers.
I have looked at the WiringPi code and read http://www.mjmwired.net/kernel/Document ... -interface
Can anyone clarify and/or show some sample code.
Re: WiringPi I2C library to get 16bit value
I had a similar problem where I needed to read 4 bytes over i2c.
read(fd, temp, 4);
read(fd, temp, 4);
Re: WiringPi I2C library to get 16bit value
reg is the data address to read from. This corresponds to the parameter after the chip-address when you call i2cget,WiringPi has `int wiringPiI2CReadReg16 (int fd, int reg)` but I am somewhat confused by the `reg`.
Code: Select all
i2cget -y 1 0x48 0x0 w
Code: Select all
int fd = wiringPiI2CSetup (0x48);
int data = wiringPiI2CReadReg16 (fd, 0x0);