Commit 1436895b authored by Raptor Engineering Development Team's avatar Raptor Engineering Development Team Committed by Timothy Pearson

Enable full 64-byte page writes with direct I2C access

parent 0127f233
......@@ -52,12 +52,20 @@ static int i2c_write_2b(struct eeprom *e, __u8 buf[2])
static int i2c_write_arbitrary(struct eeprom *e, __u8 *buf, int len)
{
int r;
// we must simulate a plain I2C byte write with SMBus functions
r = i2c_smbus_write_i2c_block_data(e->fd, buf[0], len-1, buf+1);
if(r < 0)
if (ioctl(e->fd, I2C_SLAVE, e->addr) < 0) {
fprintf(stderr, "Error i2c_write_arbitrary: %s\n", strerror(errno));
usleep(10);
return r;
return -1;
}
r = write(e->fd, buf, len);
if (r < 0) {
fprintf(stderr, "Error i2c_write_arbitrary: %s\n", strerror(errno));
return r;
}
if (r != len) {
fprintf(stderr, "Error i2c_write_arbitrary: short write (%d of %d expected)\n", r, len);
return -1;
}
return 0;
}
......
......@@ -23,9 +23,7 @@
#define EEPROM_TYPE_8BIT_ADDR 1
#define EEPROM_TYPE_16BIT_ADDR 2
// SMBus is limited to 32 bytes
// Unfortunately, the 16-bit addressing on the EEPROM chews up one of those bytes, and further downgrades the max transfer size to 16 bytes of data (since we have to stay power of 2 aligned)
#define MAX_PAGE_SIZE 16
#define MAX_PAGE_SIZE 64
struct eeprom
{
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment