Examples/Crusher/Linux/stm32/firmware/lib/src/peripherals/stm32f4xx_can.c
/**
  * @brief  Clears the CAN's pending flags.
  * @param  CANx: where x can be 1 or 2 to to select the CAN peripheral.
  * @param  CAN_FLAG: specifies the flag to clear.
  *          This parameter can be one of the following values:
  *            @arg CAN_FLAG_RQCP0: Request MailBox0 Flag
  *            @arg CAN_FLAG_RQCP1: Request MailBox1 Flag
  *            @arg CAN_FLAG_RQCP2: Request MailBox2 Flag 
  *            @arg CAN_FLAG_FF0: FIFO 0 Full Flag       
  *            @arg CAN_FLAG_FOV0: FIFO 0 Overrun Flag  
  *            @arg CAN_FLAG_FF1: FIFO 1 Full Flag        
  *            @arg CAN_FLAG_FOV1: FIFO 1 Overrun Flag     
  *            @arg CAN_FLAG_WKU: Wake up Flag
  *            @arg CAN_FLAG_SLAK: Sleep acknowledge Flag    
  *            @arg CAN_FLAG_LEC: Last error code Flag        
  * @retval None
  */
@brief  Clears the CAN's pending flags.
@param  CANx: where x can be 1 or 2 to to select the CAN peripheral.
@param  CAN_FLAG: specifies the flag to clear.
@brief Clears the CAN ' s pending flags . @param CANx : where x can be 1 or 2 to to select the CAN peripheral . @param CAN_FLAG : specifies the flag to clear .
void CAN_ClearFlag(CAN_TypeDef* CANx, uint32_t CAN_FLAG)
{
  uint32_t flagtmp=0;
  assert_param(IS_CAN_ALL_PERIPH(CANx));
  assert_param(IS_CAN_CLEAR_FLAG(CAN_FLAG));
  if (CAN_FLAG == CAN_FLAG_LEC) 
  {
    CANx->ESR = (uint32_t)RESET;
  }
  else 
  {
    flagtmp = CAN_FLAG & 0x000FFFFF;
    if ((CAN_FLAG & CAN_FLAGS_RF0R)!=(uint32_t)RESET)
    {
      CANx->RF0R = (uint32_t)(flagtmp);
    }
    else if ((CAN_FLAG & CAN_FLAGS_RF1R)!=(uint32_t)RESET)
    {
      CANx->RF1R = (uint32_t)(flagtmp);
    }
    else if ((CAN_FLAG & CAN_FLAGS_TSR)!=(uint32_t)RESET)
    {
      CANx->TSR = (uint32_t)(flagtmp);
    }
    else 
    {
      CANx->MSR = (uint32_t)(flagtmp);
    }
  }
}
void CAN_ClearFlag ( CAN_TypeDef * CANx , uint32_t CAN_FLAG ) { uint32_t flagtmp = 0 ; assert_param ( IS_CAN_ALL_PERIPH ( CANx ) ) ; assert_param ( IS_CAN_CLEAR_FLAG ( CAN_FLAG ) ) ; if ( CAN_FLAG == CAN_FLAG_LEC ) { CANx -> ESR = ( uint32_t ) RESET ; } else { flagtmp = CAN_FLAG & 0x000FFFFF ; if ( ( CAN_FLAG & CAN_FLAGS_RF0R ) != ( uint32_t ) RESET ) { CANx -> RF0R = ( uint32_t ) ( flagtmp ) ; } else if ( ( CAN_FLAG & CAN_FLAGS_RF1R ) != ( uint32_t ) RESET ) { CANx -> RF1R = ( uint32_t ) ( flagtmp ) ; } else if ( ( CAN_FLAG & CAN_FLAGS_TSR ) != ( uint32_t ) RESET ) { CANx -> TSR = ( uint32_t ) ( flagtmp ) ; } else { CANx -> MSR = ( uint32_t ) ( flagtmp ) ; } } }
@brief  Clears the CAN's pending flags.
@brief Clears the CAN ' s pending flags .
/* Check the parameters */ /* ESR register */ /* Clear the selected CAN flags */ /* MSR or TSR or RF0R or RF1R */ /* Receive Flags */ /* Receive Flags */ /* Transmit Flags */ /* If((CAN_FLAG & CAN_FLAGS_MSR)!=(uint32_t)RESET) */ /* Operating mode Flags */