59 lines
2.5 KiB
C
59 lines
2.5 KiB
C
|
#ifndef __SWM320_PWM_H__
|
|||
|
#define __SWM320_PWM_H__
|
|||
|
|
|||
|
typedef struct {
|
|||
|
uint8_t clk_div; //PWM_CLKDIV_1<5F><31>PWM_CLKDIV_8
|
|||
|
|
|||
|
uint8_t mode; //PWM_MODE_INDEP<45><50>PWM_MODE_COMPL<50><4C>PWM_MODE_INDEP_CALIGN<47><4E>PWM_MODE_COMPL_CALIGN
|
|||
|
|
|||
|
uint16_t cycleA; //A·<41><C2B7><EFBFBD><EFBFBD>
|
|||
|
uint16_t hdutyA; //A·ռ<C2B7>ձ<EFBFBD>
|
|||
|
uint16_t deadzoneA; //A·<41><C2B7><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD>ȡֵ0--1023
|
|||
|
uint8_t initLevelA; //A·<41><C2B7>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ƽ<EFBFBD><C6BD>0 <20>͵<EFBFBD>ƽ 1 <20>ߵ<EFBFBD>ƽ
|
|||
|
|
|||
|
uint16_t cycleB; //B·<42><C2B7><EFBFBD><EFBFBD>
|
|||
|
uint16_t hdutyB; //B·ռ<C2B7>ձ<EFBFBD>
|
|||
|
uint16_t deadzoneB; //B·<42><C2B7><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD>ȡֵ0--1023
|
|||
|
uint8_t initLevelB; //B·<42><C2B7>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ƽ<EFBFBD><C6BD>0 <20>͵<EFBFBD>ƽ 1 <20>ߵ<EFBFBD>ƽ
|
|||
|
|
|||
|
uint8_t HEndAIEn; //A·<41>ߵ<EFBFBD>ƽ<EFBFBD><C6BD><EFBFBD><EFBFBD><EFBFBD>ж<EFBFBD>ʹ<EFBFBD><CAB9>
|
|||
|
uint8_t NCycleAIEn; //A·<41><C2B7><EFBFBD><EFBFBD><EFBFBD>ڿ<EFBFBD>ʼ<EFBFBD>ж<EFBFBD>ʹ<EFBFBD><CAB9>
|
|||
|
uint8_t HEndBIEn; //B·<42>ߵ<EFBFBD>ƽ<EFBFBD><C6BD><EFBFBD><EFBFBD><EFBFBD>ж<EFBFBD>ʹ<EFBFBD><CAB9>
|
|||
|
uint8_t NCycleBIEn; //B·<42><C2B7><EFBFBD><EFBFBD><EFBFBD>ڿ<EFBFBD>ʼ<EFBFBD>ж<EFBFBD>ʹ<EFBFBD><CAB9>
|
|||
|
} PWM_InitStructure;
|
|||
|
|
|||
|
#define PWM_CLKDIV_1 0
|
|||
|
#define PWM_CLKDIV_8 1
|
|||
|
|
|||
|
#define PWM_MODE_INDEP 0 //A·<41><C2B7>B·Ϊ<C2B7><CEAA>·<EFBFBD><C2B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
#define PWM_MODE_COMPL 1 //A·<41><C2B7>B·Ϊһ·<D2BB><C2B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
#define PWM_MODE_INDEP_CALIGN 3 //A·<41><C2B7>B·Ϊ<C2B7><CEAA>·<EFBFBD><C2B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ķ<EFBFBD><C4B6><EFBFBD>
|
|||
|
#define PWM_MODE_COMPL_CALIGN 4 //A·<41><C2B7>B·Ϊһ·<D2BB><C2B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ķ<EFBFBD><C4B6><EFBFBD>
|
|||
|
|
|||
|
#define PWM_CH_A 0
|
|||
|
#define PWM_CH_B 1
|
|||
|
|
|||
|
|
|||
|
void PWM_Init(PWM_TypeDef * PWMx, PWM_InitStructure * initStruct); //PWM<57><4D>ʼ<EFBFBD><CABC>
|
|||
|
void PWM_Start(PWM_TypeDef * PWMx, uint32_t chA, uint32_t chB); //<2F><><EFBFBD><EFBFBD>PWM<57><4D><EFBFBD><EFBFBD>ʼPWM<57><4D><EFBFBD><EFBFBD>
|
|||
|
void PWM_Stop(PWM_TypeDef * PWMx, uint32_t chA, uint32_t chB); //<2F>ر<EFBFBD>PWM<57><4D>ֹͣPWM<57><4D><EFBFBD><EFBFBD>
|
|||
|
|
|||
|
void PWM_SetCycle(PWM_TypeDef * PWMx, uint32_t chn, uint16_t cycle); //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
uint16_t PWM_GetCycle(PWM_TypeDef * PWMx, uint32_t chn); //<2F><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD>
|
|||
|
void PWM_SetHDuty(PWM_TypeDef * PWMx, uint32_t chn, uint16_t hduty); //<2F><><EFBFBD>øߵ<C3B8>ƽʱ<C6BD><CAB1>
|
|||
|
uint16_t PWM_GetHDuty(PWM_TypeDef * PWMx, uint32_t chn); //<2F><>ȡ<EFBFBD>ߵ<EFBFBD>ƽʱ<C6BD><CAB1>
|
|||
|
void PWM_SetDeadzone(PWM_TypeDef * PWMx, uint32_t chn, uint8_t deadzone); //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1>
|
|||
|
uint8_t PWM_GetDeadzone(PWM_TypeDef * PWMx, uint32_t chn); //<2F><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1>
|
|||
|
|
|||
|
void PWM_IntNCycleEn(PWM_TypeDef * PWMx, uint32_t chn); //<2F><><EFBFBD><EFBFBD><EFBFBD>ڿ<EFBFBD>ʼ<EFBFBD>ж<EFBFBD>ʹ<EFBFBD><CAB9>
|
|||
|
void PWM_IntNCycleDis(PWM_TypeDef * PWMx, uint32_t chn); //<2F><><EFBFBD><EFBFBD><EFBFBD>ڿ<EFBFBD>ʼ<EFBFBD>жϽ<D0B6><CFBD><EFBFBD>
|
|||
|
void PWM_IntNCycleClr(PWM_TypeDef * PWMx, uint32_t chn); //<2F><><EFBFBD><EFBFBD><EFBFBD>ڿ<EFBFBD>ʼ<EFBFBD>жϱ<D0B6>־<EFBFBD><D6BE><EFBFBD><EFBFBD>
|
|||
|
uint32_t PWM_IntNCycleStat(PWM_TypeDef * PWMx, uint32_t chn); //<2F><><EFBFBD><EFBFBD><EFBFBD>ڿ<EFBFBD>ʼ<EFBFBD>ж<EFBFBD><D0B6>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
void PWM_IntHEndEn(PWM_TypeDef * PWMx, uint32_t chn); //<2F>ߵ<EFBFBD>ƽ<EFBFBD><C6BD><EFBFBD><EFBFBD><EFBFBD>ж<EFBFBD>ʹ<EFBFBD><CAB9>
|
|||
|
void PWM_IntHEndDis(PWM_TypeDef * PWMx, uint32_t chn); //<2F>ߵ<EFBFBD>ƽ<EFBFBD><C6BD><EFBFBD><EFBFBD><EFBFBD>жϽ<D0B6><CFBD><EFBFBD>
|
|||
|
void PWM_IntHEndClr(PWM_TypeDef * PWMx, uint32_t chn); //<2F>ߵ<EFBFBD>ƽ<EFBFBD><C6BD><EFBFBD><EFBFBD><EFBFBD>жϱ<D0B6>־<EFBFBD><D6BE><EFBFBD><EFBFBD>
|
|||
|
uint32_t PWM_IntHEndStat(PWM_TypeDef * PWMx, uint32_t chn); //<2F>ߵ<EFBFBD>ƽ<EFBFBD><C6BD><EFBFBD><EFBFBD><EFBFBD>ж<EFBFBD><D0B6>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
|||
|
|
|||
|
#endif //__SWM320_PWM_H__
|