-
Notifications
You must be signed in to change notification settings - Fork 104
Open
Description
“If an error occurs during an I2C read/write operation (e.g., the slave device is powered off during the transfer), i2c_master_read_sync in i2c_master.c only waits on yield_for(&ready) without checking the returned status. Consequently, i2c_master_read_sync reports success even when the I2C transaction fails.”
int i2c_master_read_sync(uint16_t address, uint8_t* buffer, uint16_t len) {
bool ready = 0;
int rval = i2c_master_set_buffer(buffer, len);
if (rval < 0) return rval;
rval = i2c_master_set_callback(i2c_callback, &ready);
if (rval < 0) return rval;
rval = i2c_master_read(address, len);
if (rval < 0) return rval;
yield_for(&ready);
return RETURNCODE_SUCCESS;
}
Metadata
Metadata
Assignees
Labels
No labels