stm32: use TME bits to find the canbus tx mailbox

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
This commit is contained in:
Eric Callahan 2022-06-03 06:09:53 -04:00 committed by KevinOConnor
parent 3c7eea7336
commit 39535b15ba
1 changed files with 5 additions and 1 deletions

View File

@ -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 */