/********************************** (C) COPYRIGHT ******************************* * File Name : ch32v20x_tim5.h * Author : ÂÞ³É * Version : V1.0.0 * Date : 2025/08/06 * Description : This file contains all the functions prototypes for the * TIM5 firmware library. *******************************************************************************/ #ifndef __CH32V20x_TIM5_H #define __CH32V20x_TIM5_H #ifdef __cplusplus extern "C" { #endif #include "ch32v20x_tim.h" /* TIM Time Base Init structure definition */ typedef struct { uint16_t TIM_Prescaler; /* Specifies the prescaler value used to divide the TIM clock. This parameter can be a number between 0x0000 and 0xFFFF */ uint16_t TIM_CounterMode; /* Specifies the counter mode. This parameter can be a value of @ref TIM_Counter_Mode */ uint32_t TIM_Period; /* Specifies the period value to be loaded into the active Auto-Reload Register at the next update event. This parameter must be a number between 0x00000000 and 0xFFFFFFFF. */ uint16_t TIM_ClockDivision; /* Specifies the clock division. This parameter can be a value of @ref TIM_Clock_Division_CKD */ uint8_t TIM_RepetitionCounter; /* Specifies the repetition counter value. Each time the RCR downcounter reaches zero, an update event is generated and counting restarts from the RCR value (N). This means in PWM mode that (N+1) corresponds to: - the number of PWM periods in edge-aligned mode - the number of half PWM period in center-aligned mode This parameter must be a number between 0x00 and 0xFF. @note This parameter is valid only for TIM1 and TIM8. */ } TIM5_TimeBaseInitTypeDef; /* TIM Output Compare Init structure definition */ typedef struct { uint16_t TIM_OCMode; /* Specifies the TIM mode. This parameter can be a value of @ref TIM_Output_Compare_and_PWM_modes */ uint16_t TIM_OutputState; /* Specifies the TIM Output Compare state. This parameter can be a value of @ref TIM_Output_Compare_state */ uint16_t TIM_OutputNState; /* Specifies the TIM complementary Output Compare state. This parameter can be a value of @ref TIM_Output_Compare_N_state @note This parameter is valid only for TIM1 and TIM8. */ uint32_t TIM_Pulse; /* Specifies the pulse value to be loaded into the Capture Compare Register. This parameter can be a number between 0x00000000 and 0xFFFFFFFF */ uint16_t TIM_OCPolarity; /* Specifies the output polarity. This parameter can be a value of @ref TIM_Output_Compare_Polarity */ uint16_t TIM_OCNPolarity; /* Specifies the complementary output polarity. This parameter can be a value of @ref TIM_Output_Compare_N_Polarity @note This parameter is valid only for TIM1 and TIM8. */ uint16_t TIM_OCIdleState; /* Specifies the TIM Output Compare pin state during Idle state. This parameter can be a value of @ref TIM_Output_Compare_Idle_State @note This parameter is valid only for TIM1 and TIM8. */ uint16_t TIM_OCNIdleState; /* Specifies the TIM Output Compare pin state during Idle state. This parameter can be a value of @ref TIM_Output_Compare_N_Idle_State @note This parameter is valid only for TIM1 and TIM8. */ } TIM5_OCInitTypeDef; /* TIM Input Capture Init structure definition */ typedef struct { uint16_t TIM_Channel; /* Specifies the TIM channel. This parameter can be a value of @ref TIM_Channel */ uint16_t TIM_ICPolarity; /* Specifies the active edge of the input signal. This parameter can be a value of @ref TIM_Input_Capture_Polarity */ uint16_t TIM_ICSelection; /* Specifies the input. This parameter can be a value of @ref TIM_Input_Capture_Selection */ uint16_t TIM_ICPrescaler; /* Specifies the Input Capture Prescaler. This parameter can be a value of @ref TIM_Input_Capture_Prescaler */ uint16_t TIM_ICFilter; /* Specifies the input capture filter. This parameter can be a number between 0x0 and 0xF */ } TIM5_ICInitTypeDef; /* BDTR structure definition */ typedef struct { uint16_t TIM_OSSRState; /* Specifies the Off-State selection used in Run mode. This parameter can be a value of @ref OSSR_Off_State_Selection_for_Run_mode_state */ uint16_t TIM_OSSIState; /* Specifies the Off-State used in Idle state. This parameter can be a value of @ref OSSI_Off_State_Selection_for_Idle_mode_state */ uint16_t TIM_LOCKLevel; /* Specifies the LOCK level parameters. This parameter can be a value of @ref Lock_level */ uint16_t TIM_DeadTime; /* Specifies the delay time between the switching-off and the switching-on of the outputs. This parameter can be a number between 0x00 and 0xFF */ uint16_t TIM_Break; /* Specifies whether the TIM Break input is enabled or not. This parameter can be a value of @ref Break_Input_enable_disable */ uint16_t TIM_BreakPolarity; /* Specifies the TIM Break Input pin polarity. This parameter can be a value of @ref Break_Polarity */ uint16_t TIM_AutomaticOutput; /* Specifies whether the TIM Automatic Output feature is enabled or not. This parameter can be a value of @ref TIM_AOE_Bit_Set_Reset */ } TIM5_BDTRInitTypeDef; void TIM5_DeInit(void); void TIM5_TimeBaseInit(TIM5_TimeBaseInitTypeDef *TIM_TimeBaseInitStruct); void TIM5_OC1Init(TIM5_OCInitTypeDef *TIM_OCInitStruct); void TIM5_OC2Init(TIM5_OCInitTypeDef *TIM_OCInitStruct); void TIM5_OC3Init(TIM5_OCInitTypeDef *TIM_OCInitStruct); void TIM5_OC4Init(TIM5_OCInitTypeDef *TIM_OCInitStruct); void TIM5_ICInit(TIM5_ICInitTypeDef *TIM_ICInitStruct); void TIM5_PWMIConfig(TIM5_ICInitTypeDef *TIM_ICInitStruct); void TIM5_BDTRConfig(TIM5_BDTRInitTypeDef *TIM_BDTRInitStruct); void TIM5_TimeBaseStructInit(TIM5_TimeBaseInitTypeDef *TIM_TimeBaseInitStruct); void TIM5_OCStructInit(TIM5_OCInitTypeDef *TIM_OCInitStruct); void TIM5_ICStructInit(TIM5_ICInitTypeDef *TIM_ICInitStruct); void TIM5_BDTRStructInit(TIM5_BDTRInitTypeDef *TIM_BDTRInitStruct); void TIM5_Cmd(FunctionalState NewState); void TIM5_ITConfig(uint16_t TIM_IT, FunctionalState NewState); void TIM5_GenerateEvent(uint16_t TIM_EventSource); void TIM5_DMAConfig(uint16_t TIM_DMABase, uint16_t TIM_DMABurstLength); void TIM5_DMACmd(uint16_t TIM_DMASource, FunctionalState NewState); void TIM5_InternalClockConfig(void); void TIM5_ITRxExternalClockConfig(uint16_t TIM_InputTriggerSource); void TIM5_TIxExternalClockConfig(uint16_t TIM_TIxExternalCLKSource, uint16_t TIM_ICPolarity, uint16_t ICFilter); void TIM5_ETRClockMode1Config(uint16_t TIM_ExtTRGPrescaler, uint16_t TIM_ExtTRGPolarity, uint16_t ExtTRGFilter); void TIM5_ETRClockMode2Config(uint16_t TIM_ExtTRGPrescaler, uint16_t TIM_ExtTRGPolarity, uint16_t ExtTRGFilter); void TIM5_ETRConfig(uint16_t TIM_ExtTRGPrescaler, uint16_t TIM_ExtTRGPolarity, uint16_t ExtTRGFilter); void TIM5_PrescalerConfig(uint16_t Prescaler, uint16_t TIM_PSCReloadMode); void TIM5_CounterModeConfig(uint16_t TIM_CounterMode); void TIM5_SelectInputTrigger(uint16_t TIM_InputTriggerSource); void TIM5_EncoderInterfaceConfig(uint16_t TIM_EncoderMode, uint16_t TIM_IC1Polarity, uint16_t TIM_IC2Polarity); void TIM5_ForcedOC1Config(uint16_t TIM_ForcedAction); void TIM5_ForcedOC2Config(uint16_t TIM_ForcedAction); void TIM5_ForcedOC3Config(uint16_t TIM_ForcedAction); void TIM5_ForcedOC4Config(uint16_t TIM_ForcedAction); void TIM5_ARRPreloadConfig(FunctionalState NewState); void TIM5_SelectCOM(FunctionalState NewState); void TIM5_SelectCCDMA(FunctionalState NewState); void TIM5_CCPreloadControl(FunctionalState NewState); void TIM5_OC1PreloadConfig(uint16_t TIM_OCPreload); void TIM5_OC2PreloadConfig(uint16_t TIM_OCPreload); void TIM5_OC3PreloadConfig(uint16_t TIM_OCPreload); void TIM5_OC4PreloadConfig(uint16_t TIM_OCPreload); void TIM5_OC1FastConfig(uint16_t TIM_OCFast); void TIM5_OC2FastConfig(uint16_t TIM_OCFast); void TIM5_OC3FastConfig(uint16_t TIM_OCFast); void TIM5_OC4FastConfig(uint16_t TIM_OCFast); void TIM5_ClearOC1Ref(uint16_t TIM_OCClear); void TIM5_ClearOC2Ref(uint16_t TIM_OCClear); void TIM5_ClearOC3Ref(uint16_t TIM_OCClear); void TIM5_ClearOC4Ref(uint16_t TIM_OCClear); void TIM5_OC1PolarityConfig(uint16_t TIM_OCPolarity); void TIM5_OC1NPolarityConfig(uint16_t TIM_OCNPolarity); void TIM5_OC2PolarityConfig(uint16_t TIM_OCPolarity); void TIM5_OC2NPolarityConfig(uint16_t TIM_OCNPolarity); void TIM5_OC3PolarityConfig(uint16_t TIM_OCPolarity); void TIM5_OC3NPolarityConfig(uint16_t TIM_OCNPolarity); void TIM5_OC4PolarityConfig(uint16_t TIM_OCPolarity); void TIM5_CCxCmd(uint16_t TIM_Channel, uint16_t TIM_CCx); void TIM5_CCxNCmd(uint16_t TIM_Channel, uint16_t TIM_CCxN); void TIM5_SelectOCxM(uint16_t TIM_Channel, uint16_t TIM_OCMode); void TIM5_UpdateDisableConfig(FunctionalState NewState); void TIM5_UpdateRequestConfig(uint16_t TIM_UpdateSource); void TIM5_SelectHallSensor(FunctionalState NewState); void TIM5_SelectOnePulseMode(uint16_t TIM_OPMode); void TIM5_SelectOutputTrigger(uint16_t TIM_TRGOSource); void TIM5_SelectSlaveMode(uint16_t TIM_SlaveMode); void TIM5_SelectMasterSlaveMode(uint16_t TIM_MasterSlaveMode); void TIM5_SetCounter(uint32_t Counter); void TIM5_SetAutoreload(uint32_t Autoreload); void TIM5_SetCompare1(uint32_t Compare1); void TIM5_SetCompare2(uint32_t Compare2); void TIM5_SetCompare3(uint32_t Compare3); void TIM5_SetCompare4(uint32_t Compare4); void TIM5_SetIC1Prescaler(uint16_t TIM_ICPSC); void TIM5_SetIC2Prescaler(uint16_t TIM_ICPSC); void TIM5_SetIC3Prescaler(uint16_t TIM_ICPSC); void TIM5_SetIC4Prescaler(uint16_t TIM_ICPSC); void TIM5_SetClockDivision(uint16_t TIM_CKD); uint32_t TIM5_GetCapture1(void); uint32_t TIM5_GetCapture2(void); uint32_t TIM5_GetCapture3(void); uint32_t TIM5_GetCapture4(void); uint32_t TIM5_GetCounter(void); uint16_t TIM5_GetPrescaler(void); FlagStatus TIM5_GetFlagStatus(uint16_t TIM_FLAG); void TIM5_ClearFlag(uint16_t TIM_FLAG); ITStatus TIM5_GetITStatus(uint16_t TIM_IT); void TIM5_ClearITPendingBit(uint16_t TIM_IT); #ifdef __cplusplus } #endif #endif