From d7ac8f65c7d0db5bad2057cebe9124e4e980e1ba Mon Sep 17 00:00:00 2001 From: Stephan Martin Date: Sat, 5 Jun 2021 09:59:16 +0200 Subject: [PATCH] Add functions to expose the RX/TX error counters This exposes the REC and TEC registers. They hold the error counters and can give insides before the checkError triggers. --- mcp2515.cpp | 10 ++++++++++ mcp2515.h | 2 ++ 2 files changed, 12 insertions(+) diff --git a/mcp2515.cpp b/mcp2515.cpp index 989b752..6b86fb9 100644 --- a/mcp2515.cpp +++ b/mcp2515.cpp @@ -754,3 +754,13 @@ void MCP2515::clearERRIF() //clearInterrupts(); modifyRegister(MCP_CANINTF, CANINTF_ERRIF, 0); } + +uint8_t MCP2515::errorCountRX(void) +{ + return readRegister(MCP_REC); +} + +uint8_t MCP2515::errorCountTX(void) +{ + return readRegister(MCP_TEC); +} diff --git a/mcp2515.h b/mcp2515.h index 2a4f8ef..5d9bef7 100644 --- a/mcp2515.h +++ b/mcp2515.h @@ -488,6 +488,8 @@ class MCP2515 void clearRXnOVR(void); void clearMERR(); void clearERRIF(); + uint8_t errorCountRX(void); + uint8_t errorCountTX(void); }; #endif