2009-05-30 09:46:04     bfin i2c twi block read and write query

Document created by Aaronwu Employee on Aug 15, 2013
Version 1Show Document
  • View in full screen mode

2009-05-30 09:46:04     bfin i2c twi block read and write query

Appalayagari Sreedhar (INDIA)

Message: 74819   




I am working with BF527 and in my hardware i have two     i2c devices connected to the TWI of BF527.


I have 2 questions.


1 question:


The i2c protocol for block writing for one of the slave device is as follows


S Addr Wr [A] subreg [A]  Data [A] Data [A] ... [A] Data [A] P


the smbus protocl for block write is as below.  from the documentation



The opposite of the Block Read command, this writes up to 32 bytes to

a device, to a designated register that is specified through the

Comm byte. The amount of data is specified in the Count byte.


S Addr Wr [A] Comm [A] Count [A] Data [A] Data [A] ... [A] Data [A] P


The smbus black write api has "Count" parameter extra. Is it possible that i can write one more api similar iike the smbus block write without count parameter. will that be proper method or smbus protocol does not support this?


2 Question.


I have opened the device succesfully.uisng the below syntax.


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


i want to read block of data.


ret = read(i2c_fd,buff,3);  is this read starts from which address is this starts at default  zero address?


suppose if i want to read a block of data from 2nd register onwards how to call this api synatax. I dont want to use the smbus block read api because it does not suits my requirement.


please let me know if my question is not clear. i will be glad to frame the question in a proper way.






2009-05-30 10:39:06     Re: bfin i2c twi block read and write query


Message: 74820   




What I2C devices is it? normally the I2C device has a "register address" register - that you write to - and then read from the device to get the info from that register.






2009-05-31 04:36:41     Re: bfin i2c twi block read and write query

Sonic Zhang (CHINA)

Message: 74874   


1. Don't use i2c smbus API. Use ioctl() I2C_RDWR API with multi messages in i2c_data structure instead. Please refer to the SVN trunk twi_test source for an example.


2. Use ioctl() to set the specific i2c address before read() or write().