31 lines
1004 B
C
31 lines
1004 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); \
|
|
LL_TIM_EnableIT_UPDATE(TIMx); \
|
|
} while (__LINE__ == -1)
|
|
|
|
// 停止PWM输出
|
|
#define PWM_STOP(TIMx, CHx) \
|
|
do \
|
|
{ \
|
|
LL_TIM_DisableCounter(TIMx); \
|
|
LL_TIM_CC_DisableChannel(TIMx, CHx); \
|
|
LL_TIM_ClearFlag_UPDATE(TIMx); \
|
|
} while (__LINE__ == -1)
|
|
|
|
// 修改比较值,修改占空比
|
|
#define PWM_SET_DUTY(TIMx, CHx, DUTY) \
|
|
do \
|
|
{ \
|
|
LL_TIM_OC_SetCompareCH##CHx(TIMx, DUTY); \
|
|
} while (__LINE__ == -1)
|
|
|
|
#endif // __PWMS_H__
|