29#define PWM_CHANNEL_NUM (8)
45#define PWM_TRIGGER_ADC_CNTR_IS_0 PWM_ADCTCTL0_ZPTRGEN0_Msk
46#define PWM_TRIGGER_ADC_CNTR_IS_CMR_D PWM_ADCTCTL0_CDTRGEN0_Msk
47#define PWM_TRIGGER_ADC_CNTR_IS_CNR PWM_ADCTCTL0_CPTRGEN0_Msk
48#define PWM_TRIGGER_ADC_CNTR_IS_CMR_U PWM_ADCTCTL0_CUTRGEN0_Msk
114 pwm->POEN |= u32ChannelMask;
126 pwm->POEN &= ~u32ChannelMask;
142 pwm->DTCTL = (pwm->DTCTL & ~(PWM_DTCTL_DTI01_Msk << (8 * u32ChannelNum))) | (u32Duration << (8 * u32ChannelNum));
144 pwm->CTL2 |= (PWM_CTL2_DTCNT01_Msk << u32ChannelNum);
158 pwm->CTL2 &= ~(PWM_CTL2_DTCNT01_Msk << u32ChannelNum);
169 (pwm)->INTEN |= ((1 << PWM_INTEN_CMPDIEN0_Pos) << u32ChannelNum);
180 (pwm)->INTEN &= ~((1 << PWM_INTEN_CMPDIEN0_Pos) << u32ChannelNum);
191 pwm->INTSTS = (PWM_INTSTS_CMPDIF0_Msk << u32ChannelNum);
204 return(pwm->INTSTS & (PWM_INTSTS_CMPDIF0_Msk << u32ChannelNum) ? 1 : 0);
215 (pwm)->INTEN |= ((1 << PWM_INTEN_PIEN0_Pos) << u32ChannelNum);
226 (pwm)->INTEN &= ~((1 << PWM_INTEN_PIEN0_Pos) << u32ChannelNum);
237 pwm->INTSTS = (PWM_INTSTS_PIF0_Msk << u32ChannelNum);
250 return(pwm->INTSTS & (PWM_INTSTS_PIF0_Msk << u32ChannelNum) ? 1 : 0);
263 (pwm)->INTEN |= ((1 << PWM_INTEN_ZIEN0_Pos) << u32ChannelNum);
274 (pwm)->INTEN &= ~((1 << PWM_INTEN_ZIEN0_Pos) << u32ChannelNum);
285 pwm->INTSTS = (PWM_INTSTS_ZIF0_Msk << u32ChannelNum);
298 return(pwm->INTSTS & (PWM_INTSTS_ZIF0_Msk << u32ChannelNum) ? 1 : 0);
309 (pwm)->INTEN |= ((1 << PWM_INTEN_CMPUIEN0_Pos) << u32ChannelNum);
320 (pwm)->INTEN &= ~((1 << PWM_INTEN_CMPUIEN0_Pos) << u32ChannelNum);
331 pwm->INTSTS = (PWM_INTSTS_CMPUIF0_Msk << u32ChannelNum);
344 return (pwm->INTSTS & (PWM_INTSTS_CMPUIF0_Msk << u32ChannelNum) ? 1 : 0);
359 pwm->CTL2 &= ~PWM_CTL2_PINTTYPE_Msk;
360 pwm->CTL2 |= (IntPeriodType << PWM_CTL2_PINTTYPE_Pos);
361 pwm->INTEN = (pwm->INTEN & ~(PWM_INTEN_PIEN0_Msk << u32ChannelNum)) | (PWM_INTEN_PIEN0_Msk << u32ChannelNum) ;
372 pwm->INTEN &= ~(PWM_INTEN_PIEN0_Msk << u32ChannelNum);
383 pwm->INTSTS = (PWM_INTSTS_PIF0_Msk << u32ChannelNum);
396 return(pwm->INTSTS & (PWM_INTSTS_PIF0_Msk << u32ChannelNum) ? 1 : 0);
406 pwm->CTL2 &= ~PWM_CTL2_MODE_Msk;
415 pwm->CTL2 = (pwm->CTL2 & ~PWM_CTL2_MODE_Msk) | (1UL << PWM_CTL2_MODE_Pos);
425 pwm->CTL2 &= ~PWM_CTL2_MODE_Msk;
435 pwm->CTL2 |= PWM_CTL2_GROUPEN_Msk;
445 pwm->CTL2 &= ~PWM_CTL2_GROUPEN_Msk;
455 pwm->CTL2 = (pwm->CTL2 & ~PWM_CTL2_MODE_Msk) | (2UL << PWM_CTL2_MODE_Pos);
465 pwm->CTL2 &= ~PWM_CTL2_MODE_Msk;
477__STATIC_INLINE
void PWM_SetPrescaler(PWM_T *pwm, uint32_t u32ChannelNum, uint32_t u32Prescaler)
479 pwm->CLKPSC = (pwm->CLKPSC & ~(PWM_CLKPSC_CLKPSC01_Msk << ((u32ChannelNum >> 1) * 8))) | (u32Prescaler << ((u32ChannelNum >> 1) * 8));
492 pwm->CLKPSC &= ~(PWM_CLKPSC_CLKPSC01_Msk << ((u32ChannelNum >> 1) * 8));
509 pwm->CLKDIV = (pwm->CLKDIV & ~(PWM_CLKDIV_CLKDIV0_Msk << ((u32ChannelNum) * 4))) | (Divider << (u32ChannelNum * 4));
520__STATIC_INLINE
void PWM_SetCMR(PWM_T *pwm, uint32_t u32ChannelNum, uint32_t u32CMR)
522 (*((__IO uint32_t *)((((uint32_t) & ((pwm)->CMPDAT0)) + u32ChannelNum * 4)))= (u32CMR & 0x0000FFFF)|(*((__IO uint32_t *)((((uint32_t) & ((pwm)->CMPDAT0)) + u32ChannelNum * 4))) & 0xFFFF0000));
533__STATIC_INLINE
void PWM_SetCNR(PWM_T *pwm, uint32_t u32ChannelNum, uint32_t u32CNR)
535 (*((__IO uint32_t *) ((((uint32_t)&((pwm)->PERIOD0)) + (u32ChannelNum) * 4))) = (u32CNR));
546__STATIC_INLINE
void PWM_SetCMRD(PWM_T *pwm, uint32_t u32ChannelNum, uint32_t u32CMRD)
548 (*((__IO uint32_t *)((((uint32_t) & ((pwm)->CMPDAT0)) + (u32ChannelNum) * 4)))= (u32CMRD << 16)|(*((__IO uint32_t *)((((uint32_t) & ((pwm)->CMPDAT0)) + (u32ChannelNum) * 4))) & 0x0000FFFF));
562 pwm->CTL2 = (pwm->CTL2 & ~PWM_CTL2_CNTTYPE_Msk) | (AlignedType << PWM_CTL2_CNTTYPE_Pos);
572 pwm->CTL |= PWM_CTL_ASYMEN_Msk;
582 pwm->CTL &= ~PWM_CTL_ASYMEN_Msk;
592 pwm->PCACTL |= PWM_PCACTL_PCAEN_Msk;
602 pwm->PCACTL &= ~PWM_PCACTL_PCAEN_Msk;
614 pwm->CTL = (pwm->CTL & ~(PWM_CTL_CNTMODE0_Msk << (u32ChannelNum * 4))) | ((CntMode << PWM_CTL_CNTMODE0_Pos) << ((u32ChannelNum) * 4));
629 uint32_t u32ChannelNum,
630 uint32_t u32Frequency,
631 uint32_t u32DutyCycle,
692void PWM_EnableADCTrigger(PWM_T *pwm, uint32_t u32ChannelNum, uint32_t u32Condition);
699void PWM_DisableADCTrigger(PWM_T *pwm, uint32_t u32ChannelNum);
707void PWM_ClearADCTriggerFlag(PWM_T *pwm, uint32_t u32ChannelNum, uint32_t u32Condition);
715uint32_t PWM_GetADCTriggerFlag (PWM_T *pwm, uint32_t u32ChannelNum, uint32_t u32Condition);
enum _PWM_AlignedTypeDef PWM_AlignedTypeDef
_PWM_AlignedTypeDef
Definition: pan_pwm.h:68
@ PWM_CENTER_ALIGNED
Definition: pan_pwm.h:70
@ PWM_EDGE_ALIGNED
Definition: pan_pwm.h:69
_PWM_ClkDivDef
Definition: pan_pwm.h:55
enum _PWM_ClkDivDef PWM_ClkDivDef
@ PWM_CLK_DIV_2
Definition: pan_pwm.h:57
@ PWM_CLK_DIV_4
Definition: pan_pwm.h:58
@ PWM_CLK_DIV_1
Definition: pan_pwm.h:56
@ PWM_CLK_DIV_8
Definition: pan_pwm.h:59
@ PWM_CLK_DIV_16
Definition: pan_pwm.h:60
_PWM_CntModeDef
Definition: pan_pwm.h:99
enum _PWM_CntModeDef PWM_CntModeDef
@ PWM_CNTMODE_ONE_SHOT
Definition: pan_pwm.h:100
@ PWM_CNTMODE_AUTO_RELOAD
Definition: pan_pwm.h:101
enum _PWM_OperateTypeDef PWM_OperateTypeDef
_PWM_OperateTypeDef
Definition: pan_pwm.h:88
@ OPERATION_EDGE_ALIGNED
Definition: pan_pwm.h:89
@ OPERATION_PRECISE_CENTER_ALIGNED
Definition: pan_pwm.h:91
@ OPERATION_CENTER_ALIGNED
Definition: pan_pwm.h:90
enum _PWM_IntPeriodTypeDef PWM_IntPeriodTypeDef
_PWM_IntPeriodTypeDef
Definition: pan_pwm.h:78
@ PWM_PERIOD_INT_UNDERFLOW
Definition: pan_pwm.h:79
@ PWM_PERIOD_INT_MATCH_CNR
Definition: pan_pwm.h:80
void PWM_ForceStop(PWM_T *pwm, uint32_t u32ChannelMask)
This function stop PWM generation immediately by clear channel enable bit.
__STATIC_INLINE void PWM_SetCNR(PWM_T *pwm, uint32_t u32ChannelNum, uint32_t u32CNR)
This function set the period of the selected channel.
Definition: pan_pwm.h:533
void PWM_Stop(PWM_T *pwm, uint32_t u32ChannelMask)
This function stop PWM module.
__STATIC_INLINE void PWM_ClearCMPDIntFlag(PWM_T *pwm, uint32_t u32ChannelNum)
This function clears Compare_Down interrupt flag of selected channel.
Definition: pan_pwm.h:189
__STATIC_INLINE void PWM_DisableOutput(PWM_T *pwm, uint32_t u32ChannelMask)
This function disables PWM output generation of selected channels.
Definition: pan_pwm.h:124
__STATIC_INLINE void PWM_EnableComplementaryMode(PWM_T *pwm)
This function enable complementary mode.
Definition: pan_pwm.h:413
__STATIC_INLINE void PWM_SetCMR(PWM_T *pwm, uint32_t u32ChannelNum, uint32_t u32CMR)
This function set the duty of the selected channel.
Definition: pan_pwm.h:520
void PWM_EnableOutputInverter(PWM_T *pwm, uint32_t u32ChannelMask)
This function enable output inverter of specified channel(s)
__STATIC_INLINE void PWM_ClearZeroIntFlag(PWM_T *pwm, uint32_t u32ChannelNum)
This function clears Zero interrupt flag of selected channel.
Definition: pan_pwm.h:283
__STATIC_INLINE void PWM_SetCMRD(PWM_T *pwm, uint32_t u32ChannelNum, uint32_t u32CMRD)
This function set the duty of the selected channel for PWM asymmetric Mode.
Definition: pan_pwm.h:546
__STATIC_INLINE void PWM_SetPrescaler(PWM_T *pwm, uint32_t u32ChannelNum, uint32_t u32Prescaler)
This function set the prescaler of the selected channel.
Definition: pan_pwm.h:477
__STATIC_INLINE void PWM_DisableCMPUInt(PWM_T *pwm, uint32_t u32ChannelNum)
This function disable Compare_Up interrupt of selected channel.
Definition: pan_pwm.h:318
__STATIC_INLINE uint32_t PWM_GetCMPUIntFlag(PWM_T *pwm, uint32_t u32ChannelNum)
This function get Compare_Up interrupt flag of selected channel.
Definition: pan_pwm.h:342
__STATIC_INLINE uint32_t PWM_GetCMPDIntFlag(PWM_T *pwm, uint32_t u32ChannelNum)
This function get Compare_Down interrupt flag of selected channel.
Definition: pan_pwm.h:202
__STATIC_INLINE void PWM_SetDivider(PWM_T *pwm, uint32_t u32ChannelNum, PWM_ClkDivDef Divider)
This function set the divider of the selected channel.
Definition: pan_pwm.h:507
__STATIC_INLINE void PWM_EnableCMPUInt(PWM_T *pwm, uint32_t u32ChannelNum)
This function enable Compare_Up interrupt of selected channel.
Definition: pan_pwm.h:307
__STATIC_INLINE void PWM_DisableAsymmetricMode(PWM_T *pwm)
This function disables PWM asymmetric mode.
Definition: pan_pwm.h:580
__STATIC_INLINE uint32_t PWM_GetPeriodIntFlag(PWM_T *pwm, uint32_t u32ChannelNum)
This function get Period interrupt flag of selected channel.
Definition: pan_pwm.h:248
__STATIC_INLINE void PWM_EnableCMPDInt(PWM_T *pwm, uint32_t u32ChannelNum)
This function enable Compare_Down interrupt of selected channel.
Definition: pan_pwm.h:167
__STATIC_INLINE void PWM_DisableZeroInt(PWM_T *pwm, uint32_t u32ChannelNum)
This function disable Zero interrupt of selected channel.
Definition: pan_pwm.h:272
__STATIC_INLINE void PWM_ClearCenterIntFlag(PWM_T *pwm, uint32_t u32ChannelNum)
This function clear Central interrupt of selected channel.
Definition: pan_pwm.h:381
__STATIC_INLINE void PWM_SetCntMode(PWM_T *pwm, uint32_t u32ChannelNum, PWM_CntModeDef CntMode)
This function set the CntMode of the selected channel.
Definition: pan_pwm.h:612
__STATIC_INLINE void PWM_EnablePCA(PWM_T *pwm)
This function enables PWM Precise Center-Aligned Type.
Definition: pan_pwm.h:590
__STATIC_INLINE uint32_t PWM_GetCenterIntFlag(PWM_T *pwm, uint32_t u32ChannelNum)
This function get Central interrupt of selected channel.
Definition: pan_pwm.h:394
__STATIC_INLINE void PWM_ClearPeriodIntFlag(PWM_T *pwm, uint32_t u32ChannelNum)
This function clears Period interrupt flag of selected channel.
Definition: pan_pwm.h:235
__STATIC_INLINE void PWM_EnableDeadZone(PWM_T *pwm, uint32_t u32ChannelNum, uint32_t u32Duration)
This function enable Dead zone of selected channel.
Definition: pan_pwm.h:137
__STATIC_INLINE void PWM_DisableCenterInt(PWM_T *pwm, uint32_t u32ChannelNum)
This function disable Central interrupt of selected channel.
Definition: pan_pwm.h:370
__STATIC_INLINE void PWM_EnableCenterInt(PWM_T *pwm, uint32_t u32ChannelNum, PWM_IntPeriodTypeDef IntPeriodType)
This function enable Central interrupt of selected channel.
Definition: pan_pwm.h:357
uint32_t PWM_ConfigOutputChannel(PWM_T *pwm, uint32_t u32ChannelNum, uint32_t u32Frequency, uint32_t u32DutyCycle, PWM_OperateTypeDef OperateType)
This function config PWM generator and get the nearest frequency in edge aligned auto-reload mode.
__STATIC_INLINE void PWM_EnableIndependentMode(PWM_T *pwm)
This function enable independent mode.
Definition: pan_pwm.h:404
__STATIC_INLINE void PWM_DisableComplementaryMode(PWM_T *pwm)
This function disable complementary mode, and enable independent mode.
Definition: pan_pwm.h:423
__STATIC_INLINE void PWM_ResetPrescaler(PWM_T *pwm, uint32_t u32ChannelNum)
This function reset the prescaler of the selected channel.
Definition: pan_pwm.h:490
__STATIC_INLINE void PWM_ClearCMPUIntFlag(PWM_T *pwm, uint32_t u32ChannelNum)
This function clears Compare_Up interrupt flag of selected channel.
Definition: pan_pwm.h:329
__STATIC_INLINE void PWM_DisableSyncMode(PWM_T *pwm)
This function disable synchronous mode, and enable independent mode.
Definition: pan_pwm.h:463
__STATIC_INLINE void PWM_DisablePCA(PWM_T *pwm)
This function disables PWM Precise Center-Aligned Type.
Definition: pan_pwm.h:600
void PWM_DisableOutputInverter(PWM_T *pwm, uint32_t u32ChannelMask)
This function disable output inverter of specified channel(s)
__STATIC_INLINE void PWM_EnableOutput(PWM_T *pwm, uint32_t u32ChannelMask)
This function enables PWM output generation of selected channels.
Definition: pan_pwm.h:112
void PWM_Start(PWM_T *pwm, uint32_t u32ChannelMask)
This function start PWM module.
__STATIC_INLINE void PWM_DisableCMPDInt(PWM_T *pwm, uint32_t u32ChannelNum)
This function disable Compare_Down interrupt of selected channel.
Definition: pan_pwm.h:178
__STATIC_INLINE void PWM_DisableDeadZone(PWM_T *pwm, uint32_t u32ChannelNum)
This function disable Dead zone of selected channel.
Definition: pan_pwm.h:153
__STATIC_INLINE void PWM_DisableGroupMode(PWM_T *pwm)
This function disable group mode.
Definition: pan_pwm.h:443
__STATIC_INLINE uint32_t PWM_GetZeroIntFlag(PWM_T *pwm, uint32_t u32ChannelNum)
This function get Zero interrupt flag of selected channel.
Definition: pan_pwm.h:296
__STATIC_INLINE void PWM_EnablePeriodInt(PWM_T *pwm, uint32_t u32ChannelNum)
This function enable Period interrupt of selected channel.
Definition: pan_pwm.h:213
__STATIC_INLINE void PWM_SetAlignedType(PWM_T *pwm, uint32_t u32ChannelMask, PWM_AlignedTypeDef AlignedType)
This function set the PWM aligned type.
Definition: pan_pwm.h:560
__STATIC_INLINE void PWM_DisablePeriodInt(PWM_T *pwm, uint32_t u32ChannelNum)
This function disable Period interrupt of selected channel.
Definition: pan_pwm.h:224
__STATIC_INLINE void PWM_EnableAsymmetricMode(PWM_T *pwm)
This function enables PWM asymmetric mode.
Definition: pan_pwm.h:570
__STATIC_INLINE void PWM_EnableSyncMode(PWM_T *pwm)
This function enable synchronous mode.
Definition: pan_pwm.h:453
__STATIC_INLINE void PWM_EnableZeroInt(PWM_T *pwm, uint32_t u32ChannelNum)
This function enable Zero interrupt of selected channel.
Definition: pan_pwm.h:261
__STATIC_INLINE void PWM_EnableGroupMode(PWM_T *pwm)
This function enable group mode.
Definition: pan_pwm.h:433