From 92597cb97dbd8766b1dca49b7c5e8837b5bae2c8 Mon Sep 17 00:00:00 2001 From: turmary Date: Mon, 18 Jan 2021 17:28:59 +0800 Subject: [PATCH] Fix from: example receive_interruptFD compiling fail --- .../receive_interruptFD.ino | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/examples/receive_interruptFD/receive_interruptFD.ino b/examples/receive_interruptFD/receive_interruptFD.ino index 85b036c..0fec972 100644 --- a/examples/receive_interruptFD/receive_interruptFD.ino +++ b/examples/receive_interruptFD/receive_interruptFD.ino @@ -7,10 +7,23 @@ #define CAN_2518FD +// Set SPI CS Pin according to your hardware + +#if defined(SEEED_WIO_TERMINAL) && defined(CAN_2518FD) +// For Wio Terminal w/ MCP2518FD RPi Hat: +// Channel 0 SPI_CS Pin: BCM 8 +// Channel 1 SPI_CS Pin: BCM 7 +// Interupt Pin: BCM25 +const int SPI_CS_PIN = BCM8; +const int CAN_INT_PIN = BCM25; +#else + +// For Arduino MCP2515 Hat: // 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; const int CAN_INT_PIN = 2; +#endif #ifdef CAN_2518FD mcp2518fd CAN(SPI_CS_PIN); // Set CS pin @@ -19,15 +32,14 @@ mcp2518fd CAN(SPI_CS_PIN); // Set CS pin unsigned char flagRecv = 0; unsigned char len = 0; unsigned char buf[64]; -char str[20]; void setup() { SERIAL_PORT_MONITOR.begin(115200); - while (!SERIAL_PORT_MONITOR. { + while (!SERIAL_PORT_MONITOR) { ; // wait for serial port to connect. Needed for native USB port only } attachInterrupt(digitalPinToInterrupt(CAN_INT_PIN), MCP2515_ISR, FALLING); // start interrupt - CAN.setMode(0); + CAN.setMode(CAN_NORMAL_MODE); while (0 != CAN.begin((byte)CAN_500K_1M)) { // init can bus : baudrate = 500k SERIAL_PORT_MONITOR.println("CAN init fail, retry..."); delay(100);