From c2bd0121647abf7210e8c01742d0e1a95665b84d Mon Sep 17 00:00:00 2001 From: peteGSX Date: Tue, 16 Jan 2024 19:37:16 +1000 Subject: [PATCH] Push with DIAGS --- I2CManager.h | 21 +++++++++++++++++++++ I2CManager_Wire.h | 9 +++++++++ 2 files changed, 30 insertions(+) diff --git a/I2CManager.h b/I2CManager.h index 08d81d4..b380294 100644 --- a/I2CManager.h +++ b/I2CManager.h @@ -418,6 +418,27 @@ public: #if !defined(I2C_USE_WIRE) I2CRB *nextRequest; // Used by non-blocking devices for I2CRB queue management. #endif + + inline void dump() { + switch (operation & OPERATION_MASK) { + case OPERATION_READ: + DIAG(F("Read addr=%x buf=%x, len=%d"), i2cAddress, readBuffer, readLen); + break; + case OPERATION_SEND: + DIAG(F("Send addr=%x buf=%x, len=%d"), i2cAddress, writeBuffer, writeLen); + break; + case OPERATION_SEND_P: + DIAG(F("SendP addr=%x buf=%x, len=%d"), i2cAddress, writeBuffer, writeLen); + break; + case OPERATION_REQUEST: + DIAG(F("Request addr=%x rbuf=%x, rlen=%d rbuf=%x, rlen=%d"), i2cAddress, readBuffer, readLen, writeBuffer, writeLen); + break; + default: + DIAG(F("No Op... WHAT???")); + break; + } + }; + }; // I2C Manager diff --git a/I2CManager_Wire.h b/I2CManager_Wire.h index 1fd4d67..e8d5668 100644 --- a/I2CManager_Wire.h +++ b/I2CManager_Wire.h @@ -146,6 +146,7 @@ uint8_t I2CManagerClass::write_P(I2CAddress address, const uint8_t buffer[], uin uint8_t I2CManagerClass::read(I2CAddress address, uint8_t readBuffer[], uint8_t readSize, const uint8_t writeBuffer[], uint8_t writeSize, I2CRB *rb) { + DIAG(F("I2CManagerClass::read()")); uint8_t status, muxStatus; uint8_t nBytes = 0; uint8_t retryCount = 0; @@ -210,6 +211,11 @@ uint8_t I2CManagerClass::read(I2CAddress address, uint8_t readBuffer[], uint8_t * the non-blocking version. ***************************************************************************/ void I2CManagerClass::queueRequest(I2CRB *req) { + if (req==NULL) { + DIAG(F("NOOOOOOOOOOO")); + return; + } + req->dump(); switch (req->operation & OPERATION_MASK) { case OPERATION_READ: read(req->i2cAddress, req->readBuffer, req->readLen, NULL, 0, req); @@ -223,6 +229,9 @@ void I2CManagerClass::queueRequest(I2CRB *req) { case OPERATION_REQUEST: read(req->i2cAddress, req->readBuffer, req->readLen, req->writeBuffer, req->writeLen, req); break; + default: + DIAG(F("No Op... WHAT???")); + break; } }