vscode_embedded/vscode_stm32f1_test/hal/STM32F10x_StdPeriph_Driver/src/stm32f10x_tim.c
/**
  * @brief  Configures the TIM peripheral according to the specified
  *         parameters in the TIM_ICInitStruct to measure an external PWM signal.
  * @param  TIMx: where x can be  1, 2, 3, 4, 5, 8, 9, 12 or 15 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  Configures the TIM peripheral according to the specified
parameters in the TIM_ICInitStruct to measure an external PWM signal.
@param  TIMx: where x can be  1, 2, 3, 4, 5, 8, 9, 12 or 15 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 Configures the TIM peripheral according to the specified parameters in the TIM_ICInitStruct to measure an external PWM signal . @param TIMx : where x can be 1 2 3 4 5 8 9 12 or 15 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_PWMIConfig(TIM_TypeDef* TIMx, TIM_ICInitTypeDef* TIM_ICInitStruct)
{
  uint16_t icoppositepolarity = TIM_ICPolarity_Rising;
  uint16_t icoppositeselection = TIM_ICSelection_DirectTI;
  assert_param(IS_TIM_LIST6_PERIPH(TIMx));
  if (TIM_ICInitStruct->TIM_ICPolarity == TIM_ICPolarity_Rising)
  {
    icoppositepolarity = TIM_ICPolarity_Falling;
  }
  else
  {
    icoppositepolarity = TIM_ICPolarity_Rising;
  }
  if (TIM_ICInitStruct->TIM_ICSelection == TIM_ICSelection_DirectTI)
  {
    icoppositeselection = TIM_ICSelection_IndirectTI;
  }
  else
  {
    icoppositeselection = TIM_ICSelection_DirectTI;
  }
  if (TIM_ICInitStruct->TIM_Channel == TIM_Channel_1)
  {
    TI1_Config(TIMx, TIM_ICInitStruct->TIM_ICPolarity, TIM_ICInitStruct->TIM_ICSelection,
               TIM_ICInitStruct->TIM_ICFilter);
    TIM_SetIC1Prescaler(TIMx, TIM_ICInitStruct->TIM_ICPrescaler);
    TI2_Config(TIMx, icoppositepolarity, icoppositeselection, TIM_ICInitStruct->TIM_ICFilter);
    TIM_SetIC2Prescaler(TIMx, TIM_ICInitStruct->TIM_ICPrescaler);
  }
  else
  { 
    TI2_Config(TIMx, TIM_ICInitStruct->TIM_ICPolarity, TIM_ICInitStruct->TIM_ICSelection,
               TIM_ICInitStruct->TIM_ICFilter);
    TIM_SetIC2Prescaler(TIMx, TIM_ICInitStruct->TIM_ICPrescaler);
    TI1_Config(TIMx, icoppositepolarity, icoppositeselection, TIM_ICInitStruct->TIM_ICFilter);
    TIM_SetIC1Prescaler(TIMx, TIM_ICInitStruct->TIM_ICPrescaler);
  }
}
void TIM_PWMIConfig ( TIM_TypeDef * TIMx , TIM_ICInitTypeDef * TIM_ICInitStruct ) { uint16_t icoppositepolarity = TIM_ICPolarity_Rising ; uint16_t icoppositeselection = TIM_ICSelection_DirectTI ; assert_param ( IS_TIM_LIST6_PERIPH ( TIMx ) ) ; if ( TIM_ICInitStruct -> TIM_ICPolarity == TIM_ICPolarity_Rising ) { icoppositepolarity = TIM_ICPolarity_Falling ; } else { icoppositepolarity = TIM_ICPolarity_Rising ; } if ( TIM_ICInitStruct -> TIM_ICSelection == TIM_ICSelection_DirectTI ) { icoppositeselection = TIM_ICSelection_IndirectTI ; } else { icoppositeselection = TIM_ICSelection_DirectTI ; } if ( TIM_ICInitStruct -> TIM_Channel == TIM_Channel_1 ) { TI1_Config ( TIMx , TIM_ICInitStruct -> TIM_ICPolarity , TIM_ICInitStruct -> TIM_ICSelection , TIM_ICInitStruct -> TIM_ICFilter ) ; TIM_SetIC1Prescaler ( TIMx , TIM_ICInitStruct -> TIM_ICPrescaler ) ; TI2_Config ( TIMx , icoppositepolarity , icoppositeselection , TIM_ICInitStruct -> TIM_ICFilter ) ; TIM_SetIC2Prescaler ( TIMx , TIM_ICInitStruct -> TIM_ICPrescaler ) ; } else { TI2_Config ( TIMx , TIM_ICInitStruct -> TIM_ICPolarity , TIM_ICInitStruct -> TIM_ICSelection , TIM_ICInitStruct -> TIM_ICFilter ) ; TIM_SetIC2Prescaler ( TIMx , TIM_ICInitStruct -> TIM_ICPrescaler ) ; TI1_Config ( TIMx , icoppositepolarity , icoppositeselection , TIM_ICInitStruct -> TIM_ICFilter ) ; TIM_SetIC1Prescaler ( TIMx , TIM_ICInitStruct -> TIM_ICPrescaler ) ; } }
@brief  Configures the TIM peripheral according to the specified
         parameters in the TIM_ICInitStruct to measure an external PWM signal.
@brief Configures the TIM peripheral according to the specified parameters in the TIM_ICInitStruct to measure an external PWM signal .
/* Check the parameters */ /* Select the Opposite Input Polarity */ /* Select the Opposite Input */ /* TI1 Configuration */ /* Set the Input Capture Prescaler value */ /* TI2 Configuration */ /* Set the Input Capture Prescaler value */ /* TI2 Configuration */ /* Set the Input Capture Prescaler value */ /* TI1 Configuration */ /* Set the Input Capture Prescaler value */