Skip to content

Commit d7ac8f6

Browse files
committed
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.
1 parent cdc0141 commit d7ac8f6

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

mcp2515.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -754,3 +754,13 @@ void MCP2515::clearERRIF()
754754
//clearInterrupts();
755755
modifyRegister(MCP_CANINTF, CANINTF_ERRIF, 0);
756756
}
757+
758+
uint8_t MCP2515::errorCountRX(void)
759+
{
760+
return readRegister(MCP_REC);
761+
}
762+
763+
uint8_t MCP2515::errorCountTX(void)
764+
{
765+
return readRegister(MCP_TEC);
766+
}

mcp2515.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -488,6 +488,8 @@ class MCP2515
488488
void clearRXnOVR(void);
489489
void clearMERR();
490490
void clearERRIF();
491+
uint8_t errorCountRX(void);
492+
uint8_t errorCountTX(void);
491493
};
492494

493495
#endif

0 commit comments

Comments
 (0)