File tree Expand file tree Collapse file tree 1 file changed +22
-4
lines changed
Expand file tree Collapse file tree 1 file changed +22
-4
lines changed Original file line number Diff line number Diff line change 11// demo: CAN-BUS Shield, send data
2- #include < mcp_can.h>
32#include < SPI.h>
43
54/* SAMD core*/
98 #define SERIAL Serial
109#endif
1110
11+ // #define CAN_2515
12+ #define CAN_2518FD
1213// the cs pin of the version after v1.1 is default to D9
1314// v0.9b and v1.0 is default D10
15+
16+ #ifdef CAN_2518FD
17+ #include " mcp2518fd_can.h"
18+ const int SPI_CS_PIN = BCM8;
19+ const int CAN_INT_PIN = BCM25;
20+ mcp2518fd CAN (SPI_CS_PIN); // Set CS pin
21+ #endif
22+
23+ #ifdef CAN_2515
24+ #include " mcp2515_can.h"
1425const int SPI_CS_PIN = 9 ;
26+ const int CAN_INT_PIN = 2 ;
27+ mcp2515_can CAN (SPI_CS_PIN); // Set CS pin
28+ #endif // Set CS pin
29+
1530const int ledHIGH = 1 ;
1631const int ledLOW = 0 ;
17-
18- MCP_CAN CAN (SPI_CS_PIN); // Set CS pin
32+
1933
2034void setup () {
2135 SERIAL.begin (115200 );
2236
23- while (CAN_OK != CAN.begin (CAN_500KBPS)) { // init can bus : baudrate = 500k
37+ #ifdef CAN_2518FD
38+ while (0 != CAN.begin ((byte)CAN_500K_1M)) { // init can bus : baudrate = 500k
39+ #else
40+ while (CAN_OK != CAN.begin (CAN_500KBPS)) { // init can bus : baudrate = 500k
41+ #endif
2442 SERIAL.println (" CAN BUS Shield init fail" );
2543 SERIAL.println (" Init CAN BUS Shield again" );
2644 delay (100 );
You can’t perform that action at this time.
0 commit comments