I already told you I didn't change the SDK code. I just used the APIs that the SDK provides differently.
static int32_t MemRead(uint16_t addr, void *data, uint32_t len)
{
int32_t ret = MEM_OP_OK;
if(0 == len){
return ret;
}
if(kStatus_Success == LPI2C_MasterStart(MEM_I2C_PERIPH, I2C_EEPROM_ADDRESS, kLPI2C_Write)){
uint8_t a[2];
a[0] = (addr>>8)&0xff;
a[1] = (addr>>0)&0xff;
if(kStatus_Success != LPI2C_MasterSend(MEM_I2C_PERIPH, a, 2)){
ret = MEM_OP_FAIL;
goto read_end;
}
uint32_t ToGo = len;
uint32_t chunk;
uint8_t *pData8 = data;
uint32_t idxData = 0;
while(ToGo > 0){
chunk = ToGo > 256 ? 256 : ToGo;
if(kStatus_Success != LPI2C_MasterRepeatedStart(MEM_I2C_PERIPH, I2C_EEPROM_ADDRESS, kLPI2C_Read)){
ret = MEM_OP_FAIL;
goto read_end;
}
if(kStatus_Success != LPI2C_MasterReceive(MEM_I2C_PERIPH, &pData8[idxData], chunk)){
ret = MEM_OP_FAIL;
goto read_end;
}
ToGo -= chunk;
idxData += chunk;
}
}
read_end:
if(kStatus_Success == LPI2C_MasterStop(MEM_I2C_PERIPH)){
if(MEM_OP_FAIL == ret){
return MEM_OP_FAIL;
}else{
return MEM_OP_OK;
}
}else{
return MEM_OP_FAIL;
}
}
I use this function (which should not be part of the HAL provided by the SDK) to read, via i2c, from an EEProm memory, for example 24C64.
You can see (lines 15~31) that there are more repeated starts for readings of more than 256 bytes.
This works because the device is an EEprom memory, that require the address of memory location that are going to be read.

There is a set of devices that instead requires the sequential reading of all registers (e.g. some sensors, or complex devices with multiple functions). For these devices the readings always take place from the first register and go in sequence. It is not possible to address the single register, in other words it is not possible to make random readings. At the beginning of each reading transaction they restart from the first register. And the start of the transaction is given by a start or a repeated start.
Assuming the registers are all 8-bit and assuming the device has 300 registers, how can I read all 300 registers in a single transaction? Remember that each start/repeated start condition restarts the reading from the first register. So adopting the solution I adopted for the memory (ie use repeated start) I could read only the first 256 registers and never the following.
best regards
Max