vscode_embedded/vscode_stm32f1_test/hal/STM32F10x_StdPeriph_Driver/src/stm32f10x_tim.c
/**
  * @brief  Configures the External clock Mode1
  * @param  TIMx: where x can be  1, 2, 3, 4, 5 or 8 to select the TIM peripheral.
  * @param  TIM_ExtTRGPrescaler: The external Trigger Prescaler.
  *   This parameter can be one of the following values:
  *     @arg TIM_ExtTRGPSC_OFF: ETRP Prescaler OFF.
  *     @arg TIM_ExtTRGPSC_DIV2: ETRP frequency divided by 2.
  *     @arg TIM_ExtTRGPSC_DIV4: ETRP frequency divided by 4.
  *     @arg TIM_ExtTRGPSC_DIV8: ETRP frequency divided by 8.
  * @param  TIM_ExtTRGPolarity: The external Trigger Polarity.
  *   This parameter can be one of the following values:
  *     @arg TIM_ExtTRGPolarity_Inverted: active low or falling edge active.
  *     @arg TIM_ExtTRGPolarity_NonInverted: active high or rising edge active.
  * @param  ExtTRGFilter: External Trigger Filter.
  *   This parameter must be a value between 0x00 and 0x0F
  * @retval None
  */
@brief  Configures the External clock Mode1
@param  TIMx: where x can be  1, 2, 3, 4, 5 or 8 to select the TIM peripheral.
@param  TIM_ExtTRGPrescaler: The external Trigger Prescaler.
This parameter can be one of the following values:
@arg TIM_ExtTRGPSC_OFF: ETRP Prescaler OFF.
@arg TIM_ExtTRGPSC_DIV2: ETRP frequency divided by 2.
@arg TIM_ExtTRGPSC_DIV4: ETRP frequency divided by 4.
@arg TIM_ExtTRGPSC_DIV8: ETRP frequency divided by 8.
@param  TIM_ExtTRGPolarity: The external Trigger Polarity.
This parameter can be one of the following values:
@arg TIM_ExtTRGPolarity_Inverted: active low or falling edge active.
@arg TIM_ExtTRGPolarity_NonInverted: active high or rising edge active.
@param  ExtTRGFilter: External Trigger Filter.
This parameter must be a value between 0x00 and 0x0F
@retval None
@brief Configures the External clock Mode1 @param TIMx : where x can be 1 2 3 4 5 or 8 to select the TIM peripheral . @param TIM_ExtTRGPrescaler : The external Trigger Prescaler . This parameter can be one of the following values : @arg TIM_ExtTRGPSC_OFF : ETRP Prescaler OFF . @arg TIM_ExtTRGPSC_DIV2 : ETRP frequency divided by 2 . @arg TIM_ExtTRGPSC_DIV4 : ETRP frequency divided by 4 . @arg TIM_ExtTRGPSC_DIV8 : ETRP frequency divided by 8 . @param TIM_ExtTRGPolarity : The external Trigger Polarity . This parameter can be one of the following values : @arg TIM_ExtTRGPolarity_Inverted : active low or falling edge active . @arg TIM_ExtTRGPolarity_NonInverted : active high or rising edge active . @param ExtTRGFilter : External Trigger Filter . This parameter must be a value between 0x00 and 0x0F @retval None
void TIM_ETRClockMode1Config(TIM_TypeDef* TIMx, uint16_t TIM_ExtTRGPrescaler, uint16_t TIM_ExtTRGPolarity,
                             uint16_t ExtTRGFilter)
{
  uint16_t tmpsmcr = 0;
  assert_param(IS_TIM_LIST3_PERIPH(TIMx));
  assert_param(IS_TIM_EXT_PRESCALER(TIM_ExtTRGPrescaler));
  assert_param(IS_TIM_EXT_POLARITY(TIM_ExtTRGPolarity));
  assert_param(IS_TIM_EXT_FILTER(ExtTRGFilter));
  TIM_ETRConfig(TIMx, TIM_ExtTRGPrescaler, TIM_ExtTRGPolarity, ExtTRGFilter);
  tmpsmcr = TIMx->SMCR;
  tmpsmcr &= (uint16_t)(~((uint16_t)TIM_SMCR_SMS));
  tmpsmcr |= TIM_SlaveMode_External1;
  tmpsmcr &= (uint16_t)(~((uint16_t)TIM_SMCR_TS));
  tmpsmcr |= TIM_TS_ETRF;
  TIMx->SMCR = tmpsmcr;
}
void TIM_ETRClockMode1Config ( TIM_TypeDef * TIMx , uint16_t TIM_ExtTRGPrescaler , uint16_t TIM_ExtTRGPolarity , uint16_t ExtTRGFilter ) { uint16_t tmpsmcr = 0 ; assert_param ( IS_TIM_LIST3_PERIPH ( TIMx ) ) ; assert_param ( IS_TIM_EXT_PRESCALER ( TIM_ExtTRGPrescaler ) ) ; assert_param ( IS_TIM_EXT_POLARITY ( TIM_ExtTRGPolarity ) ) ; assert_param ( IS_TIM_EXT_FILTER ( ExtTRGFilter ) ) ; TIM_ETRConfig ( TIMx , TIM_ExtTRGPrescaler , TIM_ExtTRGPolarity , ExtTRGFilter ) ; tmpsmcr = TIMx -> SMCR ; tmpsmcr &= ( uint16_t ) ( ~ ( ( uint16_t ) TIM_SMCR_SMS ) ) ; tmpsmcr |= TIM_SlaveMode_External1 ; tmpsmcr &= ( uint16_t ) ( ~ ( ( uint16_t ) TIM_SMCR_TS ) ) ; tmpsmcr |= TIM_TS_ETRF ; TIMx -> SMCR = tmpsmcr ; }
@brief  Configures the External clock Mode1
 @param  TIMx: where x can be  1, 2, 3, 4, 5 or 8 to select the TIM peripheral.
@brief Configures the External clock Mode1 @param TIMx : where x can be 1 2 3 4 5 or 8 to select the TIM peripheral .
/* Check the parameters */ /* Configure the ETR Clock source */ /* Get the TIMx SMCR register value */ /* Reset the SMS Bits */ /* Select the External clock mode1 */ /* Select the Trigger selection : ETRF */ /* Write to TIMx SMCR */