[Armadillo:05427] Armadillo I2C communication problem

Dimitris Tsiougkos email@hidden
2010年 7月 14日 (水) 00:01:33 JST


Hello to everyone,

I am new user of the Armadillo 500 embedded platform and I am very happy
with this extremely powerful development board.
I am writing a small piece of code using the I2C interface and a problem
occurs when I am trying to write and read with the ioctl_rdrw. My code is
bellow.

int main(int argc, char **argv)
{
  struct i2c_rdwr_ioctl_data rdwr_msg;
  unsigned int i2fd;
  unsigned short addr;
  int ret;

   char output[] = {0x2, 0x1, 0x1};
   char input[10] = {0};
   addr = 0x18;

  fd = open("/dev/i2c-0", O_RDWR);

  if (!i2cfd) {
  printf("Error on opening the device file\n");
  return 0;
  }

  rdwr_msg.nmsgs = 2;

  rdwr_msg.msgs = (struct i2c_msg*)malloc(rdwr_msg.nmsgs*sizeof(struct
i2c_msg));
  if (!rdwr_msg.msgs) {
   printf("Memory alloc error\n");
   close(fd);
   return 0;
  }


        (rdwr_msg.msgs[1]).len = 4;
     (rdwr_msg.msgs[1]).addr  = start_address;
     (rdwr_msg.msgs[1]).flags = I2C_M_RD;
     (rdwr_msg.msgs[1]).buf = &input[0];

     rdwr_msg.msgs[0].len   = 3;
     (rdwr_msg.msgs[0]).addr  = start_address;
     (rdwr_msg.msgs[0]).flags = 0;
     (rdwr_msg.msgs[0]).buf = &output[0];

  ioctl(fd,I2C_TIMEOUT,3);  /* set the timeout    */
  ioctl(fd,I2C_RETRIES,1);  /* set the retries    */

  ret = ioctl(fd,I2C_RDWR, &rdwr_msg);

  if ( ret < 0 ) {
  printf("Error during I2C_RDWR ioctl with error code: %d\n",ret);
  }

  close(fd);

  return;
}

As you can see the code is quite simple. I can write but when a read
transaction is called, a failure is caused.

I also used the SMSbus transactions since the i2c-dev driver supports these
features.
But the problem remains. I put some printk in the driver code (mxc_i2c.c)
and an arbitration lost occurs.
To be more specific, I want to communicate with a device (in address 0x18)
which receives a command like 0x2 0x1 0x1 and sends a response
like 0x3 0x1 0x0 0x1. The problem is in master reception when the SDA
remains high and the SCL is LOW. Form the I2C spec, the arbitration is lost.

Could you please help this situation?

Thank you for your time.

Take care

Dimitris
-- 
Dpl Ing. Dimitris Tsiougkos
-------------- next part --------------
HTML$B$NE:IU%U%!%$%k$rJ]4I$7$^$7$?(B...
URL: <http://lists.atmark-techno.com/pipermail/armadillo/attachments/20100713/ea485842/attachment.html>


armadillo メーリングリストの案内