Open GoogleCodeExporter opened 9 years ago
Posting a solution if anyone else gets perplexed like me ...
Basically, you have to start writing to I2C with the address of slave SHIFTED 1 bit to the left (last bit 0 for writes, or 1 for reads) so the above code would be something like:
//writing part
char Data={"\0x90\0x01\x11\x22"};
Start(context);
Write (Context,Data,4); //equals ioctl and i2c_smbus_write_word_data above
Stop(context);
//reading part
Start(Context);
Data[1]=\0x00; // ADS1015_REG_POINTER_CONVERT=0x00
Write (Context,Data,2); //set the register for read
Stop(context);
Start(Context);
Data[0]=\0x91;
Write (Context,Data,1); //State you want to read from address 0x48 (0x48<<1)|1
Read (Context,2); //read the word (2 bytes) of data
Stop(Context);
Original comment by Rezodl...@gmail.com
on 19 Mar 2014 at 5:24
This was useful to me. Thanks for taking the time to post the solution.
In the i2ceeprom.c example, it writes each of these values as the start of each transaction:
#define WCMD "\xA0\x00\x00" // Write start address command
#define RCMD "\xA1" // Read command
The Write Command (WCMD) is this:
0xA0: The I2C header: Slave Address of the eeprom device shifted left one bit, with the Read Flag (bit0) set to zero. 0x0000: The eeprom's 32-bit start address to write to, in this example, it starts at zero (0x0000).
The Read Command (RCMD) is just the I2C Header: the Slave Address byte again (0xA0), but this time with the Read Flag set to one (0x1). So (0xA0 | 0x1) == 0xA1, and the eeprom responds with its saved bytes (starting at 0x0000).
Original issue reported on code.google.com by
Rezodl...@gmail.com
on 10 Mar 2014 at 8:51