From 10cd5800612c737e2420801b77eb324a4eb240a2 Mon Sep 17 00:00:00 2001 From: Neil McKechnie Date: Thu, 16 Feb 2023 22:27:23 +0000 Subject: [PATCH] Update I2CManager_NonBlocking.h Missing initialisation of read buffer pointer! --- I2CManager_NonBlocking.h | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/I2CManager_NonBlocking.h b/I2CManager_NonBlocking.h index 322ca88..fb5bae5 100644 --- a/I2CManager_NonBlocking.h +++ b/I2CManager_NonBlocking.h @@ -316,6 +316,7 @@ void I2CManagerClass::handleInterrupt() { deviceAddress = rbAddress; sendBuffer = currentRequest->writeBuffer; bytesToSend = currentRequest->writeLen; + receiveBuffer = currentRequest->readBuffer; bytesToReceive = currentRequest->readLen; operation = currentRequest->operation & OPERATION_MASK; state = I2C_STATE_ACTIVE; @@ -326,16 +327,21 @@ void I2CManagerClass::handleInterrupt() { // Application request completed, now send epilogue to mux overallStatus = completionStatus; currentRequest->nBytes = rxCount; // Save number of bytes read into rb - muxPhase = MuxPhase_EPILOG; - deviceAddress = I2C_MUX_BASE_ADDRESS + currentRequest->i2cAddress.muxNumber(); - muxData[0] = 0x00; - sendBuffer = &muxData[0]; - bytesToSend = 1; - bytesToReceive = 0; - operation = OPERATION_SEND; - state = I2C_STATE_ACTIVE; - I2C_sendStart(); - return; + if (_muxCount == 1) { + // Only one MUX, don't need to deselect subbus + muxPhase = MuxPhase_OFF; + } else { + muxPhase = MuxPhase_EPILOG; + deviceAddress = I2C_MUX_BASE_ADDRESS + currentRequest->i2cAddress.muxNumber(); + muxData[0] = 0x00; + sendBuffer = &muxData[0]; + bytesToSend = 1; + bytesToReceive = 0; + operation = OPERATION_SEND; + state = I2C_STATE_ACTIVE; + I2C_sendStart(); + return; + } } else if (muxPhase == MuxPhase_EPILOG) { // Epilog finished, ignore completionStatus muxPhase = MuxPhase_OFF;