Skip to content

Commit 0f24a0c

Browse files
committed
drivers: i2c: sam0 Fix i2c NACK on receive
PR #38482 made the sam0 i2c send NACK when receiving a single message Fixes #38878 Fixes #41016 Signed-off-by: Christoffer Zakrisson <[email protected]>
1 parent f1f0dad commit 0f24a0c

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

drivers/i2c/i2c_sam0.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ static void i2c_sam0_isr(const struct device *dev)
162162
data->msg.buffer++;
163163
data->msg.size--;
164164
} else if (status & SERCOM_I2CM_INTFLAG_SB) {
165-
if (!continue_next) {
165+
if (!continue_next && (data->msg.size == 1)) {
166166
/*
167167
* If this is the last byte, then prepare for an auto
168168
* NACK before doing the actual read. This does not
@@ -175,7 +175,7 @@ static void i2c_sam0_isr(const struct device *dev)
175175
data->msg.buffer++;
176176
data->msg.size--;
177177

178-
if (!continue_next) {
178+
if (!continue_next && !data->msg.size) {
179179
i2c->INTENCLR.reg = SERCOM_I2CM_INTENCLR_MASK;
180180
k_sem_give(&data->sem);
181181
return;

0 commit comments

Comments
 (0)