Esempio n. 1
0
/**
  * @brief  Configures the TIM5 Trigger as External Clock.
  * @param  TIM5_TIxExternalCLKSource : Specifies Trigger source.
  *   This parameter can be one of the @ref TIM5_TIxExternalCLK1Source_TypeDef enumeration.
  * @param  TIM5_ICPolarity : Specifies the TIx Polarity.
  *   This parameter can be @ref TIM5_ICPolarity_TypeDef enumeration.
  * @param  ICFilter : Specifies the filter value.
  *   This parameter must be a value between 0x00 and 0x0F
  * @retval None
  */
void TIM5_TIxExternalClockConfig(TIM5_TIxExternalCLK1Source_TypeDef TIM5_TIxExternalCLKSource,
                                 TIM5_ICPolarity_TypeDef TIM5_ICPolarity,
                                 uint8_t ICFilter)
{
  /* Check the parameters */
  assert_param(IS_TIM5_TIXCLK_SOURCE(TIM5_TIxExternalCLKSource));
  assert_param(IS_TIM5_IC_POLARITY(TIM5_ICPolarity));
  assert_param(IS_TIM5_IC_FILTER(ICFilter));

  /* Configure the TIM5 Input Clock Source */
  if (TIM5_TIxExternalCLKSource == TIM5_TIxExternalCLK1Source_TI2)
  {
    TI2_Config(TIM5_ICPolarity, TIM5_ICSelection_DirectTI, ICFilter);
  }
  else
  {
    TI1_Config(TIM5_ICPolarity, TIM5_ICSelection_DirectTI, ICFilter);
  }

  /* Select the Trigger source */
  TIM5_SelectInputTrigger((TIM5_TRGSelection_TypeDef)TIM5_TIxExternalCLKSource);

  /* Select the External clock mode1 */
  TIM5->SMCR |= (uint8_t)(TIM5_SlaveMode_External1);
}
Esempio n. 2
0
/**
  * @brief  TIM5 Configuration.
  * @param  None
  * @retval None
  */
static void TIM5_Config(void)
{
  /*DeInit TIM5 registers*/
  TIM5_DeInit();
  
  /* Time base configuration */
  TIM5_TimeBaseInit(TIM5_PRESCALER_1, 0xFF );
  
  /* Select TIM6 as source of TIM5 Trigger Input*/
  TIM5_SelectInputTrigger(TIM5_TS_TIM6);
  
  /* configurate TIM5 as slave of Trigger input*/
  TIM5_SelectSlaveMode(TIM5_SLAVEMODE_TRIGGER);
}