Skip to content

Commit

Permalink
Calculate I3C read timeout based on input size and SCL frequency
Browse files Browse the repository at this point in the history
Default timeout used during reads falls short during read operations.
Use input size and SCL frequency to calculate a proper timeout value.

Signed-off-by: Tahsin Mutlugun <[email protected]>
  • Loading branch information
ttmut committed Dec 13, 2024
1 parent eeb59b5 commit 1c6d39e
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion Libraries/PeriphDrivers/Source/I3C/i3c_reva.c
Original file line number Diff line number Diff line change
Expand Up @@ -582,6 +582,8 @@ int MXC_I3C_RevA_Controller_Transaction(mxc_i3c_reva_regs_t *i3c, const mxc_i3c_
int ret;
uint8_t readCount;
uint16_t remaining;
uint32_t timeout;
uint32_t freq;

if (MXC_I3C_RevA_Controller_GetState(i3c) != MXC_V_I3C_REVA_CONT_STATUS_STATE_IDLE &&
MXC_I3C_RevA_Controller_GetState(i3c) != MXC_V_I3C_REVA_CONT_STATUS_STATE_SDR_NORM) {
Expand Down Expand Up @@ -633,8 +635,15 @@ int MXC_I3C_RevA_Controller_Transaction(mxc_i3c_reva_regs_t *i3c, const mxc_i3c_
goto err;
}

if (req->is_i2c) {
freq = MXC_I3C_RevA_GetI2CFrequency(i3c);
} else {
freq = MXC_I3C_RevA_GetPPFrequency(i3c);
}
timeout = (uint32_t)(20 * 1000000 / freq) * readCount;

ret = MXC_I3C_RevA_ReadRXFIFO(i3c, req->rx_buf + (req->rx_len - remaining), readCount,
1000);
timeout);
if (ret == readCount) {
remaining -= readCount;
} else {
Expand Down

0 comments on commit 1c6d39e

Please sign in to comment.