Skip to content

Commit a1bd360

Browse files
author
Anton N
committed
Allow to change clock for MCP2515 in order to support mcp2515+TJA1080 shields and modules
1 parent efd7398 commit a1bd360

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

CanHacker.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,12 @@ Stream *CanHacker::getInterfaceStream() {
5454
return _stream;
5555
}
5656

57+
void CanHacker::setClock(uint8_t clock){
58+
canClock = clock;
59+
}
60+
5761
CanHacker::ERROR CanHacker::connectCan() {
58-
MCP2515::ERROR error = mcp2515->setBitrate(bitrate);
62+
MCP2515::ERROR error = mcp2515->setBitrate(bitrate, canClock);
5963
if (error != MCP2515::ERROR_OK) {
6064
writeDebugStream(F("setBitrate error:\n"));
6165
writeDebugStream((int)error);

CanHacker.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ class CanHacker {
4747

4848
CanHacker(Stream *stream, Stream *debugStream, uint8_t cs);
4949
~CanHacker();
50+
void setClock(const uint8_t clock);
5051
ERROR receiveCommand(const char *buffer, const int length);
5152
ERROR receiveCanFrame(const struct can_frame *frame);
5253
ERROR sendFrame(const struct can_frame *);
@@ -64,6 +65,7 @@ class CanHacker {
6465
static const char BEL = 7;
6566
static const uint16_t TIMESTAMP_LIMIT = 0xEA60;
6667

68+
uint8_t canClock = MCP_16MHZ;
6769
bool _timestampEnabled = false;
6870
bool _listenOnly = false;
6971
bool _loopback = false;

0 commit comments

Comments
 (0)