I had a quick look and can't see anything obviously wrong. Have you switched the combined flag on separately?
The current version of pigpio (V31) has limited support for such transactions. It might be worth looking at the code I use (pigpio.c, line 3420, i2cTransaction). I haven't decided to leave it in or remove it.
This is test code I used.
Code: Select all
/*
i2c_transaction_test.c
2015-02-02
Public Domain
gcc -o itt i2cTransaction_test.c -lpigpio -lrt -lpthread
sudo ./itt
A test of the pigpio i2cTransaction function.
struct i2c_msg rdwr_msgs[2] = {
{ // Start address
.addr = 0x50,
.flags = 0, // write
.len = 1,
.buf = ®_address
},
{ // Read buffer
.addr = 0x50,
.flags = I2C_M_RD, // read
.len = 16,
.buf = buffer
}
};
struct i2c_rdwr_ioctl_data rdwr_data = {
.msgs = rdwr_msgs,
.nmsgs = 2
};
file = open( "/dev/i2c-1", O_RDWR );
...
result = ioctl( file, I2C_RDWR, &rdwr_data );
*/
#include <stdio.h>
#include <pigpio.h>
uint8_t buffer[]={0xAA, 0x55, 0x0F, 0xF0, 0x00, 0xFF};
pi_i2c_msg_t rdwr_msgs[]=
{
{.addr = 0x1E, .flags = PI_I2C_M_WR, .len = 0, .buf = buffer},
{.addr = 0x1E, .flags = PI_I2C_M_RD, .len = 1, .buf = buffer},
{.addr = 0x53, .flags = PI_I2C_M_WR, .len = 0, .buf = buffer},
{.addr = 0x53, .flags = PI_I2C_M_RD, .len = 1, .buf = buffer},
{.addr = 0x68, .flags = PI_I2C_M_WR, .len = 0, .buf = buffer},
{.addr = 0x68, .flags = PI_I2C_M_RD, .len = 1, .buf = buffer},
};
int main(int argc, char *argv[])
{
int i, h;
int status;
if (gpioInitialise() < 0) return 1;
printf("start piscope, then press return\n");
getchar();
h = i2cOpen(1, 0x1E, 0);
if (h >= 0)
{
for (i=0; i<10; i++)
{
status = i2cTransaction(h, rdwr_msgs, 6);
printf("i2cTransaction status = %d\n", status);
usleep(20000);
}
i2cClose(h);
}
printf("stop piscope, then press return\n");
getchar();
gpioTerminate();
}
I noticed that leaving the combined flag set seem to screw up ordinary I2C transactions.
You can reset the flag with the following command.
sudo sh -c "echo 0 >/sys/module/i2c_bcm2708/parameters/combined"
and set the flag with
sudo sh -c "echo 1 >/sys/module/i2c_bcm2708/parameters/combined"