Modified put the receive interrupt before begin

This commit is contained in:
wangcoolc
2020-12-10 17:10:14 +08:00
committed by Baozhu Zuo
parent 3c78368258
commit bfc70f2099
4 changed files with 7 additions and 12 deletions
@@ -42,6 +42,7 @@ void setup() {
while (!SERIAL) {
; // wait for serial port to connect. Needed for native USB port only
}
attachInterrupt(digitalPinToInterrupt(CAN_INT_PIN), MCP2515_ISR, FALLING); // start interrupt
#ifdef CAN_2518FD
while (0 != CAN.begin((byte)CAN_500K_1M)) { // init can bus : baudrate = 500k
#else
@@ -52,8 +53,8 @@ void setup() {
delay(100);
}
SERIAL.println("CAN BUS Shield init ok!");
pinMode(CAN_INT_PIN, INPUT);
attachInterrupt(digitalPinToInterrupt(CAN_INT_PIN), MCP2515_ISR, FALLING); // start interrupt
delay(100);
}
void MCP2515_ISR() {
@@ -33,6 +33,7 @@ void setup() {
while (!SERIAL) {
; // 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);
while (0 != CAN.begin((byte)CAN_500K_1M)) { // init can bus : baudrate = 500k
SERIAL.println("CAN BUS Shield init fail");
@@ -43,8 +44,6 @@ void setup() {
SERIAL.printf("CAN BUS get mode = %d\n\r",mode);
SERIAL.println("CAN BUS Shield init ok!");
SERIAL.println("CAN BUS Shield init ok!");
pinMode(CAN_INT_PIN, INPUT);
attachInterrupt(digitalPinToInterrupt(CAN_INT_PIN), MCP2515_ISR, FALLING); // start interrupt
}
void MCP2515_ISR() {
+2 -4
View File
@@ -42,7 +42,7 @@ char str[20];
void setup() {
SERIAL.begin(115200);
attachInterrupt(digitalPinToInterrupt(CAN_INT_PIN), MCP2515_ISR, FALLING); // start interrupt
#ifdef CAN_2518FD
while (0 != CAN.begin((byte)CAN_500K_1M)) { // init can bus : baudrate = 500k
#else
@@ -53,9 +53,7 @@ void setup() {
delay(100);
}
SERIAL.println("CAN BUS Shield init ok!");
attachInterrupt(0, MCP2515_ISR, FALLING); // start interrupt
if (!SD.begin(4)) {
SERIAL.println("SD initialization failed!");
while (1);
@@ -38,7 +38,7 @@ char str[20];
void setup() {
SERIAL.begin(115200);
while(!Serial){};
attachInterrupt(digitalPinToInterrupt(interruptPin), MCP2515_ISR, FALLING); // start interrupt
#ifdef CAN_2518FD
while (0 != CAN.begin((byte)CAN_500K_1M)) { // init can bus : baudrate = 500k
#else
@@ -50,9 +50,6 @@ void setup() {
}
SERIAL.println("CAN BUS Shield init ok!");
attachInterrupt(digitalPinToInterrupt(interruptPin), MCP2515_ISR, FALLING); // start interrupt
/*
set mask, set both the mask to 0x3ff
*/