diff options
| -rw-r--r-- | main.c | 5 |
1 files changed, 3 insertions, 2 deletions
@@ -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; } |
