29#define BPWM_CHANNEL_NUM (6)
30#define BPWM_CH_0_MASK (0x1UL)
31#define BPWM_CH_1_MASK (0x2UL)
32#define BPWM_CH_2_MASK (0x4UL)
33#define BPWM_CH_3_MASK (0x8UL)
34#define BPWM_CH_4_MASK (0x10UL)
35#define BPWM_CH_5_MASK (0x20UL)
40#define BPWM_UP_COUNTER (0UL)
41#define BPWM_DOWN_COUNTER (1UL)
42#define BPWM_UP_DOWN_COUNTER (2UL)
47#define BPWM_EDGE_ALIGNED (1UL)
48#define BPWM_CENTER_ALIGNED (2UL)
53#define BPWM_OUTPUT_NOTHING (0UL)
54#define BPWM_OUTPUT_LOW (1UL)
55#define BPWM_OUTPUT_HIGH (2UL)
56#define BPWM_OUTPUT_TOGGLE (3UL)
61#define BPWM_SSCTL_SSRC_PWM0 (0UL<<BPWM_SSCTL_SSRC_Pos)
62#define BPWM_SSCTL_SSRC_PWM1 (1UL<<BPWM_SSCTL_SSRC_Pos)
63#define BPWM_SSCTL_SSRC_BPWM0 (2UL<<BPWM_SSCTL_SSRC_Pos)
64#define BPWM_SSCTL_SSRC_BPWM1 (3UL<<BPWM_SSCTL_SSRC_Pos)
69#define BPWM_TRIGGER_ADC_EVEN_ZERO_POINT (0UL)
70#define BPWM_TRIGGER_ADC_EVEN_PERIOD_POINT (1UL)
71#define BPWM_TRIGGER_ADC_EVEN_ZERO_OR_PERIOD_POINT (2UL)
72#define BPWM_TRIGGER_ADC_EVEN_CMP_UP_COUNT_POINT (3UL)
73#define BPWM_TRIGGER_ADC_EVEN_CMP_DOWN_COUNT_POINT (4UL)
74#define BPWM_TRIGGER_ADC_ODD_CMP_UP_COUNT_POINT (8UL)
75#define BPWM_TRIGGER_ADC_ODD_CMP_DOWN_COUNT_POINT (9UL)
80#define BPWM_CAPTURE_INT_RISING_LATCH (1UL)
81#define BPWM_CAPTURE_INT_FALLING_LATCH (0x100UL)
86#define BPWM_DUTY_INT_DOWN_COUNT_MATCH_CMP (1 << BPWM_INTEN_CMPDIENn_Pos)
87#define BPWM_DUTY_INT_UP_COUNT_MATCH_CMP (1 << BPWM_INTEN_CMPUIENn_Pos)
92#define BPWM_LOAD_MODE_IMMEDIATE (1 << BPWM_CTL0_IMMLDENn_Pos)
93#define BPWM_LOAD_MODE_CENTER (1 << BPWM_CTL0_CTRLDn_Pos)
98#define BPWM_CLKSRC_BPWM_CLK (0UL)
99#define BPWM_CLKSRC_TIMER0 (1UL)
100#define BPWM_CLKSRC_TIMER1 (2UL)
101#define BPWM_CLKSRC_TIMER2 (3UL)
102#define BPWM_CLKSRC_TIMER3 (4UL)
125#define BPWM_ENABLE_TIMER_SYNC(bpwm, u32ChannelMask, u32SyncSrc) ((bpwm)->SSCTL = ((bpwm)->SSCTL & ~BPWM_SSCTL_SSRC_Msk) | (u32SyncSrc) | BPWM_SSCTL_SSEN0_Msk)
136#define BPWM_DISABLE_TIMER_SYNC(bpwm, u32ChannelMask) ((bpwm)->SSCTL &= ~BPWM_SSCTL_SSEN0_Msk)
146#define BPWM_TRIGGER_SYNC_START(bpwm) ((bpwm)->SSTRG = BPWM_SSTRG_CNTSEN_Msk)
156#define BPWM_ENABLE_OUTPUT_INVERTER(bpwm, u32ChannelMask) ((bpwm)->POLCTL = (u32ChannelMask))
165#define BPWM_GET_CAPTURE_RISING_DATA(bpwm, u32ChannelNum) ((bpwm)->CAPDAT[(u32ChannelNum)].RCAPDAT)
174#define BPWM_GET_CAPTURE_FALLING_DATA(bpwm, u32ChannelNum) ((bpwm)->CAPDAT[(u32ChannelNum)].FCAPDAT)
187#define BPWM_MASK_OUTPUT(bpwm, u32ChannelMask, u32LevelMask) \
189 (bpwm)->MSKEN = (u32ChannelMask); \
190 (bpwm)->MSK = (u32LevelMask); \
201#define BPWM_SET_PRESCALER(bpwm, u32ChannelNum, u32Prescaler) ((bpwm)->CLKPSC = (u32Prescaler))
212#define BPWM_SET_CMR(bpwm, u32ChannelNum, u32CMR) ((bpwm)->CMPDAT[(u32ChannelNum)] = (u32CMR))
221#define BPWM_GET_CMR(bpwm, u32ChannelNum) ((bpwm)->CMPDAT[(u32ChannelNum)])
233#define BPWM_SET_CNR(bpwm, u32ChannelNum, u32CNR) ((bpwm)->PERIOD = (u32CNR))
242#define BPWM_GET_CNR(bpwm, u32ChannelNum) ((bpwm)->PERIOD)
255#define BPWM_SET_ALIGNED_TYPE(bpwm, u32ChannelMask, u32AlignedType) ((bpwm)->CTL1 = (u32AlignedType))
265#define BPWM_CLR_COUNTER(bpwm, u32ChannelMask) ((bpwm)->CNTCLR = (BPWM_CNTCLR_CNTCLR0_Msk))
296#define BPWM_SET_OUTPUT_LEVEL(bpwm, u32ChannelMask, u32ZeroLevel, u32CmpUpLevel, u32PeriodLevel, u32CmpDownLevel) \
299 for(i = 0; i < 6; i++) { \
300 if((u32ChannelMask) & (1 << i)) { \
301 (bpwm)->WGCTL0 = (((bpwm)->WGCTL0 & ~(3UL << (2 * i))) | ((u32ZeroLevel) << (2 * i))); \
302 (bpwm)->WGCTL0 = (((bpwm)->WGCTL0 & ~(3UL << (BPWM_WGCTL0_PRDPCTLn_Pos + (2 * i)))) | ((u32PeriodLevel) << (BPWM_WGCTL0_PRDPCTLn_Pos + (2 * i)))); \
303 (bpwm)->WGCTL1 = (((bpwm)->WGCTL1 & ~(3UL << (2 * i))) | ((u32CmpUpLevel) << (2 * i))); \
304 (bpwm)->WGCTL1 = (((bpwm)->WGCTL1 & ~(3UL << (BPWM_WGCTL1_CMPDCTLn_Pos + (2 * i)))) | ((u32CmpDownLevel) << (BPWM_WGCTL1_CMPDCTLn_Pos + (2 * i)))); \
void BPWM_EnableADCTrigger(BPWM_T *bpwm, uint32_t u32ChannelNum, uint32_t u32Condition)
Enable selected channel to trigger ADC.
void BPWM_ClearCaptureIntFlag(BPWM_T *bpwm, uint32_t u32ChannelNum, uint32_t u32Edge)
Clear capture interrupt of selected channel.
void BPWM_Start(BPWM_T *bpwm, uint32_t u32ChannelMask)
Start BPWM module.
void BPWM_ClearWrapAroundFlag(BPWM_T *bpwm, uint32_t u32ChannelNum)
Clear the time-base counter reached its maximum value flag of selected channel.
void BPWM_EnableCapture(BPWM_T *bpwm, uint32_t u32ChannelMask)
Enable capture of selected channel(s)
uint32_t BPWM_GetWrapAroundFlag(BPWM_T *bpwm, uint32_t u32ChannelNum)
Get the time-base counter reached its maximum value flag of selected channel.
void BPWM_ClearDutyIntFlag(BPWM_T *bpwm, uint32_t u32ChannelNum)
Clear duty interrupt flag of selected channel.
void BPWM_DisablePeriodInt(BPWM_T *bpwm, uint32_t u32ChannelNum)
Disable period interrupt of selected channel.
void BPWM_Stop(BPWM_T *bpwm, uint32_t u32ChannelMask)
Stop BPWM module.
void BPWM_EnableLoadMode(BPWM_T *bpwm, uint32_t u32ChannelNum, uint32_t u32LoadMode)
Enable load mode of selected channel.
void BPWM_DisableCaptureInt(BPWM_T *bpwm, uint32_t u32ChannelNum, uint32_t u32Edge)
Disable capture interrupt of selected channel.
uint32_t BPWM_GetCaptureIntFlag(BPWM_T *bpwm, uint32_t u32ChannelNum)
Get capture interrupt of selected channel.
void BPWM_EnablePeriodInt(BPWM_T *bpwm, uint32_t u32ChannelNum, uint32_t u32IntPeriodType)
Enable period interrupt of selected channel.
uint32_t BPWM_ConfigOutputChannel(BPWM_T *bpwm, uint32_t u32ChannelNum, uint32_t u32Frequency, uint32_t u32DutyCycle)
This function Configure BPWM generator and get the nearest frequency in edge aligned auto-reload mode...
uint32_t BPWM_GetZeroIntFlag(BPWM_T *bpwm, uint32_t u32ChannelNum)
Get zero interrupt of selected channel.
uint32_t BPWM_GetDutyIntFlag(BPWM_T *bpwm, uint32_t u32ChannelNum)
Get duty interrupt flag of selected channel.
void BPWM_EnableCaptureInt(BPWM_T *bpwm, uint32_t u32ChannelNum, uint32_t u32Edge)
Enable capture interrupt of selected channel.
void BPWM_DisableCapture(BPWM_T *bpwm, uint32_t u32ChannelMask)
Disable capture of selected channel(s)
void BPWM_DisableDutyInt(BPWM_T *bpwm, uint32_t u32ChannelNum)
Disable duty interrupt of selected channel.
void BPWM_ClearADCTriggerFlag(BPWM_T *bpwm, uint32_t u32ChannelNum, uint32_t u32Condition)
Clear selected channel trigger ADC flag.
void BPWM_DisableOutput(BPWM_T *bpwm, uint32_t u32ChannelMask)
Disables BPWM output generation of selected channel(s)
uint32_t BPWM_ConfigCaptureChannel(BPWM_T *bpwm, uint32_t u32ChannelNum, uint32_t u32UnitTimeNsec, uint32_t u32CaptureEdge)
Configure BPWM capture and get the nearest unit time.
void BPWM_EnableOutput(BPWM_T *bpwm, uint32_t u32ChannelMask)
Enables BPWM output generation of selected channel(s)
void BPWM_ClearZeroIntFlag(BPWM_T *bpwm, uint32_t u32ChannelNum)
Clear zero interrupt of selected channel.
uint32_t BPWM_GetPeriodIntFlag(BPWM_T *bpwm, uint32_t u32ChannelNum)
Get period interrupt of selected channel.
void BPWM_EnableDutyInt(BPWM_T *bpwm, uint32_t u32ChannelNum, uint32_t u32IntDutyType)
Enable duty interrupt of selected channel.
uint32_t BPWM_GetADCTriggerFlag(BPWM_T *bpwm, uint32_t u32ChannelNum)
Get selected channel trigger ADC flag.
void BPWM_DisableLoadMode(BPWM_T *bpwm, uint32_t u32ChannelNum, uint32_t u32LoadMode)
Disable load mode of selected channel.
void BPWM_ForceStop(BPWM_T *bpwm, uint32_t u32ChannelMask)
Stop BPWM generation immediately by clear channel enable bit.
void BPWM_SetClockSource(BPWM_T *bpwm, uint32_t u32ChannelNum, uint32_t u32ClkSrcSel)
Set BPWM clock source.
void BPWM_ClearPeriodIntFlag(BPWM_T *bpwm, uint32_t u32ChannelNum)
Clear period interrupt of selected channel.
void BPWM_DisableZeroInt(BPWM_T *bpwm, uint32_t u32ChannelNum)
Disable zero interrupt of selected channel.
void BPWM_EnableZeroInt(BPWM_T *bpwm, uint32_t u32ChannelNum)
Enable zero interrupt of selected channel.
void BPWM_DisableADCTrigger(BPWM_T *bpwm, uint32_t u32ChannelNum)
Disable selected channel to trigger ADC.