>>I2C master mode is default, so calling this IOCTL command does not change anything in the example.
I run the sample code, the I2CR0 register MSTA bit is always a "0", ie, slave mode. no matter I use "ioctl (fd, IO_IOCTL_I2C_SET_MASTER_MODE, NULL)" or change it to "ioctl (fd, IO_IOCTL_I2C_SET_SLAVE_MODE, NULL)" in file i2c.c file, at line 119. Don't know why.
>>fwrite (mem, 1, 0, fd) is dummy send of 0 units of 1 byte size from mem buffer (so the buffer doesn't have to be initialized), this only generates START condition on the bus (as it's first read/write call) and sends the I2C destination address.
I2C des address was set at line 74(file "eeprom_polled.c"): param = I2C_EEPROM_ADDRESS | ((addr >> 8) & 7); Then, "ioctl (fd, IO_IOCTL_I2C_SET_DESTINATION_ADDRESS, ¶m)" is called at line 76, don't know what is going on here though. Anyway, how can the fwrite, at line 88, send the first control byte, which seems to be with "param" out after initial a I2C start?