diff --git a/cores/arduino/Wire.cpp b/cores/arduino/Wire.cpp index 0a51eb8..2499bbf 100644 --- a/cores/arduino/Wire.cpp +++ b/cores/arduino/Wire.cpp @@ -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; @@ -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; diff --git a/system/CMSIS/driver/lpc17xx_i2c.c b/system/CMSIS/driver/lpc17xx_i2c.c index 99b29e0..2aa648f 100644 --- a/system/CMSIS/driver/lpc17xx_i2c.c +++ b/system/CMSIS/driver/lpc17xx_i2c.c @@ -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 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);