libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F103RB/stm32f10x_can.c
/**
  * @brief  Initializes the CAN peripheral according to the specified
  *         parameters in the CAN_FilterInitStruct.
  * @param  CAN_FilterInitStruct: pointer to a CAN_FilterInitTypeDef
  *                               structure that contains the configuration 
  *                               information.
  * @retval None.
  */
@brief  Initializes the CAN peripheral according to the specified
parameters in the CAN_FilterInitStruct.
@param  CAN_FilterInitStruct: pointer to a CAN_FilterInitTypeDef
structure that contains the configuration
information.
@retval None.
@brief Initializes the CAN peripheral according to the specified parameters in the CAN_FilterInitStruct . @param CAN_FilterInitStruct : pointer to a CAN_FilterInitTypeDef structure that contains the configuration information . @retval None .
void CAN_FilterInit(CAN_FilterInitTypeDef* CAN_FilterInitStruct)
{
  uint32_t filter_number_bit_pos = 0;
  assert_param(IS_CAN_FILTER_NUMBER(CAN_FilterInitStruct->CAN_FilterNumber));
  assert_param(IS_CAN_FILTER_MODE(CAN_FilterInitStruct->CAN_FilterMode));
  assert_param(IS_CAN_FILTER_SCALE(CAN_FilterInitStruct->CAN_FilterScale));
  assert_param(IS_CAN_FILTER_FIFO(CAN_FilterInitStruct->CAN_FilterFIFOAssignment));
  assert_param(IS_FUNCTIONAL_STATE(CAN_FilterInitStruct->CAN_FilterActivation));
  filter_number_bit_pos = ((uint32_t)1) << CAN_FilterInitStruct->CAN_FilterNumber;
  CAN1->FMR |= FMR_FINIT;
  CAN1->FA1R &= ~(uint32_t)filter_number_bit_pos;
  if (CAN_FilterInitStruct->CAN_FilterScale == CAN_FilterScale_16bit)
  {
    CAN1->FS1R &= ~(uint32_t)filter_number_bit_pos;
    CAN1->sFilterRegister[CAN_FilterInitStruct->CAN_FilterNumber].FR1 = 
    ((0x0000FFFF & (uint32_t)CAN_FilterInitStruct->CAN_FilterMaskIdLow) << 16) |
        (0x0000FFFF & (uint32_t)CAN_FilterInitStruct->CAN_FilterIdLow);
    CAN1->sFilterRegister[CAN_FilterInitStruct->CAN_FilterNumber].FR2 = 
    ((0x0000FFFF & (uint32_t)CAN_FilterInitStruct->CAN_FilterMaskIdHigh) << 16) |
        (0x0000FFFF & (uint32_t)CAN_FilterInitStruct->CAN_FilterIdHigh);
  }
  if (CAN_FilterInitStruct->CAN_FilterScale == CAN_FilterScale_32bit)
  {
    CAN1->FS1R |= filter_number_bit_pos;
    CAN1->sFilterRegister[CAN_FilterInitStruct->CAN_FilterNumber].FR1 = 
    ((0x0000FFFF & (uint32_t)CAN_FilterInitStruct->CAN_FilterIdHigh) << 16) |
        (0x0000FFFF & (uint32_t)CAN_FilterInitStruct->CAN_FilterIdLow);
    CAN1->sFilterRegister[CAN_FilterInitStruct->CAN_FilterNumber].FR2 = 
    ((0x0000FFFF & (uint32_t)CAN_FilterInitStruct->CAN_FilterMaskIdHigh) << 16) |
        (0x0000FFFF & (uint32_t)CAN_FilterInitStruct->CAN_FilterMaskIdLow);
  }
  if (CAN_FilterInitStruct->CAN_FilterMode == CAN_FilterMode_IdMask)
  {
    CAN1->FM1R &= ~(uint32_t)filter_number_bit_pos;
  }
  else 
  {
    CAN1->FM1R |= (uint32_t)filter_number_bit_pos;
  }
  if (CAN_FilterInitStruct->CAN_FilterFIFOAssignment == CAN_Filter_FIFO0)
  {
    CAN1->FFA1R &= ~(uint32_t)filter_number_bit_pos;
  }
  if (CAN_FilterInitStruct->CAN_FilterFIFOAssignment == CAN_Filter_FIFO1)
  {
    CAN1->FFA1R |= (uint32_t)filter_number_bit_pos;
  }
  if (CAN_FilterInitStruct->CAN_FilterActivation == ENABLE)
  {
    CAN1->FA1R |= filter_number_bit_pos;
  }
  CAN1->FMR &= ~FMR_FINIT;
}
void CAN_FilterInit ( CAN_FilterInitTypeDef * CAN_FilterInitStruct ) { uint32_t filter_number_bit_pos = 0 ; assert_param ( IS_CAN_FILTER_NUMBER ( CAN_FilterInitStruct -> CAN_FilterNumber ) ) ; assert_param ( IS_CAN_FILTER_MODE ( CAN_FilterInitStruct -> CAN_FilterMode ) ) ; assert_param ( IS_CAN_FILTER_SCALE ( CAN_FilterInitStruct -> CAN_FilterScale ) ) ; assert_param ( IS_CAN_FILTER_FIFO ( CAN_FilterInitStruct -> CAN_FilterFIFOAssignment ) ) ; assert_param ( IS_FUNCTIONAL_STATE ( CAN_FilterInitStruct -> CAN_FilterActivation ) ) ; filter_number_bit_pos = ( ( uint32_t ) 1 ) << CAN_FilterInitStruct -> CAN_FilterNumber ; CAN1 -> FMR |= FMR_FINIT ; CAN1 -> FA1R &= ~ ( uint32_t ) filter_number_bit_pos ; if ( CAN_FilterInitStruct -> CAN_FilterScale == CAN_FilterScale_16bit ) { CAN1 -> FS1R &= ~ ( uint32_t ) filter_number_bit_pos ; CAN1 -> sFilterRegister [ CAN_FilterInitStruct -> CAN_FilterNumber ] . FR1 = ( ( 0x0000FFFF & ( uint32_t ) CAN_FilterInitStruct -> CAN_FilterMaskIdLow ) << 16 ) | ( 0x0000FFFF & ( uint32_t ) CAN_FilterInitStruct -> CAN_FilterIdLow ) ; CAN1 -> sFilterRegister [ CAN_FilterInitStruct -> CAN_FilterNumber ] . FR2 = ( ( 0x0000FFFF & ( uint32_t ) CAN_FilterInitStruct -> CAN_FilterMaskIdHigh ) << 16 ) | ( 0x0000FFFF & ( uint32_t ) CAN_FilterInitStruct -> CAN_FilterIdHigh ) ; } if ( CAN_FilterInitStruct -> CAN_FilterScale == CAN_FilterScale_32bit ) { CAN1 -> FS1R |= filter_number_bit_pos ; CAN1 -> sFilterRegister [ CAN_FilterInitStruct -> CAN_FilterNumber ] . FR1 = ( ( 0x0000FFFF & ( uint32_t ) CAN_FilterInitStruct -> CAN_FilterIdHigh ) << 16 ) | ( 0x0000FFFF & ( uint32_t ) CAN_FilterInitStruct -> CAN_FilterIdLow ) ; CAN1 -> sFilterRegister [ CAN_FilterInitStruct -> CAN_FilterNumber ] . FR2 = ( ( 0x0000FFFF & ( uint32_t ) CAN_FilterInitStruct -> CAN_FilterMaskIdHigh ) << 16 ) | ( 0x0000FFFF & ( uint32_t ) CAN_FilterInitStruct -> CAN_FilterMaskIdLow ) ; } if ( CAN_FilterInitStruct -> CAN_FilterMode == CAN_FilterMode_IdMask ) { CAN1 -> FM1R &= ~ ( uint32_t ) filter_number_bit_pos ; } else { CAN1 -> FM1R |= ( uint32_t ) filter_number_bit_pos ; } if ( CAN_FilterInitStruct -> CAN_FilterFIFOAssignment == CAN_Filter_FIFO0 ) { CAN1 -> FFA1R &= ~ ( uint32_t ) filter_number_bit_pos ; } if ( CAN_FilterInitStruct -> CAN_FilterFIFOAssignment == CAN_Filter_FIFO1 ) { CAN1 -> FFA1R |= ( uint32_t ) filter_number_bit_pos ; } if ( CAN_FilterInitStruct -> CAN_FilterActivation == ENABLE ) { CAN1 -> FA1R |= filter_number_bit_pos ; } CAN1 -> FMR &= ~ FMR_FINIT ; }
@brief  Initializes the CAN peripheral according to the specified
         parameters in the CAN_FilterInitStruct.
@brief Initializes the CAN peripheral according to the specified parameters in the CAN_FilterInitStruct .
/* Check the parameters */ /* Initialisation mode for the filter */ /* Filter Deactivation */ /* Filter Scale */ /* 16-bit scale for the filter */ /* First 16-bit identifier and First 16-bit mask */ /* Or First 16-bit identifier and Second 16-bit identifier */ /* Second 16-bit identifier and Second 16-bit mask */ /* Or Third 16-bit identifier and Fourth 16-bit identifier */ /* 32-bit scale for the filter */ /* 32-bit identifier or First 32-bit identifier */ /* 32-bit mask or Second 32-bit identifier */ /* Filter Mode */ /*Id/Mask mode for the filter*/ /* CAN_FilterInitStruct->CAN_FilterMode == CAN_FilterMode_IdList */ /*Identifier list mode for the filter*/ /* Filter FIFO assignment */ /* FIFO 0 assignation for the filter */ /* FIFO 1 assignation for the filter */ /* Filter activation */ /* Leave the initialisation mode for the filter */