From c72a842c316871cc0ec938afa5a3776405fb7452 Mon Sep 17 00:00:00 2001 From: wangcoolc <1387172050@163.com> Date: Wed, 9 Dec 2020 15:51:00 +0800 Subject: [PATCH] Modified canbus send and receive example --- examples/receive_interrupt/receive_interrupt.ino | 15 +++++++++------ examples/send/send.ino | 13 ++++++++++--- 2 files changed, 19 insertions(+), 9 deletions(-) diff --git a/examples/receive_interrupt/receive_interrupt.ino b/examples/receive_interrupt/receive_interrupt.ino index 0fc44d7..394d9e4 100644 --- a/examples/receive_interrupt/receive_interrupt.ino +++ b/examples/receive_interrupt/receive_interrupt.ino @@ -3,8 +3,6 @@ // loovee, 2014-6-13 #include -#include "mcp2515_can.h" -#include "mcp2518fd_can.h" /*SAMD core*/ #ifdef ARDUINO_SAMD_VARIANT_COMPLIANCE @@ -13,18 +11,23 @@ #define SERIAL Serial #endif -#define CAN_2518FD - +#define CAN_2515 +//#define CAN_2518FD // the cs pin of the version after v1.1 is default to D9 // v0.9b and v1.0 is default D10 -const int SPI_CS_PIN = BCM8; -const int CAN_INT_PIN = BCM25; + #ifdef CAN_2518FD +#include "mcp2518fd_can.h" +const int SPI_CS_PIN = BCM8; +const int CAN_INT_PIN = BCM25; mcp2518fd CAN(SPI_CS_PIN); // Set CS pin #endif #ifdef CAN_2515 +#include "mcp2515_can.h" +const int SPI_CS_PIN = 9; +const int CAN_INT_PIN = 2; mcp2515_can CAN(SPI_CS_PIN); // Set CS pin #endif // Set CS pin diff --git a/examples/send/send.ino b/examples/send/send.ino index b7e6f94..8fe2f25 100644 --- a/examples/send/send.ino +++ b/examples/send/send.ino @@ -14,18 +14,25 @@ #endif -#define CAN_2515 +//#define CAN_2515 +#define CAN_2518FD // the cs pin of the version after v1.1 is default to D9 // v0.9b and v1.0 is default D10 -const int SPI_CS_PIN = 9; + #ifdef CAN_2518FD +#include "mcp2518fd_can.h" +const int SPI_CS_PIN = BCM8; +const int CAN_INT_PIN = BCM25; mcp2518fd CAN(SPI_CS_PIN); // Set CS pin #endif #ifdef CAN_2515 +#include "mcp2515_can.h" +const int SPI_CS_PIN = 9; +const int CAN_INT_PIN = 2; mcp2515_can CAN(SPI_CS_PIN); // Set CS pin -#endif +#endif // Set CS pin void setup() { SERIAL.begin(115200);