From 39535b15ba2492608a4d1b2854df4faee920da53 Mon Sep 17 00:00:00 2001 From: Eric Callahan Date: Fri, 3 Jun 2022 06:09:53 -0400 Subject: [PATCH] stm32: use TME bits to find the canbus tx mailbox Signed-off-by: Eric Callahan --- src/stm32/can.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/stm32/can.c b/src/stm32/can.c index ff88edb9..a82ad688 100644 --- a/src/stm32/can.c +++ b/src/stm32/can.c @@ -135,7 +135,11 @@ canbus_send(uint32_t id, uint32_t len, uint8_t *data) irq_enable(); return -1; } - int mbox = (tsr & CAN_TSR_CODE) >> CAN_TSR_CODE_Pos; + int mbox = 2; + if (tsr & CAN_TSR_TME0) + mbox = 0; + else if (tsr & CAN_TSR_TME1) + mbox = 1; CAN_TxMailBox_TypeDef *mb = &SOC_CAN->sTxMailBox[mbox]; /* Set up the DLC */