Skip to content
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

Fix for I2C #40

Merged
merged 1 commit into from
Dec 12, 2020
Merged
Show file tree
Hide file tree
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
4 changes: 2 additions & 2 deletions cores/arduino/Wire.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ uint8_t TwoWire::requestFrom(uint8_t address, uint8_t quantity) {

// perform blocking read into buffer
I2C_M_SETUP_Type transferMCfg;
transferMCfg.sl_addr7bit = address >> 1; // not sure about the right shift
transferMCfg.sl_addr7bit = address;
transferMCfg.tx_data = NULL;
transferMCfg.tx_length = 0;
transferMCfg.rx_data = rxBuffer;
Expand Down Expand Up @@ -153,7 +153,7 @@ void TwoWire::beginTransmission(int address) {
uint8_t TwoWire::endTransmission(void) {
// transmit buffer (blocking)
I2C_M_SETUP_Type transferMCfg;
transferMCfg.sl_addr7bit = txAddress >> 1; // not sure about the right shift
transferMCfg.sl_addr7bit = txAddress;
transferMCfg.tx_data = txBuffer;
transferMCfg.tx_length = txBufferLength;
transferMCfg.rx_data = NULL;
Expand Down
4 changes: 2 additions & 2 deletions system/CMSIS/driver/lpc17xx_i2c.c
Original file line number Diff line number Diff line change
Expand Up @@ -516,9 +516,9 @@ int32_t I2C_MasterHanleStates(LPC_I2C_TypeDef *I2Cx, uint32_t CodeStatus, I2C_M
Ret = I2C_BYTE_RECV;
break;
case I2C_I2STAT_M_RX_DAT_ACK:
if (TransferCfg->rx_count <TransferCfg->rx_length)
if (TransferCfg->rx_count < TransferCfg->rx_length)
{
if (TransferCfg->rx_count < (TransferCfg->rx_length - 2))
if (TransferCfg->rx_count < (TransferCfg->rx_length - 1))
{
I2C_GetByte(I2Cx, &tmp, TRUE);

Expand Down