From d96bc986449740813eed55cc4919dcd2c6337d9e Mon Sep 17 00:00:00 2001 From: Sandeep Mistry Date: Tue, 8 Dec 2020 19:30:06 -0500 Subject: [PATCH 1/8] Create FUNDING.yml --- .github/FUNDING.yml | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 .github/FUNDING.yml diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml new file mode 100644 index 0000000..6612607 --- /dev/null +++ b/.github/FUNDING.yml @@ -0,0 +1,3 @@ +# These are supported funding model platforms + +github: [sandeepmistry] From 382fff7a04673705fbd5bc79e6badd319a03c3a8 Mon Sep 17 00:00:00 2001 From: Ziss Date: Mon, 10 May 2021 22:46:24 +0200 Subject: [PATCH 2/8] Update README.md --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 02f5667..5723c97 100644 --- a/README.md +++ b/README.md @@ -35,8 +35,8 @@ Requires an external 3.3V CAN transceiver, such as a [TI SN65HVD230](http://www. | :-------------: | :---: | | 3V3 | 3V3 | | GND | GND | -| CTX | 5 | -| CRX | 4 | +| CTX | GPIO_5 | +| CRX | GPIO_4 | `CTX` and `CRX` pins can be changed by using `CAN.setPins(rx, tx)`. From b7e40dd25ef3b24dba7484a2735623a39cf0c1f0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Emek=20Bar=C4=B1=C5=9F=20K=C3=BC=C3=A7=C3=BCktabak?= <32764586+emekBaris@users.noreply.github.com> Date: Sat, 19 Nov 2022 09:33:07 -0600 Subject: [PATCH 3/8] reception of empty packets with and without callback (#103) * allows receiving empty packets with and without callback * bug fix * Update examples/CANReceiver/CANReceiver.ino Co-authored-by: emekBaris Co-authored-by: Sandeep Mistry --- examples/CANReceiver/CANReceiver.ino | 2 +- src/MCP2515.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/CANReceiver/CANReceiver.ino b/examples/CANReceiver/CANReceiver.ino index fca49e4..d2f5db8 100644 --- a/examples/CANReceiver/CANReceiver.ino +++ b/examples/CANReceiver/CANReceiver.ino @@ -20,7 +20,7 @@ void loop() { // try to parse packet int packetSize = CAN.parsePacket(); - if (packetSize) { + if (packetSize || CAN.packetId() != -1) { // received a packet Serial.print("Received "); diff --git a/src/MCP2515.cpp b/src/MCP2515.cpp index aa46051..9ad96b7 100644 --- a/src/MCP2515.cpp +++ b/src/MCP2515.cpp @@ -442,7 +442,7 @@ void MCP2515Class::handleInterrupt() return; } - while (parsePacket()) { + while (parsePacket() || _rxId != -1) { _onReceive(available()); } } From 4bb2b2fb58638c112156e66c4f9b965912a82a87 Mon Sep 17 00:00:00 2001 From: Damien Dejean Date: Sun, 20 Nov 2022 21:28:04 +0100 Subject: [PATCH 4/8] MCP2515: fix observe() method. Fixes the observe() method to set the "listen only mode" bit in the control register instead of the "configuration mode" bit. --- src/MCP2515.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/MCP2515.cpp b/src/MCP2515.cpp index 9ad96b7..a153a76 100644 --- a/src/MCP2515.cpp +++ b/src/MCP2515.cpp @@ -353,8 +353,8 @@ int MCP2515Class::filterExtended(long id, long mask) int MCP2515Class::observe() { - writeRegister(REG_CANCTRL, 0x80); - if (readRegister(REG_CANCTRL) != 0x80) { + writeRegister(REG_CANCTRL, 0x60); + if (readRegister(REG_CANCTRL) != 0x60) { return 0; } From 68f4b7fb4c5366d067a363f642d270355d813115 Mon Sep 17 00:00:00 2001 From: Timo Denk Date: Sun, 11 Dec 2022 19:37:24 +0100 Subject: [PATCH 5/8] Fix `attachInterrupt` link to Arduino docs --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 5723c97..cf4b798 100644 --- a/README.md +++ b/README.md @@ -23,7 +23,7 @@ An Arduino library for sending and receiving data using CAN bus. | INT | 2 | -`CS` and `INT` pins can be changed by using `CAN.setPins(cs, irq)`. `INT` pin is optional, it is only needed for receive callback mode. If `INT` pin is used, it **must** be interrupt capable via [`attachInterrupt(...)`](https://www.arduino.cc/en/Reference/AttachInterrupt). +`CS` and `INT` pins can be changed by using `CAN.setPins(cs, irq)`. `INT` pin is optional, it is only needed for receive callback mode. If `INT` pin is used, it **must** be interrupt capable via [`attachInterrupt(...)`](https://www.arduino.cc/reference/en/language/functions/external-interrupts/attachinterrupt/). **NOTE**: Logic level converters must be used for boards which operate at 3.3V. From a1cd3017c840942a7a4eeed0e44460e5df796e65 Mon Sep 17 00:00:00 2001 From: kouuta Date: Wed, 8 Mar 2023 23:32:51 +0900 Subject: [PATCH 6/8] Fix extended ID filter mistake --- src/ESP32SJA1000.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/ESP32SJA1000.cpp b/src/ESP32SJA1000.cpp index 3c56fba..309e030 100644 --- a/src/ESP32SJA1000.cpp +++ b/src/ESP32SJA1000.cpp @@ -304,12 +304,12 @@ int ESP32SJA1000Class::filterExtended(long id, long mask) writeRegister(REG_ACRn(0), id >> 21); writeRegister(REG_ACRn(1), id >> 13); writeRegister(REG_ACRn(2), id >> 5); - writeRegister(REG_ACRn(3), id << 5); + writeRegister(REG_ACRn(3), id << 3); writeRegister(REG_AMRn(0), mask >> 21); writeRegister(REG_AMRn(1), mask >> 13); writeRegister(REG_AMRn(2), mask >> 5); - writeRegister(REG_AMRn(3), (mask << 5) | 0x1f); + writeRegister(REG_AMRn(3), (mask << 3) | 0x1f); modifyRegister(REG_MOD, 0x17, 0x00); // normal From b514e6b8596126a8f94f226b9906455393efd3a2 Mon Sep 17 00:00:00 2001 From: jonmon6691 Date: Thu, 28 Mar 2024 13:34:15 -0700 Subject: [PATCH 7/8] Add bit timing configurations for 667 kbaud CAN buses Register definitions maintain the library conventions for sampling modes and other bitfields in the CNF registers according to clock speed. --- src/MCP2515.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/MCP2515.cpp b/src/MCP2515.cpp index a153a76..36c160d 100644 --- a/src/MCP2515.cpp +++ b/src/MCP2515.cpp @@ -91,6 +91,7 @@ int MCP2515Class::begin(long baudRate) uint8_t cnf[3]; } CNF_MAPPER[] = { { (long)8E6, (long)1000E3, { 0x00, 0x80, 0x00 } }, + { (long)8E6, (long)666666, { 0xC0, 0xB8, 0x01 } }, { (long)8E6, (long)500E3, { 0x00, 0x90, 0x02 } }, { (long)8E6, (long)250E3, { 0x00, 0xb1, 0x05 } }, { (long)8E6, (long)200E3, { 0x00, 0xb4, 0x06 } }, @@ -104,6 +105,7 @@ int MCP2515Class::begin(long baudRate) { (long)8E6, (long)5E3, { 0x1f, 0xbf, 0x07 } }, { (long)16E6, (long)1000E3, { 0x00, 0xd0, 0x82 } }, + { (long)16E6, (long)666666, { 0xC0, 0xF8, 0x81 } }, { (long)16E6, (long)500E3, { 0x00, 0xf0, 0x86 } }, { (long)16E6, (long)250E3, { 0x41, 0xf1, 0x85 } }, { (long)16E6, (long)200E3, { 0x01, 0xfa, 0x87 } }, From a26765798782020586997e20389a2a12a63b76b9 Mon Sep 17 00:00:00 2001 From: Tiny_Spider Date: Tue, 3 Dec 2024 14:40:22 +0100 Subject: [PATCH 8/8] Add adafruit feather support --- src/MCP2515.h | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/MCP2515.h b/src/MCP2515.h index 40a1334..7254b54 100644 --- a/src/MCP2515.h +++ b/src/MCP2515.h @@ -12,7 +12,13 @@ #define MCP2515_DEFAULT_CLOCK_FREQUENCY 16e6 -#if defined(ARDUINO_ARCH_SAMD) && defined(PIN_SPI_MISO) && defined(PIN_SPI_MOSI) && defined(PIN_SPI_SCK) && (PIN_SPI_MISO == 10) && (PIN_SPI_MOSI == 8) && (PIN_SPI_SCK == 9) +#if defined(ARDUINO_ADAFRUIT_FEATHER_RP2040) +#define MCP2515_DEFAULT_CS_PIN 7 +#define MCP2515_DEFAULT_INT_PIN 8 +#elif defined(ARDUINO_ADAFRUIT_FEATHER_RP2040_CAN) +#define MCP2515_DEFAULT_CS_PIN PIN_CAN_CS +#define MCP2515_DEFAULT_INT_PIN PIN_CAN_INTERRUPT +#elif defined(ARDUINO_ARCH_SAMD) && defined(PIN_SPI_MISO) && defined(PIN_SPI_MOSI) && defined(PIN_SPI_SCK) && (PIN_SPI_MISO == 10) && (PIN_SPI_MOSI == 8) && (PIN_SPI_SCK == 9) // Arduino MKR board: MKR CAN shield CS is pin 3, INT is pin 7 #define MCP2515_DEFAULT_CS_PIN 3 #define MCP2515_DEFAULT_INT_PIN 7