Skip to content

Commit

Permalink
drivers: i2c: i2c_ll_stm32_v1
Browse files Browse the repository at this point in the history
In rare cases, the I2C driver runs the N==2 logic
for I2C receives when N>2. This change breaks early
when handling the last 2 bytes for transactions with N>2

Signed-off-by: Mikhail Skobov <[email protected]>
  • Loading branch information
kail authored and nashif committed May 3, 2024
1 parent 5d44ebf commit 7d362e0
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions drivers/i2c/i2c_ll_stm32_v1.c
Original file line number Diff line number Diff line change
Expand Up @@ -359,6 +359,14 @@ static inline void handle_rxne(const struct device *dev)
k_sem_give(&data->device_sync_sem);
break;
case 2:
/*
* 2-byte reception for N > 3 has already set the NACK
* bit, and must not set the POS bit. See pg. 854 in
* the F4 reference manual (RM0090).
*/
if (data->current.msg->len > 2) {
break;
}
LL_I2C_AcknowledgeNextData(i2c, LL_I2C_NACK);
LL_I2C_EnableBitPOS(i2c);
__fallthrough;
Expand Down

0 comments on commit 7d362e0

Please sign in to comment.