stm32: Use CAN_TSR_CODE to select next tx fifo in can.c

The spec states that the TX fifo is transmitted in chronological order
if the TXFP bit is set, but it's unclear if the software needs to fill
the tx fifo in a particular order to obtain that result.  Use the TSR
CODE bit field to fill the TX fifo in the order that the hardware
reports as next.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
This commit is contained in:
Kevin O'Connor 2021-01-27 21:58:04 -05:00
parent 95eb00740b
commit 95adff7431
1 changed files with 2 additions and 6 deletions

View File

@ -91,12 +91,8 @@ static int
can_find_empty_tx_mbox(void) can_find_empty_tx_mbox(void)
{ {
uint32_t tsr = SOC_CAN->TSR; uint32_t tsr = SOC_CAN->TSR;
if (tsr & CAN_TSR_TME0) if (tsr & (CAN_TSR_TME0|CAN_TSR_TME1|CAN_TSR_TME2))
return 0; return (tsr & CAN_TSR_CODE) >> CAN_TSR_CODE_Pos;
if (tsr & CAN_TSR_TME1)
return 1;
if (tsr & CAN_TSR_TME2)
return 2;
return -1; return -1;
} }