src/peripherals.c
/*
 * @brief  Configures TIM1 for PWM outputs
 * @param  None
 * @retval None
 */
@brief  Configures TIM1 for PWM outputs
@param  None
@retval None
@brief Configures TIM1 for PWM outputs @param None @retval None
void TIM_Configuration(void)
{
	TIM_TimeBaseInitTypeDef TIM_TimeBaseStructure;
	TIM_OCInitTypeDef TIM_OCInitStructure;
	int PrescalerValue = (uint16_t) (SystemCoreClock / (50000)) - 1;
	TIM_TimeBaseStructure.TIM_Period = PWM_TIMER_PERIOD;
	TIM_TimeBaseStructure.TIM_Prescaler = PrescalerValue;
	TIM_TimeBaseStructure.TIM_ClockDivision = 0;
	TIM_TimeBaseStructure.TIM_CounterMode = TIM_CounterMode_Up;
	TIM_TimeBaseInit(TIM3, &TIM_TimeBaseStructure);
	TIM_OCInitStructure.TIM_OCMode = TIM_OCMode_PWM1;
	TIM_OCInitStructure.TIM_OutputState = TIM_OutputState_Enable;
	TIM_OCInitStructure.TIM_Pulse = 0;
	TIM_OCInitStructure.TIM_OCPolarity = TIM_OCPolarity_High;
	TIM_OC1Init(TIM3, &TIM_OCInitStructure);
	TIM_OC1PreloadConfig(TIM3, TIM_OCPreload_Enable);
	TIM_OCInitStructure.TIM_OutputState = TIM_OutputState_Enable;
	TIM_OCInitStructure.TIM_Pulse = 0;
	TIM_OC2Init(TIM3, &TIM_OCInitStructure);
	TIM_OC2PreloadConfig(TIM3, TIM_OCPreload_Enable);
	TIM_OCInitStructure.TIM_OutputState = TIM_OutputState_Enable;
	TIM_OCInitStructure.TIM_Pulse = 0;
	TIM_OC3Init(TIM3, &TIM_OCInitStructure);
	TIM_OC3PreloadConfig(TIM3, TIM_OCPreload_Enable);
	TIM_ARRPreloadConfig(TIM3, ENABLE);
	TIM_Cmd(TIM3, ENABLE);
}
void TIM_Configuration ( void ) { TIM_TimeBaseInitTypeDef TIM_TimeBaseStructure ; TIM_OCInitTypeDef TIM_OCInitStructure ; int PrescalerValue = ( uint16_t ) ( SystemCoreClock / ( 50000 ) ) - 1 ; TIM_TimeBaseStructure . TIM_Period = PWM_TIMER_PERIOD ; TIM_TimeBaseStructure . TIM_Prescaler = PrescalerValue ; TIM_TimeBaseStructure . TIM_ClockDivision = 0 ; TIM_TimeBaseStructure . TIM_CounterMode = TIM_CounterMode_Up ; TIM_TimeBaseInit ( TIM3 , & TIM_TimeBaseStructure ) ; TIM_OCInitStructure . TIM_OCMode = TIM_OCMode_PWM1 ; TIM_OCInitStructure . TIM_OutputState = TIM_OutputState_Enable ; TIM_OCInitStructure . TIM_Pulse = 0 ; TIM_OCInitStructure . TIM_OCPolarity = TIM_OCPolarity_High ; TIM_OC1Init ( TIM3 , & TIM_OCInitStructure ) ; TIM_OC1PreloadConfig ( TIM3 , TIM_OCPreload_Enable ) ; TIM_OCInitStructure . TIM_OutputState = TIM_OutputState_Enable ; TIM_OCInitStructure . TIM_Pulse = 0 ; TIM_OC2Init ( TIM3 , & TIM_OCInitStructure ) ; TIM_OC2PreloadConfig ( TIM3 , TIM_OCPreload_Enable ) ; TIM_OCInitStructure . TIM_OutputState = TIM_OutputState_Enable ; TIM_OCInitStructure . TIM_Pulse = 0 ; TIM_OC3Init ( TIM3 , & TIM_OCInitStructure ) ; TIM_OC3PreloadConfig ( TIM3 , TIM_OCPreload_Enable ) ; TIM_ARRPreloadConfig ( TIM3 , ENABLE ) ; TIM_Cmd ( TIM3 , ENABLE ) ; }
@brief  Configures TIM1 for PWM outputs
 @param  None
 @retval None
@brief Configures TIM1 for PWM outputs @param None @retval None
/* Compute the prescaler value */ /* Time base configuration */ /* PWM1 Mode configuration: Channel1 */ /* PWM1 Mode configuration: Channel2 */ /* PWM1 Mode configuration: Channel */ /* TIM3 enable counter */