From 36d5f004515bebaf9d22785aa947a8f0904aa78b Mon Sep 17 00:00:00 2001 From: Matthew Wozniak Date: Fri, 12 Dec 2025 00:10:31 -0500 Subject: 80 col/avoid reprocessing modulus should just be a bitmap anyway but it's a bit more legible anyway which is good --- main.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/main.c b/main.c index 462c2a8..fba678a 100644 --- a/main.c +++ b/main.c @@ -46,12 +46,13 @@ bool can_recv(CAN_FIFOMailBox_TypeDef *frame) { // This will get called when we get a new frame in FIFO1 void canrx1_handler() { // if the queue is full just drop the frame - if ((can_frame_queue.back + 1) % CAN_FRAME_QUEUE_DEPTH == can_frame_queue.front) { + int next_back = (can_frame_queue.back + 1) % CAN_FRAME_QUEUE_DEPTH; + if (next_back == can_frame_queue.front) { CAN1->RF1R |= CAN_RF1R_RFOM1; return; } can_frame_queue.data[can_frame_queue.back] = CAN1->sFIFOMailBox[1]; - can_frame_queue.back = (can_frame_queue.back + 1) % CAN_FRAME_QUEUE_DEPTH; + can_frame_queue.back = next_back; // tell the FIFO we are done with this frame CAN1->RF1R |= CAN_RF1R_RFOM1; } -- cgit v1.2.3-54-g00ecf