Skip to content

Commit 1e4a837

Browse files
author
Seppo Takalo
authored
Merge pull request #11141 from maciejbocianski/i2c_Xpresso_byte_read_fix
freescale: fix i2c_byte_read function
2 parents 34813ed + b788541 commit 1e4a837

File tree

1 file changed

+7
-4
lines changed
  • targets/TARGET_Freescale/TARGET_MCUXpresso_MCUS/api

1 file changed

+7
-4
lines changed

targets/TARGET_Freescale/TARGET_MCUXpresso_MCUS/api/i2c_api.c

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -192,10 +192,8 @@ int i2c_byte_read(i2c_t *obj, int last)
192192
base->C1 |= I2C_C1_TXAK_MASK; // NACK
193193
}
194194

195-
data = (base->D & 0xFF);
196-
197-
/* Change direction to Tx to avoid extra clocks. */
198-
base->C1 |= I2C_C1_TX_MASK;
195+
/* Read dummy to release the bus. */
196+
data = base->D;
199197

200198
/* Wait until data transfer complete. */
201199
while (!(base->S & kI2C_IntPendingFlag))
@@ -205,6 +203,11 @@ int i2c_byte_read(i2c_t *obj, int last)
205203
/* Clear the IICIF flag. */
206204
base->S = kI2C_IntPendingFlag;
207205

206+
/* Change direction to Tx to avoid extra clocks. */
207+
base->C1 |= I2C_C1_TX_MASK;
208+
209+
data = (base->D & 0xFF);
210+
208211
return data;
209212
}
210213

0 commit comments

Comments
 (0)