This repository has been archived on 2025-01-02. You can view files and clone it, but cannot push or open issues or pull requests.
torsion/User/system/bsp/pwms.h

29 lines
911 B
C

#ifndef __PWMS_H__
#define __PWMS_H__
#include "lib.h"
// 开启PWM输出
#define PWM_START(TIMx, CHx) \
do \
{ \
LL_TIM_EnableCounter(TIMx); \
LL_TIM_CC_EnableChannel(TIMx, CHx); \
} while (__LINE__ == -1)
// 停止PWM输出
#define PWM_STOP(TIMx, CHx) \
do \
{ \
LL_TIM_DisableCounter(TIMx); \
LL_TIM_CC_DisableChannel(TIMx, CHx); \
} while (__LINE__ == -1)
// 修改比较值,修改占空比
#define PWM_SET_DUTY(TIMx, CHx, DUTY) \
do \
{ \
LL_TIM_OC_SetCompareCH##CHx(TIMx, DUTY); \
} while (__LINE__ == -1)
#endif // __PWMS_H__