Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

i2c lpcopen library can't address correctly 16 bit addresses on read command #200

Closed
gustavosr8 opened this issue Feb 2, 2024 · 0 comments · Fixed by #201
Closed

i2c lpcopen library can't address correctly 16 bit addresses on read command #200

gustavosr8 opened this issue Feb 2, 2024 · 0 comments · Fixed by #201

Comments

@gustavosr8
Copy link
Contributor

The 24xx64 eeprom driver uses two 8 bits field to address the i2c read command

size_t eeprom_24xx64_read( uint8_t id, uint16_t address, uint8_t *rx_data, size_t buf_len, TickType_t timeout )
{
uint8_t i2c_addr;
uint8_t i2c_interface;
uint8_t rx_len = 0;
uint8_t addr8[2];
addr8[0] = (address >> 8) & 0xFF;
addr8[1] = (address) & 0xFF;
if ( rx_data == NULL ) {
return 0;
}
if (i2c_take_by_chipid( id, &i2c_addr, &i2c_interface, timeout ) ) {
rx_len = xI2CMasterWriteRead (i2c_interface, i2c_addr, addr8, rx_data, buf_len);
i2c_give( i2c_interface );
}
return rx_len;
}

but the lpcopen module that handle this expect only one 8 bit address

/* Transmit one byte and receive an array of bytes after a repeated start condition is generated in Master mode.
* This function is useful for communicating with the I2C slave registers
*/
int Chip_I2C_MasterCmdRead(I2C_ID_T id, uint8_t slaveAddr, uint8_t cmd, uint8_t *buff, int len)
{
I2C_XFER_T xfer = {0};
xfer.slaveAddr = slaveAddr;
xfer.txBuff = &cmd;
xfer.txSz = 1;
xfer.rxBuff = buff;
xfer.rxSz = len;
while (Chip_I2C_MasterTransfer(id, &xfer) == I2C_STATUS_ARBLOST) {}
return len - xfer.rxSz;
}

For this reason, we need to build a custom function to handle this i2c transaction that accepts any size of command field.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant