vscode_embedded/vscode_stm32f1_test/hal/STM32F10x_StdPeriph_Driver/src/stm32f10x_tim.c
/**
  * @brief  Initializes the TIM peripheral according to the specified
  *         parameters in the TIM_ICInitStruct.
  * @param  TIMx: where x can be  1 to 17 except 6 and 7 to select the TIM peripheral.
  * @param  TIM_ICInitStruct: pointer to a TIM_ICInitTypeDef structure
  *         that contains the configuration information for the specified TIM peripheral.
  * @retval None
  */
@brief  Initializes the TIM peripheral according to the specified
parameters in the TIM_ICInitStruct.
@param  TIMx: where x can be  1 to 17 except 6 and 7 to select the TIM peripheral.
@param  TIM_ICInitStruct: pointer to a TIM_ICInitTypeDef structure
that contains the configuration information for the specified TIM peripheral.
@retval None
@brief Initializes the TIM peripheral according to the specified parameters in the TIM_ICInitStruct . @param TIMx : where x can be 1 to 17 except 6 and 7 to select the TIM peripheral . @param TIM_ICInitStruct : pointer to a TIM_ICInitTypeDef structure that contains the configuration information for the specified TIM peripheral . @retval None
void TIM_ICInit(TIM_TypeDef* TIMx, TIM_ICInitTypeDef* TIM_ICInitStruct)
{
  assert_param(IS_TIM_CHANNEL(TIM_ICInitStruct->TIM_Channel));  
  assert_param(IS_TIM_IC_SELECTION(TIM_ICInitStruct->TIM_ICSelection));
  assert_param(IS_TIM_IC_PRESCALER(TIM_ICInitStruct->TIM_ICPrescaler));
  assert_param(IS_TIM_IC_FILTER(TIM_ICInitStruct->TIM_ICFilter));
  if((TIMx == TIM1) || (TIMx == TIM8) || (TIMx == TIM2) || (TIMx == TIM3) ||
     (TIMx == TIM4) ||(TIMx == TIM5))
  {
    assert_param(IS_TIM_IC_POLARITY(TIM_ICInitStruct->TIM_ICPolarity));
  }
  else
  {
    assert_param(IS_TIM_IC_POLARITY_LITE(TIM_ICInitStruct->TIM_ICPolarity));
  }
  if (TIM_ICInitStruct->TIM_Channel == TIM_Channel_1)
  {
    assert_param(IS_TIM_LIST8_PERIPH(TIMx));
    TI1_Config(TIMx, TIM_ICInitStruct->TIM_ICPolarity,
               TIM_ICInitStruct->TIM_ICSelection,
               TIM_ICInitStruct->TIM_ICFilter);
    TIM_SetIC1Prescaler(TIMx, TIM_ICInitStruct->TIM_ICPrescaler);
  }
  else if (TIM_ICInitStruct->TIM_Channel == TIM_Channel_2)
  {
    assert_param(IS_TIM_LIST6_PERIPH(TIMx));
    TI2_Config(TIMx, TIM_ICInitStruct->TIM_ICPolarity,
               TIM_ICInitStruct->TIM_ICSelection,
               TIM_ICInitStruct->TIM_ICFilter);
    TIM_SetIC2Prescaler(TIMx, TIM_ICInitStruct->TIM_ICPrescaler);
  }
  else if (TIM_ICInitStruct->TIM_Channel == TIM_Channel_3)
  {
    assert_param(IS_TIM_LIST3_PERIPH(TIMx));
    TI3_Config(TIMx,  TIM_ICInitStruct->TIM_ICPolarity,
               TIM_ICInitStruct->TIM_ICSelection,
               TIM_ICInitStruct->TIM_ICFilter);
    TIM_SetIC3Prescaler(TIMx, TIM_ICInitStruct->TIM_ICPrescaler);
  }
  else
  {
    assert_param(IS_TIM_LIST3_PERIPH(TIMx));
    TI4_Config(TIMx, TIM_ICInitStruct->TIM_ICPolarity,
               TIM_ICInitStruct->TIM_ICSelection,
               TIM_ICInitStruct->TIM_ICFilter);
    TIM_SetIC4Prescaler(TIMx, TIM_ICInitStruct->TIM_ICPrescaler);
  }
}
void TIM_ICInit ( TIM_TypeDef * TIMx , TIM_ICInitTypeDef * TIM_ICInitStruct ) { assert_param ( IS_TIM_CHANNEL ( TIM_ICInitStruct -> TIM_Channel ) ) ; assert_param ( IS_TIM_IC_SELECTION ( TIM_ICInitStruct -> TIM_ICSelection ) ) ; assert_param ( IS_TIM_IC_PRESCALER ( TIM_ICInitStruct -> TIM_ICPrescaler ) ) ; assert_param ( IS_TIM_IC_FILTER ( TIM_ICInitStruct -> TIM_ICFilter ) ) ; if ( ( TIMx == TIM1 ) || ( TIMx == TIM8 ) || ( TIMx == TIM2 ) || ( TIMx == TIM3 ) || ( TIMx == TIM4 ) || ( TIMx == TIM5 ) ) { assert_param ( IS_TIM_IC_POLARITY ( TIM_ICInitStruct -> TIM_ICPolarity ) ) ; } else { assert_param ( IS_TIM_IC_POLARITY_LITE ( TIM_ICInitStruct -> TIM_ICPolarity ) ) ; } if ( TIM_ICInitStruct -> TIM_Channel == TIM_Channel_1 ) { assert_param ( IS_TIM_LIST8_PERIPH ( TIMx ) ) ; TI1_Config ( TIMx , TIM_ICInitStruct -> TIM_ICPolarity , TIM_ICInitStruct -> TIM_ICSelection , TIM_ICInitStruct -> TIM_ICFilter ) ; TIM_SetIC1Prescaler ( TIMx , TIM_ICInitStruct -> TIM_ICPrescaler ) ; } else if ( TIM_ICInitStruct -> TIM_Channel == TIM_Channel_2 ) { assert_param ( IS_TIM_LIST6_PERIPH ( TIMx ) ) ; TI2_Config ( TIMx , TIM_ICInitStruct -> TIM_ICPolarity , TIM_ICInitStruct -> TIM_ICSelection , TIM_ICInitStruct -> TIM_ICFilter ) ; TIM_SetIC2Prescaler ( TIMx , TIM_ICInitStruct -> TIM_ICPrescaler ) ; } else if ( TIM_ICInitStruct -> TIM_Channel == TIM_Channel_3 ) { assert_param ( IS_TIM_LIST3_PERIPH ( TIMx ) ) ; TI3_Config ( TIMx , TIM_ICInitStruct -> TIM_ICPolarity , TIM_ICInitStruct -> TIM_ICSelection , TIM_ICInitStruct -> TIM_ICFilter ) ; TIM_SetIC3Prescaler ( TIMx , TIM_ICInitStruct -> TIM_ICPrescaler ) ; } else { assert_param ( IS_TIM_LIST3_PERIPH ( TIMx ) ) ; TI4_Config ( TIMx , TIM_ICInitStruct -> TIM_ICPolarity , TIM_ICInitStruct -> TIM_ICSelection , TIM_ICInitStruct -> TIM_ICFilter ) ; TIM_SetIC4Prescaler ( TIMx , TIM_ICInitStruct -> TIM_ICPrescaler ) ; } }
@brief  Initializes the TIM peripheral according to the specified
         parameters in the TIM_ICInitStruct.
@brief Initializes the TIM peripheral according to the specified parameters in the TIM_ICInitStruct .
/* Check the parameters */ /* TI1 Configuration */ /* Set the Input Capture Prescaler value */ /* TI2 Configuration */ /* Set the Input Capture Prescaler value */ /* TI3 Configuration */ /* Set the Input Capture Prescaler value */ /* TI4 Configuration */ /* Set the Input Capture Prescaler value */