mirror of
https://github.com/Seeed-Studio/Seeed_Arduino_CAN.git
synced 2026-07-28 04:06:45 +00:00
add samd compatibility
This commit is contained in:
+11
-4
@@ -4,6 +4,13 @@
|
||||
#include <mcp_can.h>
|
||||
#include <SPI.h>
|
||||
|
||||
/*SAMD core*/
|
||||
#ifdef ARDUINO_SAMD_VARIANT_COMPLIANCE
|
||||
#define SERIAL SerialUSB
|
||||
#else
|
||||
#define SERIAL Serial
|
||||
#endif
|
||||
|
||||
// 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;
|
||||
@@ -12,15 +19,15 @@ MCP_CAN CAN(SPI_CS_PIN); // Set CS pin
|
||||
|
||||
void setup()
|
||||
{
|
||||
Serial.begin(115200);
|
||||
SERIAL.begin(115200);
|
||||
|
||||
while (CAN_OK != CAN.begin(CAN_500KBPS)) // init can bus : baudrate = 500k
|
||||
{
|
||||
Serial.println("CAN BUS Shield init fail");
|
||||
Serial.println(" Init CAN BUS Shield again");
|
||||
SERIAL.println("CAN BUS Shield init fail");
|
||||
SERIAL.println(" Init CAN BUS Shield again");
|
||||
delay(100);
|
||||
}
|
||||
Serial.println("CAN BUS Shield init ok!");
|
||||
SERIAL.println("CAN BUS Shield init ok!");
|
||||
}
|
||||
|
||||
unsigned char stmp[8] = {0, 0, 0, 0, 0, 0, 0, 0};
|
||||
|
||||
Reference in New Issue
Block a user