Skip to content

Commit

Permalink
fix(can): Wait for a free slot in the TX message fifo before trying s…
Browse files Browse the repository at this point in the history
…ending. (#243)

* Wait for a free slot in the TX message fifo before trying sending.

* minimal delay while waiting for fifo space.

* vTaskDelay
  • Loading branch information
amitlissack authored Feb 14, 2022
1 parent 5a5fe56 commit 9710206
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions can/firmware/hal_can.c
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,12 @@ void can_send_message(HAL_CAN_HANDLE handle, uint32_t arbitration_id, uint8_t* b
.TxEventFifoControl = FDCAN_NO_TX_EVENTS,
.MessageMarker=0
};

// Wait for there to be room.
while (HAL_FDCAN_GetTxFifoFreeLevel(handle) == 0) {
vTaskDelay(1);
}

HAL_FDCAN_AddMessageToTxFifoQ(handle, &tx_header, buffer);
}

Expand Down

0 comments on commit 9710206

Please sign in to comment.