Skip to content

freescale: fix i2c_byte_read function #11141

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions targets/TARGET_Freescale/TARGET_MCUXpresso_MCUS/api/i2c_api.c
Original file line number Diff line number Diff line change
Expand Up @@ -192,10 +192,8 @@ int i2c_byte_read(i2c_t *obj, int last)
base->C1 |= I2C_C1_TXAK_MASK; // NACK
}

data = (base->D & 0xFF);

/* Change direction to Tx to avoid extra clocks. */
base->C1 |= I2C_C1_TX_MASK;
/* Read dummy to release the bus. */
data = base->D;

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

/* Change direction to Tx to avoid extra clocks. */
base->C1 |= I2C_C1_TX_MASK;

data = (base->D & 0xFF);

return data;
}

Expand Down