summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Matthew Wozniak <me@woz.blue> 2025-12-12 00:10:31 -0500
committerGravatar Matthew Wozniak <me@woz.blue> 2025-12-12 00:12:15 -0500
commit36d5f004515bebaf9d22785aa947a8f0904aa78b (patch)
treec9e4d3f4dd2299503b0e84e1b2ea7f049567f53c
parenta23a659972f0975eabb3462b9de314c563893a04 (diff)
downloadstm32_can_demo-master.tar.gz
stm32_can_demo-master.zip
80 col/avoid reprocessing modulusHEADmaster
should just be a bitmap anyway but it's a bit more legible anyway which is good
-rw-r--r--main.c5
1 files 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;
}