Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am supposed to write a simple write and read program for i2c but the problem is that I don't have the device at hand presently to test it so I need my code to be perfect.

I am confused about the function of the I2C_SLAVE ioctl. From what I read,this ioctl is used to set the slave address.

But we pass the slave address again when performing read/write using ioctl I2C_RDWR via Addr in the structure i2c_msg. In the linux documentation it is mentioned the address set using I2C_RDWR has precedence over address set by I2C_SLAVE.

So then,what is the function of I2C_SLAVE command? Is it required?

share|improve this question
You should consider adding more information about what you tried yourself – Ivo Flipse Mar 26 '12 at 13:24

I2C_SLAVE will change the slave address, so probably you need to use this command before writing to a specific address or read from specific address.

share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .