From 76734f7380d126ad16932466d4f3d3d1f33781b3 Mon Sep 17 00:00:00 2001 From: peteGSX Date: Thu, 18 Jan 2024 18:29:36 +1000 Subject: [PATCH] Initial success --- I2CManager_Wire.h | 28 ++++++++++++++-------------- IO_EXIOExpander.h | 4 ++-- 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/I2CManager_Wire.h b/I2CManager_Wire.h index e248c2b..3b6b00e 100644 --- a/I2CManager_Wire.h +++ b/I2CManager_Wire.h @@ -147,35 +147,35 @@ uint8_t I2CManagerClass::read(I2CAddress address, uint8_t readBuffer[], uint8_t const uint8_t writeBuffer[], uint8_t writeSize, I2CRB *rb) { // DIAG(F("Read addr=%x rdBuf=%x, rdLen=%d, wrBuf=%x, wrLen=%d"), address, readBuffer, readSize, writeBuffer, writeSize); - DIAG(F("I2CManagerClass::read() hit")); + // DIAG(F("I2CManagerClass::read() hit")); uint8_t status, muxStatus; uint8_t nBytes = 0; uint8_t retryCount = 0; // If request fails, retry up to the defined limit, unless the NORETRY flag is set // in the request block. do { - DIAG(F("do hit")); + // DIAG(F("do hit")); status = muxStatus = I2C_STATUS_OK; - DIAG(F("status=%d"),status); + // DIAG(F("status=%d"),status); #ifdef I2C_EXTENDED_ADDRESS - DIAG(F("Extended address hit")); + // DIAG(F("Extended address hit")); if (address.muxNumber() != I2CMux_None) { muxStatus = muxSelect(address); } #endif // Only start new transaction if address is non-zero. if (muxStatus == I2C_STATUS_OK && address != 0) { - DIAG(F("muxStatus=%d"),muxStatus); + // DIAG(F("muxStatus=%d"),muxStatus); if (writeSize > 0) { - DIAG(F("wrBuf=%x, wrSize=%d"),writeBuffer,writeSize); + // DIAG(F("wrBuf=%x, wrSize=%d"),writeBuffer,writeSize); Wire.beginTransmission(address); Wire.write(writeBuffer, writeSize); status = Wire.endTransmission(false); // Don't free bus yet - DIAG(F("status=%d"),status); + // DIAG(F("status=%d"),status); } if (status == I2C_STATUS_OK) { #ifdef WIRE_HAS_TIMEOUT - DIAG(F("WIRE_HAS_TIMEOUT")); + // DIAG(F("WIRE_HAS_TIMEOUT")); Wire.clearWireTimeoutFlag(); Wire.requestFrom(address, (size_t)readSize); if (!Wire.getWireTimeoutFlag()) { @@ -186,16 +186,16 @@ uint8_t I2CManagerClass::read(I2CAddress address, uint8_t readBuffer[], uint8_t status = I2C_STATUS_TIMEOUT; } #else - DIAG(F("NO timeout")); + // DIAG(F("NO timeout")); Wire.requestFrom(address, (size_t)readSize); - DIAG(F("address=%x, nBytes=%d, readSize=%d"),address,nBytes,readSize); - DIAG(F("Wire.available()=%d"),Wire.available()); + // DIAG(F("address=%x, nBytes=%d, readSize=%d"),address,nBytes,readSize); + // DIAG(F("Wire.available()=%d"),Wire.available()); // while (Wire.available() && nBytes < readSize) while (nBytes < readSize) if (Wire.available()) { // uint8_t temp=nBytes; char readByte=Wire.read(); - DIAG(F("nBytes=%d, readByte=%d"),nBytes,readByte); + // DIAG(F("nBytes=%d, readByte=%d"),nBytes,readByte); // readBuffer[nBytes++] = Wire.read(); readBuffer[nBytes++]=readByte; // DIAG(F("nBytes=%d, readBuffer[nBytes]=%d"), temp, readBuffer[temp]); @@ -204,7 +204,7 @@ uint8_t I2CManagerClass::read(I2CAddress address, uint8_t readBuffer[], uint8_t } // DIAG(F("nBytes=%d,readBuffer[nBytes]=%d"),nBytes-1,readBuffer[nBytes-1]); if (nBytes < readSize) status = I2C_STATUS_TRUNCATED; - DIAG(F("status=%d"),status); + // DIAG(F("status=%d"),status); #endif } } @@ -234,7 +234,7 @@ uint8_t I2CManagerClass::read(I2CAddress address, uint8_t readBuffer[], uint8_t * the non-blocking version. ***************************************************************************/ void I2CManagerClass::queueRequest(I2CRB *req) { - DIAG(F("I2CManagerClass::queueRequest() hit")); + // DIAG(F("I2CManagerClass::queueRequest() hit")); if (req==NULL) { DIAG(F("NOOOOOOOOOOO")); return; diff --git a/IO_EXIOExpander.h b/IO_EXIOExpander.h index 5e7a1e9..1987b2e 100644 --- a/IO_EXIOExpander.h +++ b/IO_EXIOExpander.h @@ -252,7 +252,7 @@ private: // Issue new read request for digital states. As the request is non-blocking, the buffer has to // be allocated from heap (object state). _readCommandBuffer[0] = EXIORDD; - DIAG(F("EXIORDD address=%x, states=%d, bytes=%d"),_I2CAddress,_digitalInputStates,(_numDigitalPins+7)/8); + // DIAG(F("EXIORDD address=%x, states=%d, bytes=%d"),_I2CAddress,_digitalInputStates,(_numDigitalPins+7)/8); I2CManager.read(_I2CAddress, _digitalInputStates, (_numDigitalPins+7)/8, _readCommandBuffer, 1, &_i2crb); // non-blocking read _lastDigitalRead = currentMicros; @@ -260,7 +260,7 @@ private: } else if (currentMicros - _lastAnalogueRead > _analogueRefresh && _numAnaloguePins>0) { // Delay for analogue read refresh // Issue new read for analogue input states _readCommandBuffer[0] = EXIORDAN; - DIAG(F("EXIORDAN address=%x, aBuffer=%d, bytes=%d"),_I2CAddress,_analogueInputBuffer,_numAnaloguePins*2); + // DIAG(F("EXIORDAN address=%x, aBuffer=%d, bytes=%d"),_I2CAddress,_analogueInputBuffer,_numAnaloguePins*2); I2CManager.read(_I2CAddress, _analogueInputBuffer, _numAnaloguePins * 2, _readCommandBuffer, 1, &_i2crb); _lastAnalogueRead = currentMicros;