/**
******************************************************************************
* File Name : TIM.c
* Description : This file provides code for the configuration
* of the TIM instances.
******************************************************************************
* @attention
*
*
© Copyright (c) 2020 STMicroelectronics.
* All rights reserved.
*
* This software component is licensed by ST under BSD 3-Clause license,
* the "License"; You may not use this file except in compliance with the
* License. You may obtain a copy of the License at:
* opensource.org/licenses/BSD-3-Clause
*
******************************************************************************
*/
/* Includes ------------------------------------------------------------------*/
#include "tim.h"
/* USER CODE BEGIN 0 */
/* USER CODE END 0 */
/* TIM4 init function */
void MX_TIM4_Init(void)
{
LL_TIM_InitTypeDef TIM_InitStruct = {0};
/* Peripheral clock enable */
LL_APB1_GRP1_EnableClock(LL_APB1_GRP1_PERIPH_TIM4);
/* TIM4 interrupt Init */
NVIC_SetPriority(TIM4_IRQn, NVIC_EncodePriority(NVIC_GetPriorityGrouping(),0, 0));
NVIC_EnableIRQ(TIM4_IRQn);
TIM_InitStruct.Prescaler = 64000;
TIM_InitStruct.CounterMode = LL_TIM_COUNTERMODE_UP;
TIM_InitStruct.Autoreload = 10000;
TIM_InitStruct.ClockDivision = LL_TIM_CLOCKDIVISION_DIV1;
LL_TIM_Init(TIM4, &TIM_InitStruct);
LL_TIM_DisableARRPreload(TIM4);
LL_TIM_SetClockSource(TIM4, LL_TIM_CLOCKSOURCE_INTERNAL);
LL_TIM_SetTriggerOutput(TIM4, LL_TIM_TRGO_RESET);
LL_TIM_DisableMasterSlaveMode(TIM4);
}
/* USER CODE BEGIN 1 */
void StartTIM(TIM_TypeDef *TIMx)
{
LL_TIM_EnableCounter(TIMx);
LL_TIM_ClearFlag_UPDATE(TIMx);
LL_TIM_EnableIT_UPDATE(TIMx);
}
void StopTIM(TIM_TypeDef *TIMx)
{
LL_TIM_DisableCounter(TIMx);
LL_TIM_ClearFlag_UPDATE(TIMx);
LL_TIM_DisableIT_UPDATE(TIMx);
}
/* USER CODE END 1 */
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/