| NUC472_NUC442_BSP V3.04.000 The Board Support Package for NUC472/NUC442

epwm.h
Go to the documentation of this file.
1/**************************************************************************/
12#ifndef __EPWM_H__
13#define __EPWM_H__
14
15#ifdef __cplusplus
16extern "C"
17{
18#endif
19
20
32#define EPWM_CHANNEL_NUM (6)
33#define EPWM_CH0 (0UL)
34#define EPWM_CH1 (1UL)
35#define EPWM_CH2 (2UL)
36#define EPWM_CH3 (3UL)
37#define EPWM_CH4 (4UL)
38#define EPWM_CH5 (5UL)
39#define EPWM_CH_0_MASK (1UL)
40#define EPWM_CH_1_MASK (2UL)
41#define EPWM_CH_2_MASK (4UL)
42#define EPWM_CH_3_MASK (8UL)
43#define EPWM_CH_4_MASK (16UL)
44#define EPWM_CH_5_MASK (32UL)
45#define EPWM_CH_6_MASK (64UL)
46#define EPWM_CLK_DIV_1 (0UL)
47#define EPWM_CLK_DIV_2 (1UL)
48#define EPWM_CLK_DIV_4 (2UL)
49#define EPWM_CLK_DIV_16 (3UL)
50#define EPWM_EDGE_ALIGNED (0UL)
51#define EPWM_CENTER_ALIGNED (EPWM_CTL_CNTTYPE_Msk)
52#define EPWM_BRK0_BKP0 (EPWM_CTL_BRKP0EN_Msk)
53#define EPWM_BRK0_CPO0 (EPWM_CTL_CPO0BKEN_Msk)
54#define EPWM_BRK0_CPO1 (EPWM_CTL_CPO1BKEN_Msk)
55#define EPWM_BRK0_CPO2 (EPWM_CTL_CPO2BKEN_Msk)
56#define EPWM_BRK1_LVDBKEN (EPWM_CTL_LVDBKEN_Msk)
57#define EPWM_BK1SEL_BKP1 (0UL << EPWM_CTL_BRK1SEL_Pos)
58#define EPWM_BK1SEL_CPO0 (1UL << EPWM_CTL_BRK1SEL_Pos)
59#define EPWM_BK1SEL_CPO1 (2UL << EPWM_CTL_BRK1SEL_Pos)
60#define EPWM_BK1SEL_CPO2 (3UL << EPWM_CTL_BRK1SEL_Pos)
61#define EPWM_PERIOD_INT_UNDERFLOW (0)
62#define EPWM_PERIOD_INT_MATCH_CNR (EPWM_CTL_INTTYPE_Msk)
63#define EPWM_MODE_INDEPENDENT (0UL)
64#define EPWM_MODE_COMPLEMENTARY (1UL)
65#define EPWM_MODE_SYNCHRONIZED (2UL) /* end of group NUC472_442_EPWM_EXPORTED_CONSTANTS */
68
69
80#define EPWM_ENABLE_COMPLEMENTARY_MODE(pwm) ((pwm)->CTL = ((pwm)->CTL & ~EPWM_CTL_MODE_Msk) | (EPWM_MODE_COMPLEMENTARY << EPWM_CTL_MODE_Pos))
81
88#define EPWM_DISABLE_COMPLEMENTARY_MODE(pwm) ((pwm)->CTL &= ~EPWM_CTL_MODE_Msk)
89
96#define EPWM_ENABLE_GROUP_MODE(pwm) ((pwm)->CTL |= EPWM_CTL_GROUPEN_Msk)
97
104#define EPWM_DISABLE_GROUP_MODE(pwm) ((pwm)->CTL &= ~EPWM_CTL_GROUPEN_Msk)
105
112#define EPWM_ENABLE_SYNC_MODE(pwm) ((pwm)->CTL = ((pwm)->CTL & ~EPWM_CTL_MODE_Msk) | (EPWM_MODE_SYNCHRONIZED << EPWM_CTL_MODE_Pos))
113
120#define EPWM_DISABLE_SYNC_MODE(pwm) ((pwm)->CTL = ((pwm)->CTL & ~EPWM_CTL_MODE_Msk))
121
130#define EPWM_ENABLE_OUTPUT_INVERTER(pwm, u32ChannelMask) \
131do { \
132 if ((u32ChannelMask)) \
133 ((pwm)->CTL |= EPWM_CTL_PINV_Msk); \
134 else \
135 ((pwm)->CTL &= ~EPWM_CTL_PINV_Msk); \
136}while(0)
137
147#define EPWM_MASK_OUTPUT(pwm, u32ChannelMask, u32LevelMask) \
148do { \
149 (pwm)->MSKEN = u32ChannelMask; \
150 (pwm)->MSK = u32LevelMask; \
151}while(0)
152
165#define EPWM_SET_DIVIDER(pwm, u32ChannelNum, u32Divider) \
166 ((pwm)->CTL = ((pwm)->CTL & ~EPWM_CTL_CLKDIV_Msk) | ((u32Divider) << EPWM_CTL_CLKDIV_Pos))
167
177#define EPWM_SET_CMR(pwm, u32ChannelNum, u32CMR) \
178do { \
179 (pwm)->CMPDAT[(u32ChannelNum) >> 1] = (u32CMR); \
180 (pwm)->CTL |= EPWM_CTL_LOAD_Msk; \
181}while(0)
182
193#define EPWM_SET_CNR(pwm, u32ChannelNum, u32CNR) \
194do { \
195 (pwm)->PERIOD = (u32CNR); \
196 (pwm)->CTL |= EPWM_CTL_LOAD_Msk; \
197}while(0)
198
209#define EPWM_SET_ALIGNED_TYPE(pwm, u32ChannelMask, u32AlignedType) \
210 ((pwm)->CTL = ((pwm)->CTL & ~EPWM_CTL_CNTTYPE_Msk) | (u32AlignedType))
211
212
213uint32_t EPWM_ConfigOutputChannel(EPWM_T *pwm,
214 uint32_t u32ChannelNum,
215 uint32_t u32Frequency,
216 uint32_t u32DutyCycle);
217void EPWM_Start (EPWM_T *pwm, uint32_t u32ChannelMask);
218void EPWM_Stop(EPWM_T *pwm, uint32_t u32ChannelMask);
219void EPWM_ForceStop(EPWM_T *pwm, uint32_t u32ChannelMask);
220void EPWM_EnableFaultBrake(EPWM_T *pwm,
221 uint32_t u32ChannelMask,
222 uint32_t u32LevelMask,
223 uint32_t u32BrakeSource);
224void EPWM_ClearFaultBrakeFlag(EPWM_T *pwm, uint32_t u32BrakeSource);
225void EPWM_EnableOutput(EPWM_T *pwm, uint32_t u32ChannelMask);
226void EPWM_DisableOutput(EPWM_T *pwm, uint32_t u32ChannelMask);
227void EPWM_EnableDeadZone(EPWM_T *pwm, uint32_t u32ChannelNum, uint32_t u32Duration);
228void EPWM_DisableDeadZone(EPWM_T *pwm, uint32_t u32ChannelNum);
229void EPWM_EnableDutyInt(EPWM_T *pwm, uint32_t u32ChannelNum, uint32_t u32IntDutyType);
230void EPWM_DisableDutyInt(EPWM_T *pwm, uint32_t u32ChannelNum);
231void EPWM_ClearDutyIntFlag(EPWM_T *pwm, uint32_t u32ChannelNum);
232uint32_t EPWM_GetDutyIntFlag(EPWM_T *pwm, uint32_t u32ChannelNum);
233void EPWM_EnableFaultBrakeInt(EPWM_T *pwm, uint32_t u32BrakeSource);
234void EPWM_DisableFaultBrakeInt(EPWM_T *pwm, uint32_t u32BrakeSource);
235void EPWM_ClearFaultBrakeIntFlag(EPWM_T *pwm, uint32_t u32BrakeSource);
236uint32_t EPWM_GetFaultBrakeIntFlag(EPWM_T *pwm, uint32_t u32BrakeSource);
237void EPWM_EnablePeriodInt(EPWM_T *pwm, uint32_t u32ChannelNum, uint32_t u32IntPeriodType);
238void EPWM_DisablePeriodInt(EPWM_T *pwm, uint32_t u32ChannelNum);
239void EPWM_ClearPeriodIntFlag(EPWM_T *pwm, uint32_t u32ChannelNum);
240uint32_t EPWM_GetPeriodIntFlag(EPWM_T *pwm, uint32_t u32ChannelNum);
241
242
243 /* end of group NUC472_442_EPWM_EXPORTED_FUNCTIONS */
245 /* end of group NUC472_442_EPWM_Driver */
247 /* end of group NUC472_442_Device_Driver */
249
250#ifdef __cplusplus
251}
252#endif
253
254#endif //__EPWM_H__
255
256/*** (C) COPYRIGHT 2013 Nuvoton Technology Corp. ***/
EPWM_GetPeriodIntFlag
uint32_t EPWM_GetPeriodIntFlag(EPWM_T *pwm, uint32_t u32ChannelNum)
This function get period interrupt of selected channel.
Definition: epwm.c:394
EPWM_DisableDutyInt
void EPWM_DisableDutyInt(EPWM_T *pwm, uint32_t u32ChannelNum)
This function disable duty interrupt of selected channel.
Definition: epwm.c:265
EPWM_GetDutyIntFlag
uint32_t EPWM_GetDutyIntFlag(EPWM_T *pwm, uint32_t u32ChannelNum)
This function get duty interrupt flag of selected channel.
Definition: epwm.c:294
EPWM_DisableFaultBrakeInt
void EPWM_DisableFaultBrakeInt(EPWM_T *pwm, uint32_t u32BrakeSource)
This function disable fault brake interrupt.
Definition: epwm.c:316
EPWM_Stop
void EPWM_Stop(EPWM_T *pwm, uint32_t u32ChannelMask)
This function stop PWM module.
Definition: epwm.c:116
EPWM_DisableDeadZone
void EPWM_DisableDeadZone(EPWM_T *pwm, uint32_t u32ChannelNum)
This function disable Dead zone of selected channel.
Definition: epwm.c:234
EPWM_DisableOutput
void EPWM_DisableOutput(EPWM_T *pwm, uint32_t u32ChannelMask)
This function disables PWM output generation of selected channels.
Definition: epwm.c:202
EPWM_ClearDutyIntFlag
void EPWM_ClearDutyIntFlag(EPWM_T *pwm, uint32_t u32ChannelNum)
This function clears duty interrupt flag of selected channel.
Definition: epwm.c:278
EPWM_DisablePeriodInt
void EPWM_DisablePeriodInt(EPWM_T *pwm, uint32_t u32ChannelNum)
This function disable period interrupt of selected channel.
Definition: epwm.c:369
EPWM_EnableFaultBrake
void EPWM_EnableFaultBrake(EPWM_T *pwm, uint32_t u32ChannelMask, uint32_t u32LevelMask, uint32_t u32BrakeSource)
This function enable fault brake of selected channels.
Definition: epwm.c:152
EPWM_ForceStop
void EPWM_ForceStop(EPWM_T *pwm, uint32_t u32ChannelMask)
This function stop PWM generation immediately by clear channel enable bit.
Definition: epwm.c:128
EPWM_ClearFaultBrakeFlag
void EPWM_ClearFaultBrakeFlag(EPWM_T *pwm, uint32_t u32BrakeSource)
This function clear fault brake flag.
Definition: epwm.c:174
EPWM_EnableFaultBrakeInt
void EPWM_EnableFaultBrakeInt(EPWM_T *pwm, uint32_t u32BrakeSource)
This function enable fault brake interrupt.
Definition: epwm.c:305
EPWM_Start
void EPWM_Start(EPWM_T *pwm, uint32_t u32ChannelMask)
This function start PWM module.
Definition: epwm.c:104
EPWM_EnablePeriodInt
void EPWM_EnablePeriodInt(EPWM_T *pwm, uint32_t u32ChannelNum, uint32_t u32IntPeriodType)
This function enable period interrupt of selected channel.
Definition: epwm.c:357
EPWM_EnableOutput
void EPWM_EnableOutput(EPWM_T *pwm, uint32_t u32ChannelMask)
This function enables PWM output generation of selected channels.
Definition: epwm.c:187
EPWM_EnableDutyInt
void EPWM_EnableDutyInt(EPWM_T *pwm, uint32_t u32ChannelNum, uint32_t u32IntDutyType)
This function enable duty interrupt of selected channel.
Definition: epwm.c:249
EPWM_EnableDeadZone
void EPWM_EnableDeadZone(EPWM_T *pwm, uint32_t u32ChannelNum, uint32_t u32Duration)
This function enable Dead zone of selected channel.
Definition: epwm.c:218
EPWM_ClearFaultBrakeIntFlag
void EPWM_ClearFaultBrakeIntFlag(EPWM_T *pwm, uint32_t u32BrakeSource)
This function clear fault brake interrupt of selected source.
Definition: epwm.c:329
EPWM_ClearPeriodIntFlag
void EPWM_ClearPeriodIntFlag(EPWM_T *pwm, uint32_t u32ChannelNum)
This function clear period interrupt of selected channel.
Definition: epwm.c:380
EPWM_ConfigOutputChannel
uint32_t EPWM_ConfigOutputChannel(EPWM_T *pwm, uint32_t u32ChannelNum, uint32_t u32Frequency, uint32_t u32DutyCycle)
This function config PWM generator and get the nearest frequency in edge aligned auto-reload mode.
Definition: epwm.c:35
EPWM_GetFaultBrakeIntFlag
uint32_t EPWM_GetFaultBrakeIntFlag(EPWM_T *pwm, uint32_t u32BrakeSource)
This function get fault brake interrupt of selected source.
Definition: epwm.c:344
EPWM_T
Definition: NUC472_442.h:13932