Examples/Crusher/Linux/stm32/firmware/lib/src/peripherals/stm32f4xx_can.c
/**
  * @brief  Checks the transmission status of a CAN Frame.
  * @param  CANx: where x can be 1 or 2 to select the CAN peripheral.
  * @param  TransmitMailbox: the number of the mailbox that is used for transmission.
  * @retval CAN_TxStatus_Ok if the CAN driver transmits the message, 
  *         CAN_TxStatus_Failed in an other case.
  */
@brief  Checks the transmission status of a CAN Frame.
@param  CANx: where x can be 1 or 2 to select the CAN peripheral.
@param  TransmitMailbox: the number of the mailbox that is used for transmission.
@retval CAN_TxStatus_Ok if the CAN driver transmits the message,
CAN_TxStatus_Failed in an other case.
@brief Checks the transmission status of a CAN Frame . @param CANx : where x can be 1 or 2 to select the CAN peripheral . @param TransmitMailbox : the number of the mailbox that is used for transmission . @retval CAN_TxStatus_Ok if the CAN driver transmits the message CAN_TxStatus_Failed in an other case .
uint8_t CAN_TransmitStatus(CAN_TypeDef* CANx, uint8_t TransmitMailbox)
{
  uint32_t state = 0;
  assert_param(IS_CAN_ALL_PERIPH(CANx));
  assert_param(IS_CAN_TRANSMITMAILBOX(TransmitMailbox));
  switch (TransmitMailbox)
  {
    case (CAN_TXMAILBOX_0): 
      state =   CANx->TSR &  (CAN_TSR_RQCP0 | CAN_TSR_TXOK0 | CAN_TSR_TME0);
      break;
    case (CAN_TXMAILBOX_1): 
      state =   CANx->TSR &  (CAN_TSR_RQCP1 | CAN_TSR_TXOK1 | CAN_TSR_TME1);
      break;
    case (CAN_TXMAILBOX_2): 
      state =   CANx->TSR &  (CAN_TSR_RQCP2 | CAN_TSR_TXOK2 | CAN_TSR_TME2);
      break;
    default:
      state = CAN_TxStatus_Failed;
      break;
  }
  switch (state)
  {
    case (0x0): state = CAN_TxStatus_Pending;
      break;
     case (CAN_TSR_RQCP0 | CAN_TSR_TME0): state = CAN_TxStatus_Failed;
      break;
     case (CAN_TSR_RQCP1 | CAN_TSR_TME1): state = CAN_TxStatus_Failed;
      break;
     case (CAN_TSR_RQCP2 | CAN_TSR_TME2): state = CAN_TxStatus_Failed;
      break;
    case (CAN_TSR_RQCP0 | CAN_TSR_TXOK0 | CAN_TSR_TME0):state = CAN_TxStatus_Ok;
      break;
    case (CAN_TSR_RQCP1 | CAN_TSR_TXOK1 | CAN_TSR_TME1):state = CAN_TxStatus_Ok;
      break;
    case (CAN_TSR_RQCP2 | CAN_TSR_TXOK2 | CAN_TSR_TME2):state = CAN_TxStatus_Ok;
      break;
    default: state = CAN_TxStatus_Failed;
      break;
  }
  return (uint8_t) state;
}
uint8_t CAN_TransmitStatus ( CAN_TypeDef * CANx , uint8_t TransmitMailbox ) { uint32_t state = 0 ; assert_param ( IS_CAN_ALL_PERIPH ( CANx ) ) ; assert_param ( IS_CAN_TRANSMITMAILBOX ( TransmitMailbox ) ) ; switch ( TransmitMailbox ) { case ( CAN_TXMAILBOX_0 ) : state = CANx -> TSR & ( CAN_TSR_RQCP0 | CAN_TSR_TXOK0 | CAN_TSR_TME0 ) ; break ; case ( CAN_TXMAILBOX_1 ) : state = CANx -> TSR & ( CAN_TSR_RQCP1 | CAN_TSR_TXOK1 | CAN_TSR_TME1 ) ; break ; case ( CAN_TXMAILBOX_2 ) : state = CANx -> TSR & ( CAN_TSR_RQCP2 | CAN_TSR_TXOK2 | CAN_TSR_TME2 ) ; break ; default : state = CAN_TxStatus_Failed ; break ; } switch ( state ) { case ( 0x0 ) : state = CAN_TxStatus_Pending ; break ; case ( CAN_TSR_RQCP0 | CAN_TSR_TME0 ) : state = CAN_TxStatus_Failed ; break ; case ( CAN_TSR_RQCP1 | CAN_TSR_TME1 ) : state = CAN_TxStatus_Failed ; break ; case ( CAN_TSR_RQCP2 | CAN_TSR_TME2 ) : state = CAN_TxStatus_Failed ; break ; case ( CAN_TSR_RQCP0 | CAN_TSR_TXOK0 | CAN_TSR_TME0 ) : state = CAN_TxStatus_Ok ; break ; case ( CAN_TSR_RQCP1 | CAN_TSR_TXOK1 | CAN_TSR_TME1 ) : state = CAN_TxStatus_Ok ; break ; case ( CAN_TSR_RQCP2 | CAN_TSR_TXOK2 | CAN_TSR_TME2 ) : state = CAN_TxStatus_Ok ; break ; default : state = CAN_TxStatus_Failed ; break ; } return ( uint8_t ) state ; }
@brief  Checks the transmission status of a CAN Frame.
@brief Checks the transmission status of a CAN Frame .
/* Check the parameters */ /* transmit pending  */ /* transmit failed  */ /* transmit succeeded  */