From 94865f71a583239e48ff107ea2dadd316b5446e9 Mon Sep 17 00:00:00 2001 From: Alexander Entinger Date: Mon, 12 Sep 2022 12:45:55 +0200 Subject: [PATCH] Fix: Clear RX int flag before calling user-callback. This has the added benefit of allowing the next CAN frame to be received WHILE the current one is processed in the user-callback (in case that processing takes very long, which is not advisable). --- src/ArduinoMCP2515.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/ArduinoMCP2515.cpp b/src/ArduinoMCP2515.cpp index 8ede2f7..f21896c 100644 --- a/src/ArduinoMCP2515.cpp +++ b/src/ArduinoMCP2515.cpp @@ -165,8 +165,8 @@ void ArduinoMCP2515::onReceiveBuffer_0_Full() unsigned long const rx_timestamp_us = _micros(); _ctrl.receive(RxB::RxB0, id, data, len); - onReceiveBuffer_n_Full(rx_timestamp_us, id, data, len); _ctrl.clearIntFlag(CANINTF::RX0IF); + onReceiveBuffer_n_Full(rx_timestamp_us, id, data, len); } void ArduinoMCP2515::onReceiveBuffer_1_Full() @@ -176,8 +176,8 @@ void ArduinoMCP2515::onReceiveBuffer_1_Full() unsigned long const rx_timestamp_us = _micros(); _ctrl.receive(RxB::RxB1, id, data, len); - onReceiveBuffer_n_Full(rx_timestamp_us, id, data, len); _ctrl.clearIntFlag(CANINTF::RX1IF); + onReceiveBuffer_n_Full(rx_timestamp_us, id, data, len); } void ArduinoMCP2515::onTransmitBuffer_0_Empty()