mirror of
https://github.com/Seeed-Studio/Seeed_Arduino_CAN.git
synced 2026-07-28 04:06:45 +00:00
Move: SERIAL to SERIAL_PORT_MONITOR in examples
This commit is contained in:
@@ -21,13 +21,6 @@
|
||||
|
||||
#define SPI_CS_PIN 9
|
||||
|
||||
/*SAMD core*/
|
||||
#ifdef ARDUINO_SAMD_VARIANT_COMPLIANCE
|
||||
#define SERIAL SerialUSB
|
||||
#else
|
||||
#define SERIAL Serial
|
||||
#endif
|
||||
|
||||
#ifdef CAN_2518FD
|
||||
mcp2518fd CAN(SPI_CS_PIN); // Set CS pin
|
||||
#endif
|
||||
@@ -37,7 +30,7 @@ mcp2515_can CAN(SPI_CS_PIN); // Set CS pin
|
||||
#endif
|
||||
|
||||
void setup() {
|
||||
SERIAL.begin(115200);
|
||||
SERIAL_PORT_MONITOR.begin(115200);
|
||||
#ifdef CAN_2518FD
|
||||
while (0 != CAN.begin((byte)CAN_500K_1M)) { // init can bus : baudrate = 500k
|
||||
#endif
|
||||
@@ -45,27 +38,27 @@ void setup() {
|
||||
while (CAN_OK != CAN.begin(CAN_500KBPS)) {
|
||||
#endif
|
||||
|
||||
SERIAL.println("CAN init failed, retry");
|
||||
SERIAL_PORT_MONITOR.println("CAN init failed, retry");
|
||||
delay(100);
|
||||
}
|
||||
SERIAL.println("CAN init ok");
|
||||
SERIAL_PORT_MONITOR.println("CAN init ok");
|
||||
#ifdef CAN_2518FD
|
||||
if (CAN.mcpPinMode(GPIO_PIN_0, GPIO_MODE_INT)) {
|
||||
#else
|
||||
if (CAN.mcpPinMode(MCP_TX2RTS, MCP_PIN_IN)) {
|
||||
#endif
|
||||
SERIAL.println("TX2RTS is now an input");
|
||||
SERIAL_PORT_MONITOR.println("TX2RTS is now an input");
|
||||
} else {
|
||||
SERIAL.println("Could not switch TX2RTS");
|
||||
SERIAL_PORT_MONITOR.println("Could not switch TX2RTS");
|
||||
}
|
||||
}
|
||||
|
||||
void loop() {
|
||||
SERIAL.print("TX2RTS is currently ");
|
||||
SERIAL_PORT_MONITOR.print("TX2RTS is currently ");
|
||||
#ifdef CAN_2518FD
|
||||
SERIAL.println(CAN.mcpDigitalRead(GPIO_PIN_0));
|
||||
SERIAL_PORT_MONITOR.println(CAN.mcpDigitalRead(GPIO_PIN_0));
|
||||
#else
|
||||
SERIAL.println(CAN.mcpDigitalRead(MCP_TX2RTS));
|
||||
SERIAL_PORT_MONITOR.println(CAN.mcpDigitalRead(MCP_TX2RTS));
|
||||
#endif
|
||||
delay(500);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user