libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F103RB/stm32f10x_can.c
/**
  * @brief  Receives a message.
  * @param  CANx:       where x can be 1 or 2 to to select the CAN peripheral.
  * @param  FIFONumber: Receive FIFO number, CAN_FIFO0 or CAN_FIFO1.
  * @param  RxMessage:  pointer to a structure receive message which contains 
  *                     CAN Id, CAN DLC, CAN datas and FMI number.
  * @retval None.
  */
@brief  Receives a message.
@param  CANx:       where x can be 1 or 2 to to select the CAN peripheral.
@brief Receives a message . @param CANx : where x can be 1 or 2 to to select the CAN peripheral .
void CAN_Receive(CAN_TypeDef* CANx, uint8_t FIFONumber, CanRxMsg* RxMessage)
{
  assert_param(IS_CAN_ALL_PERIPH(CANx));
  assert_param(IS_CAN_FIFO(FIFONumber));
  RxMessage->IDE = (uint8_t)0x04 & CANx->sFIFOMailBox[FIFONumber].RIR;
  if (RxMessage->IDE == CAN_Id_Standard)
  {
    RxMessage->StdId = (uint32_t)0x000007FF & (CANx->sFIFOMailBox[FIFONumber].RIR >> 21);
  }
  else
  {
    RxMessage->ExtId = (uint32_t)0x1FFFFFFF & (CANx->sFIFOMailBox[FIFONumber].RIR >> 3);
  }
  RxMessage->RTR = (uint8_t)0x02 & CANx->sFIFOMailBox[FIFONumber].RIR;
  RxMessage->DLC = (uint8_t)0x0F & CANx->sFIFOMailBox[FIFONumber].RDTR;
  RxMessage->FMI = (uint8_t)0xFF & (CANx->sFIFOMailBox[FIFONumber].RDTR >> 8);
  RxMessage->Data[0] = (uint8_t)0xFF & CANx->sFIFOMailBox[FIFONumber].RDLR;
  RxMessage->Data[1] = (uint8_t)0xFF & (CANx->sFIFOMailBox[FIFONumber].RDLR >> 8);
  RxMessage->Data[2] = (uint8_t)0xFF & (CANx->sFIFOMailBox[FIFONumber].RDLR >> 16);
  RxMessage->Data[3] = (uint8_t)0xFF & (CANx->sFIFOMailBox[FIFONumber].RDLR >> 24);
  RxMessage->Data[4] = (uint8_t)0xFF & CANx->sFIFOMailBox[FIFONumber].RDHR;
  RxMessage->Data[5] = (uint8_t)0xFF & (CANx->sFIFOMailBox[FIFONumber].RDHR >> 8);
  RxMessage->Data[6] = (uint8_t)0xFF & (CANx->sFIFOMailBox[FIFONumber].RDHR >> 16);
  RxMessage->Data[7] = (uint8_t)0xFF & (CANx->sFIFOMailBox[FIFONumber].RDHR >> 24);
  if (FIFONumber == CAN_FIFO0)
  {
    CANx->RF0R |= CAN_RF0R_RFOM0;
  }
  else 
  {
    CANx->RF1R |= CAN_RF1R_RFOM1;
  }
}
void CAN_Receive ( CAN_TypeDef * CANx , uint8_t FIFONumber , CanRxMsg * RxMessage ) { assert_param ( IS_CAN_ALL_PERIPH ( CANx ) ) ; assert_param ( IS_CAN_FIFO ( FIFONumber ) ) ; RxMessage -> IDE = ( uint8_t ) 0x04 & CANx -> sFIFOMailBox [ FIFONumber ] . RIR ; if ( RxMessage -> IDE == CAN_Id_Standard ) { RxMessage -> StdId = ( uint32_t ) 0x000007FF & ( CANx -> sFIFOMailBox [ FIFONumber ] . RIR >> 21 ) ; } else { RxMessage -> ExtId = ( uint32_t ) 0x1FFFFFFF & ( CANx -> sFIFOMailBox [ FIFONumber ] . RIR >> 3 ) ; } RxMessage -> RTR = ( uint8_t ) 0x02 & CANx -> sFIFOMailBox [ FIFONumber ] . RIR ; RxMessage -> DLC = ( uint8_t ) 0x0F & CANx -> sFIFOMailBox [ FIFONumber ] . RDTR ; RxMessage -> FMI = ( uint8_t ) 0xFF & ( CANx -> sFIFOMailBox [ FIFONumber ] . RDTR >> 8 ) ; RxMessage -> Data [ 0 ] = ( uint8_t ) 0xFF & CANx -> sFIFOMailBox [ FIFONumber ] . RDLR ; RxMessage -> Data [ 1 ] = ( uint8_t ) 0xFF & ( CANx -> sFIFOMailBox [ FIFONumber ] . RDLR >> 8 ) ; RxMessage -> Data [ 2 ] = ( uint8_t ) 0xFF & ( CANx -> sFIFOMailBox [ FIFONumber ] . RDLR >> 16 ) ; RxMessage -> Data [ 3 ] = ( uint8_t ) 0xFF & ( CANx -> sFIFOMailBox [ FIFONumber ] . RDLR >> 24 ) ; RxMessage -> Data [ 4 ] = ( uint8_t ) 0xFF & CANx -> sFIFOMailBox [ FIFONumber ] . RDHR ; RxMessage -> Data [ 5 ] = ( uint8_t ) 0xFF & ( CANx -> sFIFOMailBox [ FIFONumber ] . RDHR >> 8 ) ; RxMessage -> Data [ 6 ] = ( uint8_t ) 0xFF & ( CANx -> sFIFOMailBox [ FIFONumber ] . RDHR >> 16 ) ; RxMessage -> Data [ 7 ] = ( uint8_t ) 0xFF & ( CANx -> sFIFOMailBox [ FIFONumber ] . RDHR >> 24 ) ; if ( FIFONumber == CAN_FIFO0 ) { CANx -> RF0R |= CAN_RF0R_RFOM0 ; } else { CANx -> RF1R |= CAN_RF1R_RFOM1 ; } }
@brief  Receives a message.
@brief Receives a message .
/* Check the parameters */ /* Get the Id */ /* Get the DLC */ /* Get the FMI */ /* Get the data field */ /* Release the FIFO */ /* Release FIFO0 */ /* Release FIFO1 */ /* FIFONumber == CAN_FIFO1 */