diff --git a/src/CAN.h b/src/CAN.h index d8edc06..efa5c88 100644 --- a/src/CAN.h +++ b/src/CAN.h @@ -4,10 +4,14 @@ #ifndef CAN_H #define CAN_H + #ifdef ARDUINO_ARCH_ESP32 -#include "ESP32SJA1000.h" -#else -#include "MCP2515.h" +//#include "ESP32SJA1000.h" +#ifndef ESP32_EXTERNAL_CAN +//#define IGNORE_MCP2515 +#endif #endif +#include "MCP2515.h" + #endif diff --git a/src/MCP2515.cpp b/src/MCP2515.cpp index 1d451ba..4529453 100644 --- a/src/MCP2515.cpp +++ b/src/MCP2515.cpp @@ -1,7 +1,7 @@ // Copyright (c) Sandeep Mistry. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -#ifndef ARDUINO_ARCH_ESP32 +#ifndef IGNORE_MCP2515 #include "MCP2515.h" @@ -328,6 +328,7 @@ int MCP2515Class::parsePacket() return _rxDlc; } + void MCP2515Class::onReceive(void(*callback)(int)) { CANControllerClass::onReceive(callback); @@ -335,8 +336,8 @@ void MCP2515Class::onReceive(void(*callback)(int)) pinMode(_intPin, INPUT); if (callback) { - SPI.usingInterrupt(digitalPinToInterrupt(_intPin)); - attachInterrupt(digitalPinToInterrupt(_intPin), MCP2515Class::onInterrupt, LOW); + //SPI.usingInterrupt(digitalPinToInterrupt(_intPin)); + //attachInterrupt(digitalPinToInterrupt(_intPin), MCP2515Class::onInterrupt, LOW); } else { detachInterrupt(digitalPinToInterrupt(_intPin)); #ifdef SPI_HAS_NOTUSINGINTERRUPT @@ -345,6 +346,7 @@ void MCP2515Class::onReceive(void(*callback)(int)) } } + int MCP2515Class::filter(int id, int mask) { id &= 0x7ff; @@ -705,11 +707,5 @@ void MCP2515Class::writeRegister(uint8_t address, uint8_t value) SPI.endTransaction(); } -void MCP2515Class::onInterrupt() -{ - CAN.handleInterrupt(); -} - -MCP2515Class CAN; #endif diff --git a/src/MCP2515.h b/src/MCP2515.h index 40a1334..a7fb64b 100644 --- a/src/MCP2515.h +++ b/src/MCP2515.h @@ -1,7 +1,7 @@ // Copyright (c) Sandeep Mistry. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -#ifndef ARDUINO_ARCH_ESP32 +//#ifndef IGNORE_MCP2515 #ifndef MCP2515_H #define MCP2515_H @@ -81,8 +81,6 @@ class MCP2515Class : public CANControllerClass { void modifyRegister(uint8_t address, uint8_t mask, uint8_t value); void writeRegister(uint8_t address, uint8_t value); - static void onInterrupt(); - private: SPISettings _spiSettings; int _csPin; @@ -90,8 +88,7 @@ class MCP2515Class : public CANControllerClass { long _clockFrequency; }; -extern MCP2515Class CAN; #endif -#endif +//#endif