can_write(): return error code when no tx mailboxes are available.

pull/3930/head
Simon Vogl 2017-02-23 09:26:45 +01:00 committed by Anna Bridge
parent c76d8ffdfc
commit c0351446cf
1 changed files with 23 additions and 25 deletions

View File

@ -207,7 +207,7 @@ int can_frequency(can_t *obj, int f)
int can_write(can_t *obj, CAN_Message msg, int cc)
{
uint32_t transmitmailbox = 5;
uint32_t transmitmailbox = CAN_TXSTATUS_NOMAILBOX;
CAN_TypeDef *can = (CAN_TypeDef *)(obj->can);
/* Select one empty transmit mailbox */
@ -218,10 +218,9 @@ int can_write(can_t *obj, CAN_Message msg, int cc)
} else if ((can->TSR & CAN_TSR_TME2) == CAN_TSR_TME2) {
transmitmailbox = 2;
} else {
transmitmailbox = CAN_TXSTATUS_NOMAILBOX;
return 0;
}
if (transmitmailbox != CAN_TXSTATUS_NOMAILBOX) {
can->sTxMailBox[transmitmailbox].TIR &= CAN_TI0R_TXRQ;
if (!(msg.format)) {
can->sTxMailBox[transmitmailbox].TIR |= ((msg.id << 21) | msg.type);
@ -244,7 +243,6 @@ int can_write(can_t *obj, CAN_Message msg, int cc)
((uint32_t)msg.data[4]));
/* Request transmission */
can->sTxMailBox[transmitmailbox].TIR |= CAN_TI0R_TXRQ;
}
return 1;
}