diff --git a/I2CManager_Mega4809.h b/I2CManager_Mega4809.h index a8254a9..0b8e8ca 100644 --- a/I2CManager_Mega4809.h +++ b/I2CManager_Mega4809.h @@ -72,7 +72,7 @@ void I2CManagerClass::I2C_sendStart() { bytesToReceive = currentRequest->readLen; // If anything to send, initiate write. Otherwise initiate read. - if (operation == OPERATION_READ || ((operation == OPERATION_REQUEST) & !bytesToSend)) + if (operation == OPERATION_READ || ((operation == OPERATION_REQUEST) && !bytesToSend)) TWI0.MADDR = (currentRequest->i2cAddress << 1) | 1; else TWI0.MADDR = (currentRequest->i2cAddress << 1) | 0; diff --git a/I2CManager_Wire.h b/I2CManager_Wire.h index 26deb74..87152e7 100644 --- a/I2CManager_Wire.h +++ b/I2CManager_Wire.h @@ -94,22 +94,24 @@ uint8_t I2CManagerClass::read(uint8_t address, uint8_t readBuffer[], uint8_t rea /*************************************************************************** * Function to queue a request block and initiate operations. * - * For the Wire version, this executes synchronously, but the status is - * returned in the I2CRB as for the asynchronous version. + * For the Wire version, this executes synchronously. + * The read/write/write_P functions return I2C_STATUS_OK always, and the + * completion status of the operation is in the request block, as for + * the non-blocking version. ***************************************************************************/ void I2CManagerClass::queueRequest(I2CRB *req) { switch (req->operation) { case OPERATION_READ: - req->status = read(req->i2cAddress, req->readBuffer, req->readLen, NULL, 0, req); + read(req->i2cAddress, req->readBuffer, req->readLen, NULL, 0, req); break; case OPERATION_SEND: - req->status = write(req->i2cAddress, req->writeBuffer, req->writeLen, req); + write(req->i2cAddress, req->writeBuffer, req->writeLen, req); break; case OPERATION_SEND_P: - req->status = write_P(req->i2cAddress, req->writeBuffer, req->writeLen, req); + write_P(req->i2cAddress, req->writeBuffer, req->writeLen, req); break; case OPERATION_REQUEST: - req->status = read(req->i2cAddress, req->readBuffer, req->readLen, req->writeBuffer, req->writeLen, req); + read(req->i2cAddress, req->readBuffer, req->readLen, req->writeBuffer, req->writeLen, req); break; } }