epwm.h 41 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620
  1. /**************************************************************************//**
  2. * @file epwm.h
  3. * @version V3.00
  4. * @brief M480 series EPWM driver header file
  5. *
  6. * @copyright (C) 2016 Nuvoton Technology Corp. All rights reserved.
  7. *****************************************************************************/
  8. #ifndef __EPWM_H__
  9. #define __EPWM_H__
  10. #ifdef __cplusplus
  11. extern "C"
  12. {
  13. #endif
  14. /** @addtogroup Standard_Driver Standard Driver
  15. @{
  16. */
  17. /** @addtogroup EPWM_Driver EPWM Driver
  18. @{
  19. */
  20. /** @addtogroup EPWM_EXPORTED_CONSTANTS EPWM Exported Constants
  21. @{
  22. */
  23. #define EPWM_CHANNEL_NUM (6U) /*!< EPWM channel number \hideinitializer */
  24. #define EPWM_CH_0_MASK (0x1U) /*!< EPWM channel 0 mask \hideinitializer */
  25. #define EPWM_CH_1_MASK (0x2U) /*!< EPWM channel 1 mask \hideinitializer */
  26. #define EPWM_CH_2_MASK (0x4U) /*!< EPWM channel 2 mask \hideinitializer */
  27. #define EPWM_CH_3_MASK (0x8U) /*!< EPWM channel 3 mask \hideinitializer */
  28. #define EPWM_CH_4_MASK (0x10U) /*!< EPWM channel 4 mask \hideinitializer */
  29. #define EPWM_CH_5_MASK (0x20U) /*!< EPWM channel 5 mask \hideinitializer */
  30. /*---------------------------------------------------------------------------------------------------------*/
  31. /* Counter Type Constant Definitions */
  32. /*---------------------------------------------------------------------------------------------------------*/
  33. #define EPWM_UP_COUNTER (0U) /*!< Up counter type \hideinitializer */
  34. #define EPWM_DOWN_COUNTER (1U) /*!< Down counter type \hideinitializer */
  35. #define EPWM_UP_DOWN_COUNTER (2U) /*!< Up-Down counter type \hideinitializer */
  36. /*---------------------------------------------------------------------------------------------------------*/
  37. /* Aligned Type Constant Definitions */
  38. /*---------------------------------------------------------------------------------------------------------*/
  39. #define EPWM_EDGE_ALIGNED (1U) /*!< EPWM working in edge aligned type(down count) \hideinitializer */
  40. #define EPWM_CENTER_ALIGNED (2U) /*!< EPWM working in center aligned type \hideinitializer */
  41. /*---------------------------------------------------------------------------------------------------------*/
  42. /* Output Level Constant Definitions */
  43. /*---------------------------------------------------------------------------------------------------------*/
  44. #define EPWM_OUTPUT_NOTHING (0U) /*!< EPWM output nothing \hideinitializer */
  45. #define EPWM_OUTPUT_LOW (1U) /*!< EPWM output low \hideinitializer */
  46. #define EPWM_OUTPUT_HIGH (2U) /*!< EPWM output high \hideinitializer */
  47. #define EPWM_OUTPUT_TOGGLE (3U) /*!< EPWM output toggle \hideinitializer */
  48. /*---------------------------------------------------------------------------------------------------------*/
  49. /* Synchronous Start Function Control Constant Definitions */
  50. /*---------------------------------------------------------------------------------------------------------*/
  51. #define EPWM_SSCTL_SSRC_EPWM0 (0U<<EPWM_SSCTL_SSRC_Pos) /*!< Synchronous start source comes from EPWM0 \hideinitializer */
  52. #define EPWM_SSCTL_SSRC_EPWM1 (1U<<EPWM_SSCTL_SSRC_Pos) /*!< Synchronous start source comes from EPWM0 \hideinitializer */
  53. #define EPWM_SSCTL_SSRC_BPWM0 (2UL<<EPWM_SSCTL_SSRC_Pos) /*!< Synchronous start source comes from BPWM0 \hideinitializer */
  54. #define EPWM_SSCTL_SSRC_BPWM1 (3UL<<EPWM_SSCTL_SSRC_Pos) /*!< Synchronous start source comes from BPWM1 \hideinitializer */
  55. /*---------------------------------------------------------------------------------------------------------*/
  56. /* Trigger Source Select Constant Definitions */
  57. /*---------------------------------------------------------------------------------------------------------*/
  58. #define EPWM_TRG_ADC_EVEN_ZERO (0U) /*!< EPWM trigger ADC while counter of even channel matches zero point \hideinitializer */
  59. #define EPWM_TRG_ADC_EVEN_PERIOD (1U) /*!< EPWM trigger ADC while counter of even channel matches period point \hideinitializer */
  60. #define EPWM_TRG_ADC_EVEN_ZERO_PERIOD (2U) /*!< EPWM trigger ADC while counter of even channel matches zero or period point \hideinitializer */
  61. #define EPWM_TRG_ADC_EVEN_COMPARE_UP (3U) /*!< EPWM trigger ADC while counter of even channel matches up count to comparator point \hideinitializer */
  62. #define EPWM_TRG_ADC_EVEN_COMPARE_DOWN (4U) /*!< EPWM trigger ADC while counter of even channel matches down count to comparator point \hideinitializer */
  63. #define EPWM_TRG_ADC_ODD_ZERO (5U) /*!< EPWM trigger ADC while counter of odd channel matches zero point \hideinitializer */
  64. #define EPWM_TRG_ADC_ODD_PERIOD (6U) /*!< EPWM trigger ADC while counter of odd channel matches period point \hideinitializer */
  65. #define EPWM_TRG_ADC_ODD_ZERO_PERIOD (7U) /*!< EPWM trigger ADC while counter of odd channel matches zero or period point \hideinitializer */
  66. #define EPWM_TRG_ADC_ODD_COMPARE_UP (8U) /*!< EPWM trigger ADC while counter of odd channel matches up count to comparator point \hideinitializer */
  67. #define EPWM_TRG_ADC_ODD_COMPARE_DOWN (9U) /*!< EPWM trigger ADC while counter of odd channel matches down count to comparator point \hideinitializer */
  68. #define EPWM_TRG_ADC_CH_0_FREE_CMP_UP (10U) /*!< EPWM trigger ADC while counter of channel 0 matches up count to free comparator point \hideinitializer */
  69. #define EPWM_TRG_ADC_CH_0_FREE_CMP_DOWN (11U) /*!< EPWM trigger ADC while counter of channel 0 matches down count to free comparator point \hideinitializer */
  70. #define EPWM_TRG_ADC_CH_2_FREE_CMP_UP (12U) /*!< EPWM trigger ADC while counter of channel 2 matches up count to free comparator point \hideinitializer */
  71. #define EPWM_TRG_ADC_CH_2_FREE_CMP_DOWN (13U) /*!< EPWM trigger ADC while counter of channel 2 matches down count to free comparator point \hideinitializer */
  72. #define EPWM_TRG_ADC_CH_4_FREE_CMP_UP (14U) /*!< EPWM trigger ADC while counter of channel 4 matches up count to free comparator point \hideinitializer */
  73. #define EPWM_TRG_ADC_CH_4_FREE_CMP_DOWN (15U) /*!< EPWM trigger ADC while counter of channel 4 matches down count to free comparator point \hideinitializer */
  74. #define EPWM_TRIGGER_DAC_ZERO (0x1U) /*!< EPWM trigger DAC while counter down count to 0 \hideinitializer */
  75. #define EPWM_TRIGGER_DAC_PERIOD (0x100U) /*!< EPWM trigger DAC while counter matches (PERIOD + 1) \hideinitializer */
  76. #define EPWM_TRIGGER_DAC_COMPARE_UP (0x10000U) /*!< EPWM trigger DAC while counter up count to CMPDAT \hideinitializer */
  77. #define EPWM_TRIGGER_DAC_COMPARE_DOWN (0x1000000U) /*!< EPWM trigger DAC while counter down count to CMPDAT \hideinitializer */
  78. /*---------------------------------------------------------------------------------------------------------*/
  79. /* Fail brake Control Constant Definitions */
  80. /*---------------------------------------------------------------------------------------------------------*/
  81. #define EPWM_FB_EDGE_ACMP0 (EPWM_BRKCTL0_1_CPO0EBEN_Msk) /*!< Comparator 0 as edge-detect fault brake source \hideinitializer */
  82. #define EPWM_FB_EDGE_ACMP1 (EPWM_BRKCTL0_1_CPO1EBEN_Msk) /*!< Comparator 1 as edge-detect fault brake source \hideinitializer */
  83. #define EPWM_FB_EDGE_BKP0 (EPWM_BRKCTL0_1_BRKP0EEN_Msk) /*!< BKP0 pin as edge-detect fault brake source \hideinitializer */
  84. #define EPWM_FB_EDGE_BKP1 (EPWM_BRKCTL0_1_BRKP1EEN_Msk) /*!< BKP1 pin as edge-detect fault brake source \hideinitializer */
  85. #define EPWM_FB_EDGE_ADCRM (EPWM_BRKCTL0_1_ADCEBEN_Msk) /*!< ADC Result Monitor (ADCRM) as edge-detect fault brake source \hideinitializer */
  86. #define EPWM_FB_EDGE_SYS_CSS (EPWM_BRKCTL0_1_SYSEBEN_Msk | EPWM_FAILBRK_CSSBRKEN_Msk) /*!< System fail condition: clock security system detection as edge-detect fault brake source \hideinitializer */
  87. #define EPWM_FB_EDGE_SYS_BOD (EPWM_BRKCTL0_1_SYSEBEN_Msk | EPWM_FAILBRK_BODBRKEN_Msk) /*!< System fail condition: brown-out detection as edge-detect fault brake source \hideinitializer */
  88. #define EPWM_FB_EDGE_SYS_RAM (EPWM_BRKCTL0_1_SYSEBEN_Msk | EPWM_FAILBRK_RAMBRKEN_Msk) /*!< System fail condition: SRAM parity error detection as edge-detect fault brake source \hideinitializer */
  89. #define EPWM_FB_EDGE_SYS_COR (EPWM_BRKCTL0_1_SYSEBEN_Msk | EPWM_FAILBRK_CORBRKEN_Msk) /*!< System fail condition: core lockup detection as edge-detect fault brake source \hideinitializer */
  90. #define EPWM_FB_LEVEL_ACMP0 (EPWM_BRKCTL0_1_CPO0LBEN_Msk) /*!< Comparator 0 as level-detect fault brake source \hideinitializer */
  91. #define EPWM_FB_LEVEL_ACMP1 (EPWM_BRKCTL0_1_CPO1LBEN_Msk) /*!< Comparator 1 as level-detect fault brake source \hideinitializer */
  92. #define EPWM_FB_LEVEL_BKP0 (EPWM_BRKCTL0_1_BRKP0LEN_Msk) /*!< BKP0 pin as level-detect fault brake source \hideinitializer */
  93. #define EPWM_FB_LEVEL_BKP1 (EPWM_BRKCTL0_1_BRKP1LEN_Msk) /*!< BKP1 pin as level-detect fault brake source \hideinitializer */
  94. #define EPWM_FB_LEVEL_ADCRM (EPWM_BRKCTL0_1_ADCLBEN_Msk) /*!< ADC Result Monitor (ADCRM) as level-detect fault brake source \hideinitializer */
  95. #define EPWM_FB_LEVEL_SYS_CSS (EPWM_BRKCTL0_1_SYSLBEN_Msk | EPWM_FAILBRK_CSSBRKEN_Msk) /*!< System fail condition: clock security system detection as level-detect fault brake source \hideinitializer */
  96. #define EPWM_FB_LEVEL_SYS_BOD (EPWM_BRKCTL0_1_SYSLBEN_Msk | EPWM_FAILBRK_BODBRKEN_Msk) /*!< System fail condition: brown-out detection as level-detect fault brake source \hideinitializer */
  97. #define EPWM_FB_LEVEL_SYS_RAM (EPWM_BRKCTL0_1_SYSLBEN_Msk | EPWM_FAILBRK_RAMBRKEN_Msk) /*!< System fail condition: SRAM parity error detection as level-detect fault brake source \hideinitializer */
  98. #define EPWM_FB_LEVEL_SYS_COR (EPWM_BRKCTL0_1_SYSLBEN_Msk | EPWM_FAILBRK_CORBRKEN_Msk) /*!< System fail condition: core lockup detection as level-detect fault brake source \hideinitializer */
  99. #define EPWM_FB_EDGE (0U) /*!< edge-detect fault brake \hideinitializer */
  100. #define EPWM_FB_LEVEL (8U) /*!< level-detect fault brake \hideinitializer */
  101. /*---------------------------------------------------------------------------------------------------------*/
  102. /* Leading Edge Blanking Control Constant Definitions */
  103. /*---------------------------------------------------------------------------------------------------------*/
  104. #define EPWM_LEBCTL_TRGTYPE_RISING (0U<<EPWM_LEBCTL_TRGTYPE_Pos) /*!< EPWM Leading Edge Blanking Trigger Type Is Rising Edge \hideinitializer */
  105. #define EPWM_LEBCTL_TRGTYPE_FALLING (1U<<EPWM_LEBCTL_TRGTYPE_Pos) /*!< EPWM Leading Edge Blanking Trigger Type Is Falling Edge \hideinitializer */
  106. #define EPWM_LEBCTL_TRGTYPE_RISING_OR_FALLING (2U<<EPWM_LEBCTL_TRGTYPE_Pos) /*!< EPWM Leading Edge Blanking Trigger Type Is Rising or Falling Edge \hideinitializer */
  107. #define EPWM_LEBCTL_SRCEN0 (EPWM_LEBCTL_SRCEN0_Msk) /*!< EPWM Leading Edge Blanking Source From EPWMx_CH0 Enable \hideinitializer */
  108. #define EPWM_LEBCTL_SRCEN2 (EPWM_LEBCTL_SRCEN2_Msk) /*!< EPWM Leading Edge Blanking Source From EPWMx_CH2 Enable \hideinitializer */
  109. #define EPWM_LEBCTL_SRCEN4 (EPWM_LEBCTL_SRCEN4_Msk) /*!< EPWM Leading Edge Blanking Source From EPWMx_CH4 Enable \hideinitializer */
  110. #define EPWM_LEBCTL_SRCEN0_2 (EPWM_LEBCTL_SRCEN0_Msk|EPWM_LEBCTL_SRCEN2_Msk) /*!< EPWM Leading Edge Blanking Source From EPWMx_CH0 and EPWMx_CH2 Enable \hideinitializer */
  111. #define EPWM_LEBCTL_SRCEN0_4 (EPWM_LEBCTL_SRCEN0_Msk|EPWM_LEBCTL_SRCEN4_Msk) /*!< EPWM Leading Edge Blanking Source From EPWMx_CH0 and EPWMx_CH4 Enable \hideinitializer */
  112. #define EPWM_LEBCTL_SRCEN2_4 (EPWM_LEBCTL_SRCEN2_Msk|EPWM_LEBCTL_SRCEN4_Msk) /*!< EPWM Leading Edge Blanking Source From EPWMx_CH2 and EPWMx_CH4 Enable \hideinitializer */
  113. #define EPWM_LEBCTL_SRCEN0_2_4 (EPWM_LEBCTL_SRCEN0_Msk|EPWM_LEBCTL_SRCEN2_Msk|EPWM_LEBCTL_SRCEN4_Msk) /*!< EPWM Leading Edge Blanking Source From EPWMx_CH0, EPWMx_CH2 and EPWMx_CH4 Enable \hideinitializer */
  114. /*---------------------------------------------------------------------------------------------------------*/
  115. /* Capture Control Constant Definitions */
  116. /*---------------------------------------------------------------------------------------------------------*/
  117. #define EPWM_CAPTURE_INT_RISING_LATCH (1U) /*!< EPWM capture interrupt if channel has rising transition \hideinitializer */
  118. #define EPWM_CAPTURE_INT_FALLING_LATCH (0x100U) /*!< EPWM capture interrupt if channel has falling transition \hideinitializer */
  119. #define EPWM_CAPTURE_PDMA_RISING_LATCH (0x2U) /*!< EPWM capture rising latched data transfer by PDMA \hideinitializer */
  120. #define EPWM_CAPTURE_PDMA_FALLING_LATCH (0x4U) /*!< EPWM capture falling latched data transfer by PDMA \hideinitializer */
  121. #define EPWM_CAPTURE_PDMA_RISING_FALLING_LATCH (0x6U) /*!< EPWM capture rising and falling latched data transfer by PDMA \hideinitializer */
  122. /*---------------------------------------------------------------------------------------------------------*/
  123. /* Duty Interrupt Type Constant Definitions */
  124. /*---------------------------------------------------------------------------------------------------------*/
  125. #define EPWM_DUTY_INT_DOWN_COUNT_MATCH_CMP (1U << EPWM_INTEN0_CMPDIEN0_Pos) /*!< EPWM duty interrupt triggered if down count match comparator \hideinitializer */
  126. #define EPWM_DUTY_INT_UP_COUNT_MATCH_CMP (1U << EPWM_INTEN0_CMPUIEN0_Pos) /*!< EPWM duty interrupt triggered if up down match comparator \hideinitializer */
  127. /*---------------------------------------------------------------------------------------------------------*/
  128. /* Interrupt Flag Accumulator Constant Definitions */
  129. /*---------------------------------------------------------------------------------------------------------*/
  130. #define EPWM_IFA_ZERO_POINT (0U) /*!< EPWM counter equal to zero \hideinitializer */
  131. #define EPWM_IFA_PERIOD_POINT (1U) /*!< EPWM counter equal to period \hideinitializer */
  132. #define EPWM_IFA_COMPARE_UP_COUNT_POINT (2U) /*!< EPWM counter up count to comparator value \hideinitializer */
  133. #define EPWM_IFA_COMPARE_DOWN_COUNT_POINT (3U) /*!< EPWM counter down count to comparator value \hideinitializer */
  134. /*---------------------------------------------------------------------------------------------------------*/
  135. /* Load Mode Constant Definitions */
  136. /*---------------------------------------------------------------------------------------------------------*/
  137. #define EPWM_LOAD_MODE_IMMEDIATE (1U << EPWM_CTL0_IMMLDEN0_Pos) /*!< EPWM immediately load mode \hideinitializer */
  138. #define EPWM_LOAD_MODE_WINDOW (1U << EPWM_CTL0_WINLDEN0_Pos) /*!< EPWM window load mode \hideinitializer */
  139. #define EPWM_LOAD_MODE_CENTER (1U << EPWM_CTL0_CTRLD0_Pos) /*!< EPWM center load mode \hideinitializer */
  140. /*---------------------------------------------------------------------------------------------------------*/
  141. /* Synchronize Control Constant Definitions */
  142. /*---------------------------------------------------------------------------------------------------------*/
  143. #define EPWM_SYNC_OUT_FROM_SYNCIN_SWSYNC (0U) /*!< Synchronize source from SYNC_IN or SWSYNC \hideinitializer */
  144. #define EPWM_SYNC_OUT_FROM_COUNT_TO_ZERO (1U) /*!< Synchronize source from counter equal to 0 \hideinitializer */
  145. #define EPWM_SYNC_OUT_FROM_COUNT_TO_COMPARATOR (2U) /*!< Synchronize source from counter equal to CMPDAT1, CMPDAT3, CMPDAT5 \hideinitializer */
  146. #define EPWM_SYNC_OUT_DISABLE (3U) /*!< SYNC_OUT will not be generated \hideinitializer */
  147. #define EPWM_PHS_DIR_DECREMENT (0U) /*!< EPWM counter count decrement \hideinitializer */
  148. #define EPWM_PHS_DIR_INCREMENT (1U) /*!< EPWM counter count increment \hideinitializer */
  149. /*---------------------------------------------------------------------------------------------------------*/
  150. /* Noise Filter Clock Divide Select Constant Definitions */
  151. /*---------------------------------------------------------------------------------------------------------*/
  152. #define EPWM_NF_CLK_DIV_1 (0U) /*!< Noise filter clock is HCLK divide by 1 \hideinitializer */
  153. #define EPWM_NF_CLK_DIV_2 (1U) /*!< Noise filter clock is HCLK divide by 2 \hideinitializer */
  154. #define EPWM_NF_CLK_DIV_4 (2U) /*!< Noise filter clock is HCLK divide by 4 \hideinitializer */
  155. #define EPWM_NF_CLK_DIV_8 (3U) /*!< Noise filter clock is HCLK divide by 8 \hideinitializer */
  156. #define EPWM_NF_CLK_DIV_16 (4U) /*!< Noise filter clock is HCLK divide by 16 \hideinitializer */
  157. #define EPWM_NF_CLK_DIV_32 (5U) /*!< Noise filter clock is HCLK divide by 32 \hideinitializer */
  158. #define EPWM_NF_CLK_DIV_64 (6U) /*!< Noise filter clock is HCLK divide by 64 \hideinitializer */
  159. #define EPWM_NF_CLK_DIV_128 (7U) /*!< Noise filter clock is HCLK divide by 128 \hideinitializer */
  160. /*---------------------------------------------------------------------------------------------------------*/
  161. /* Clock Source Select Constant Definitions */
  162. /*---------------------------------------------------------------------------------------------------------*/
  163. #define EPWM_CLKSRC_EPWM_CLK (0U) /*!< EPWM Clock source selects to EPWM0_CLK or EPWM1_CLK \hideinitializer */
  164. #define EPWM_CLKSRC_TIMER0 (1U) /*!< EPWM Clock source selects to TIMER0 overflow \hideinitializer */
  165. #define EPWM_CLKSRC_TIMER1 (2U) /*!< EPWM Clock source selects to TIMER1 overflow \hideinitializer */
  166. #define EPWM_CLKSRC_TIMER2 (3U) /*!< EPWM Clock source selects to TIMER2 overflow \hideinitializer */
  167. #define EPWM_CLKSRC_TIMER3 (4U) /*!< EPWM Clock source selects to TIMER3 overflow \hideinitializer */
  168. /*@}*/ /* end of group EPWM_EXPORTED_CONSTANTS */
  169. /** @addtogroup EPWM_EXPORTED_FUNCTIONS EPWM Exported Functions
  170. @{
  171. */
  172. /**
  173. * @brief This macro enable complementary mode
  174. * @param[in] epwm The pointer of the specified EPWM module
  175. * @return None
  176. * @details This macro is used to enable complementary mode of EPWM module.
  177. * \hideinitializer
  178. */
  179. #define EPWM_ENABLE_COMPLEMENTARY_MODE(epwm) ((epwm)->CTL1 = (epwm)->CTL1 | (0x7ul<<EPWM_CTL1_OUTMODE0_Pos))
  180. /**
  181. * @brief This macro disable complementary mode, and enable independent mode.
  182. * @param[in] epwm The pointer of the specified EPWM module
  183. * @return None
  184. * @details This macro is used to disable complementary mode of EPWM module.
  185. * \hideinitializer
  186. */
  187. #define EPWM_DISABLE_COMPLEMENTARY_MODE(epwm) ((epwm)->CTL1 = (epwm)->CTL1 & ~(0x7ul<<EPWM_CTL1_OUTMODE0_Pos))
  188. /**
  189. * @brief This macro enable group mode
  190. * @param[in] epwm The pointer of the specified EPWM module
  191. * @return None
  192. * @details This macro is used to enable group mode of EPWM module.
  193. * \hideinitializer
  194. */
  195. #define EPWM_ENABLE_GROUP_MODE(epwm) ((epwm)->CTL0 = (epwm)->CTL0 | EPWM_CTL0_GROUPEN_Msk)
  196. /**
  197. * @brief This macro disable group mode
  198. * @param[in] epwm The pointer of the specified EPWM module
  199. * @return None
  200. * @details This macro is used to disable group mode of EPWM module.
  201. * \hideinitializer
  202. */
  203. #define EPWM_DISABLE_GROUP_MODE(epwm) ((epwm)->CTL0 = (epwm)->CTL0 & ~EPWM_CTL0_GROUPEN_Msk)
  204. /**
  205. * @brief Enable timer synchronous start counting function of specified channel(s)
  206. * @param[in] epwm The pointer of the specified EPWM module
  207. * @param[in] u32ChannelMask Combination of enabled channels. Each bit corresponds to a channel
  208. * Bit 0 represents channel 0, bit 1 represents channel 1...
  209. * @param[in] u32SyncSrc Synchronous start source selection, valid values are:
  210. * - \ref EPWM_SSCTL_SSRC_EPWM0
  211. * - \ref EPWM_SSCTL_SSRC_EPWM1
  212. * - \ref EPWM_SSCTL_SSRC_BPWM0
  213. * - \ref EPWM_SSCTL_SSRC_BPWM1
  214. * @return None
  215. * @details This macro is used to enable timer synchronous start counting function of specified channel(s).
  216. * \hideinitializer
  217. */
  218. #define EPWM_ENABLE_TIMER_SYNC(epwm, u32ChannelMask, u32SyncSrc) ((epwm)->SSCTL = ((epwm)->SSCTL & ~EPWM_SSCTL_SSRC_Msk) | (u32SyncSrc) | (u32ChannelMask))
  219. /**
  220. * @brief Disable timer synchronous start counting function of specified channel(s)
  221. * @param[in] epwm The pointer of the specified EPWM module
  222. * @param[in] u32ChannelMask Combination of enabled channels. Each bit corresponds to a channel
  223. * Bit 0 represents channel 0, bit 1 represents channel 1...
  224. * @return None
  225. * @details This macro is used to disable timer synchronous start counting function of specified channel(s).
  226. * \hideinitializer
  227. */
  228. #define EPWM_DISABLE_TIMER_SYNC(epwm, u32ChannelMask) \
  229. do{ \
  230. int i;\
  231. for(i = 0; i < 6; i++) { \
  232. if((u32ChannelMask) & (1 << i)) \
  233. (epwm)->SSCTL &= ~(1UL << i); \
  234. } \
  235. }while(0)
  236. /**
  237. * @brief This macro enable EPWM counter synchronous start counting function.
  238. * @param[in] epwm The pointer of the specified EPWM module
  239. * @return None
  240. * @details This macro is used to make selected EPWM0 and EPWM1 channel(s) start counting at the same time.
  241. * To configure synchronous start counting channel(s) by EPWM_ENABLE_TIMER_SYNC() and EPWM_DISABLE_TIMER_SYNC().
  242. * \hideinitializer
  243. */
  244. #define EPWM_TRIGGER_SYNC_START(epwm) ((epwm)->SSTRG = EPWM_SSTRG_CNTSEN_Msk)
  245. /**
  246. * @brief This macro enable output inverter of specified channel(s)
  247. * @param[in] epwm The pointer of the specified EPWM module
  248. * @param[in] u32ChannelMask Combination of enabled channels. Each bit corresponds to a channel
  249. * Bit 0 represents channel 0, bit 1 represents channel 1...
  250. * @return None
  251. * @details This macro is used to enable output inverter of specified channel(s).
  252. * \hideinitializer
  253. */
  254. #define EPWM_ENABLE_OUTPUT_INVERTER(epwm, u32ChannelMask) ((epwm)->POLCTL = (u32ChannelMask))
  255. /**
  256. * @brief This macro get captured rising data
  257. * @param[in] epwm The pointer of the specified EPWM module
  258. * @param[in] u32ChannelNum EPWM channel number. Valid values are between 0~5
  259. * @return None
  260. * @details This macro is used to get captured rising data of specified channel.
  261. * \hideinitializer
  262. */
  263. #define EPWM_GET_CAPTURE_RISING_DATA(epwm, u32ChannelNum) ((epwm)->CAPDAT[(u32ChannelNum)].RCAPDAT)
  264. /**
  265. * @brief This macro get captured falling data
  266. * @param[in] epwm The pointer of the specified EPWM module
  267. * @param[in] u32ChannelNum EPWM channel number. Valid values are between 0~5
  268. * @return None
  269. * @details This macro is used to get captured falling data of specified channel.
  270. * \hideinitializer
  271. */
  272. #define EPWM_GET_CAPTURE_FALLING_DATA(epwm, u32ChannelNum) ((epwm)->CAPDAT[(u32ChannelNum)].FCAPDAT)
  273. /**
  274. * @brief This macro mask output logic to high or low
  275. * @param[in] epwm The pointer of the specified EPWM module
  276. * @param[in] u32ChannelMask Combination of enabled channels. Each bit corresponds to a channel
  277. * Bit 0 represents channel 0, bit 1 represents channel 1...
  278. * @param[in] u32LevelMask Output logic to high or low
  279. * @return None
  280. * @details This macro is used to mask output logic to high or low of specified channel(s).
  281. * @note If u32ChannelMask parameter is 0, then mask function will be disabled.
  282. * \hideinitializer
  283. */
  284. #define EPWM_MASK_OUTPUT(epwm, u32ChannelMask, u32LevelMask) \
  285. { \
  286. (epwm)->MSKEN = (u32ChannelMask); \
  287. (epwm)->MSK = (u32LevelMask); \
  288. }
  289. /**
  290. * @brief This macro set the prescaler of the selected channel
  291. * @param[in] epwm The pointer of the specified EPWM module
  292. * @param[in] u32ChannelNum EPWM channel number. Valid values are between 0~5
  293. * @param[in] u32Prescaler Clock prescaler of specified channel. Valid values are between 0 ~ 0xFFF
  294. * @return None
  295. * @details This macro is used to set the prescaler of specified channel.
  296. * @note Every even channel N, and channel (N + 1) share a prescaler. So if channel 0 prescaler changed, channel 1 will also be affected.
  297. * The clock of EPWM counter is divided by (u32Prescaler + 1).
  298. * \hideinitializer
  299. */
  300. #define EPWM_SET_PRESCALER(epwm, u32ChannelNum, u32Prescaler) ((epwm)->CLKPSC[(u32ChannelNum) >> 1] = (u32Prescaler))
  301. /**
  302. * @brief This macro get the prescaler of the selected channel
  303. * @param[in] epwm The pointer of the specified EPWM module
  304. * @param[in] u32ChannelNum EPWM channel number. Valid values are between 0~5
  305. * @return Return Clock prescaler of specified channel. Valid values are between 0 ~ 0xFFF
  306. * @details This macro is used to get the prescaler of specified channel.
  307. * @note Every even channel N, and channel (N + 1) share a prescaler. So if channel 0 prescaler changed, channel 1 will also be affected.
  308. * The clock of EPWM counter is divided by (u32Prescaler + 1).
  309. * \hideinitializer
  310. */
  311. #define EPWM_GET_PRESCALER(epwm, u32ChannelNum) ((epwm)->CLKPSC[(u32ChannelNum) >> 1U])
  312. /**
  313. * @brief This macro set the comparator of the selected channel
  314. * @param[in] epwm The pointer of the specified EPWM module
  315. * @param[in] u32ChannelNum EPWM channel number. Valid values are between 0~5
  316. * @param[in] u32CMR Comparator of specified channel. Valid values are between 0~0xFFFF
  317. * @return None
  318. * @details This macro is used to set the comparator of specified channel.
  319. * @note This new setting will take effect on next EPWM period.
  320. * \hideinitializer
  321. */
  322. #define EPWM_SET_CMR(epwm, u32ChannelNum, u32CMR) ((epwm)->CMPDAT[(u32ChannelNum)]= (u32CMR))
  323. /**
  324. * @brief This macro get the comparator of the selected channel
  325. * @param[in] epwm The pointer of the specified EPWM module
  326. * @param[in] u32ChannelNum EPWM channel number. Valid values are between 0~5
  327. * @return Return the comparator of specified channel. Valid values are between 0~0xFFFF
  328. * @details This macro is used to get the comparator of specified channel.
  329. * \hideinitializer
  330. */
  331. #define EPWM_GET_CMR(epwm, u32ChannelNum) ((epwm)->CMPDAT[(u32ChannelNum)])
  332. /**
  333. * @brief This macro set the free trigger comparator of the selected channel
  334. * @param[in] epwm The pointer of the specified EPWM module
  335. * @param[in] u32ChannelNum EPWM channel number. Valid values are between 0~5
  336. * @param[in] u32FTCMR Free trigger comparator of specified channel. Valid values are between 0~0xFFFF
  337. * @return None
  338. * @details This macro is used to set the free trigger comparator of specified channel.
  339. * @note This new setting will take effect on next EPWM period.
  340. * \hideinitializer
  341. */
  342. #define EPWM_SET_FTCMR(epwm, u32ChannelNum, u32FTCMR) (((epwm)->FTCMPDAT[((u32ChannelNum) >> 1U)]) = (u32FTCMR))
  343. /**
  344. * @brief This macro set the period of the selected channel
  345. * @param[in] epwm The pointer of the specified EPWM module
  346. * @param[in] u32ChannelNum EPWM channel number. Valid values are between 0~5
  347. * @param[in] u32CNR Period of specified channel. Valid values are between 0~0xFFFF
  348. * @return None
  349. * @details This macro is used to set the period of specified channel.
  350. * @note This new setting will take effect on next EPWM period.
  351. * @note EPWM counter will stop if period length set to 0.
  352. * \hideinitializer
  353. */
  354. #define EPWM_SET_CNR(epwm, u32ChannelNum, u32CNR) ((epwm)->PERIOD[(u32ChannelNum)] = (u32CNR))
  355. /**
  356. * @brief This macro get the period of the selected channel
  357. * @param[in] epwm The pointer of the specified EPWM module
  358. * @param[in] u32ChannelNum EPWM channel number. Valid values are between 0~5
  359. * @return Return the period of specified channel. Valid values are between 0~0xFFFF
  360. * @details This macro is used to get the period of specified channel.
  361. * \hideinitializer
  362. */
  363. #define EPWM_GET_CNR(epwm, u32ChannelNum) ((epwm)->PERIOD[(u32ChannelNum)])
  364. /**
  365. * @brief This macro set the EPWM aligned type
  366. * @param[in] epwm The pointer of the specified EPWM module
  367. * @param[in] u32ChannelMask Combination of enabled channels. Each bit corresponds to a channel
  368. * Bit 0 represents channel 0, bit 1 represents channel 1...
  369. * @param[in] u32AlignedType EPWM aligned type, valid values are:
  370. * - \ref EPWM_EDGE_ALIGNED
  371. * - \ref EPWM_CENTER_ALIGNED
  372. * @return None
  373. * @details This macro is used to set the EPWM aligned type of specified channel(s).
  374. * \hideinitializer
  375. */
  376. #define EPWM_SET_ALIGNED_TYPE(epwm, u32ChannelMask, u32AlignedType) \
  377. do{ \
  378. int i; \
  379. for(i = 0; i < 6; i++) { \
  380. if((u32ChannelMask) & (1 << i)) \
  381. (epwm)->CTL1 = (((epwm)->CTL1 & ~(3UL << (i << 1))) | ((u32AlignedType) << (i << 1))); \
  382. } \
  383. }while(0)
  384. /**
  385. * @brief Set load window of window loading mode for specified channel(s)
  386. * @param[in] epwm The pointer of the specified EPWM module
  387. * @param[in] u32ChannelMask Combination of enabled channels. Each bit corresponds to a channel
  388. * Bit 0 represents channel 0, bit 1 represents channel 1...
  389. * @return None
  390. * @details This macro is used to set load window of window loading mode for specified channel(s).
  391. * \hideinitializer
  392. */
  393. #define EPWM_SET_LOAD_WINDOW(epwm, u32ChannelMask) ((epwm)->LOAD |= (u32ChannelMask))
  394. /**
  395. * @brief Trigger synchronous event from specified channel(s)
  396. * @param[in] epwm The pointer of the specified EPWM module
  397. * @param[in] u32ChannelNum EPWM channel number. Valid values are 0, 2, 4
  398. * Bit 0 represents channel 0, bit 1 represents channel 2 and bit 2 represents channel 4
  399. * @return None
  400. * @details This macro is used to trigger synchronous event from specified channel(s).
  401. * \hideinitializer
  402. */
  403. #define EPWM_TRIGGER_SYNC(epwm, u32ChannelNum) ((epwm)->SWSYNC |= (1 << ((u32ChannelNum) >> 1)))
  404. /**
  405. * @brief Clear counter of specified channel(s)
  406. * @param[in] epwm The pointer of the specified EPWM module
  407. * @param[in] u32ChannelMask Combination of enabled channels. Each bit corresponds to a channel
  408. * Bit 0 represents channel 0, bit 1 represents channel 1...
  409. * @return None
  410. * @details This macro is used to clear counter of specified channel(s).
  411. * \hideinitializer
  412. */
  413. #define EPWM_CLR_COUNTER(epwm, u32ChannelMask) ((epwm)->CNTCLR |= (u32ChannelMask))
  414. /**
  415. * @brief Set output level at zero, compare up, period(center) and compare down of specified channel(s)
  416. * @param[in] epwm The pointer of the specified EPWM module
  417. * @param[in] u32ChannelMask Combination of enabled channels. Each bit corresponds to a channel
  418. * Bit 0 represents channel 0, bit 1 represents channel 1...
  419. * @param[in] u32ZeroLevel output level at zero point, valid values are:
  420. * - \ref EPWM_OUTPUT_NOTHING
  421. * - \ref EPWM_OUTPUT_LOW
  422. * - \ref EPWM_OUTPUT_HIGH
  423. * - \ref EPWM_OUTPUT_TOGGLE
  424. * @param[in] u32CmpUpLevel output level at compare up point, valid values are:
  425. * - \ref EPWM_OUTPUT_NOTHING
  426. * - \ref EPWM_OUTPUT_LOW
  427. * - \ref EPWM_OUTPUT_HIGH
  428. * - \ref EPWM_OUTPUT_TOGGLE
  429. * @param[in] u32PeriodLevel output level at period(center) point, valid values are:
  430. * - \ref EPWM_OUTPUT_NOTHING
  431. * - \ref EPWM_OUTPUT_LOW
  432. * - \ref EPWM_OUTPUT_HIGH
  433. * - \ref EPWM_OUTPUT_TOGGLE
  434. * @param[in] u32CmpDownLevel output level at compare down point, valid values are:
  435. * - \ref EPWM_OUTPUT_NOTHING
  436. * - \ref EPWM_OUTPUT_LOW
  437. * - \ref EPWM_OUTPUT_HIGH
  438. * - \ref EPWM_OUTPUT_TOGGLE
  439. * @return None
  440. * @details This macro is used to Set output level at zero, compare up, period(center) and compare down of specified channel(s).
  441. * \hideinitializer
  442. */
  443. #define EPWM_SET_OUTPUT_LEVEL(epwm, u32ChannelMask, u32ZeroLevel, u32CmpUpLevel, u32PeriodLevel, u32CmpDownLevel) \
  444. do{ \
  445. int i; \
  446. for(i = 0; i < 6; i++) { \
  447. if((u32ChannelMask) & (1 << i)) { \
  448. (epwm)->WGCTL0 = (((epwm)->WGCTL0 & ~(3UL << (i << 1))) | ((u32ZeroLevel) << (i << 1))); \
  449. (epwm)->WGCTL0 = (((epwm)->WGCTL0 & ~(3UL << (EPWM_WGCTL0_PRDPCTL0_Pos + (i << 1)))) | ((u32PeriodLevel) << (EPWM_WGCTL0_PRDPCTL0_Pos + (i << 1)))); \
  450. (epwm)->WGCTL1 = (((epwm)->WGCTL1 & ~(3UL << (i << 1))) | ((u32CmpUpLevel) << (i << 1))); \
  451. (epwm)->WGCTL1 = (((epwm)->WGCTL1 & ~(3UL << (EPWM_WGCTL1_CMPDCTL0_Pos + (i << 1)))) | ((u32CmpDownLevel) << (EPWM_WGCTL1_CMPDCTL0_Pos + (i << 1)))); \
  452. } \
  453. } \
  454. }while(0)
  455. /**
  456. * @brief Trigger brake event from specified channel(s)
  457. * @param[in] epwm The pointer of the specified EPWM module
  458. * @param[in] u32ChannelMask Combination of enabled channels. Each bit corresponds to a channel
  459. * Bit 0 represents channel 0, bit 1 represents channel 2 and bit 2 represents channel 4
  460. * @param[in] u32BrakeType Type of brake trigger.
  461. * - \ref EPWM_FB_EDGE
  462. * - \ref EPWM_FB_LEVEL
  463. * @return None
  464. * @details This macro is used to trigger brake event from specified channel(s).
  465. * \hideinitializer
  466. */
  467. #define EPWM_TRIGGER_BRAKE(epwm, u32ChannelMask, u32BrakeType) ((epwm)->SWBRK |= ((u32ChannelMask) << (u32BrakeType)))
  468. /**
  469. * @brief Set Dead zone clock source
  470. * @param[in] epwm The pointer of the specified EPWM module
  471. * @param[in] u32ChannelNum EPWM channel number. Valid values are between 0~5
  472. * @param[in] u32AfterPrescaler Dead zone clock source is from prescaler output. Valid values are TRUE (after prescaler) or FALSE (before prescaler).
  473. * @return None
  474. * @details This macro is used to set Dead zone clock source. Every two channels share the same setting.
  475. * @note The write-protection function should be disabled before using this function.
  476. * \hideinitializer
  477. */
  478. #define EPWM_SET_DEADZONE_CLK_SRC(epwm, u32ChannelNum, u32AfterPrescaler) \
  479. ((epwm)->DTCTL[(u32ChannelNum) >> 1] = (((epwm)->DTCTL[(u32ChannelNum) >> 1] & ~EPWM_DTCTL0_1_DTCKSEL_Msk) | \
  480. ((u32AfterPrescaler) << EPWM_DTCTL0_1_DTCKSEL_Pos)))
  481. /*---------------------------------------------------------------------------------------------------------*/
  482. /* Define EPWM functions prototype */
  483. /*---------------------------------------------------------------------------------------------------------*/
  484. uint32_t EPWM_ConfigCaptureChannel(EPWM_T *epwm, uint32_t u32ChannelNum, uint32_t u32UnitTimeNsec, uint32_t u32CaptureEdge);
  485. uint32_t EPWM_ConfigOutputChannel(EPWM_T *epwm, uint32_t u32ChannelNum, uint32_t u32Frequency, uint32_t u32DutyCycle);
  486. void EPWM_Start(EPWM_T *epwm, uint32_t u32ChannelMask);
  487. void EPWM_Stop(EPWM_T *epwm, uint32_t u32ChannelMask);
  488. void EPWM_ForceStop(EPWM_T *epwm, uint32_t u32ChannelMask);
  489. void EPWM_EnableADCTrigger(EPWM_T *epwm, uint32_t u32ChannelNum, uint32_t u32Condition);
  490. void EPWM_DisableADCTrigger(EPWM_T *epwm, uint32_t u32ChannelNum);
  491. void EPWM_ClearADCTriggerFlag(EPWM_T *epwm, uint32_t u32ChannelNum, uint32_t u32Condition);
  492. uint32_t EPWM_GetADCTriggerFlag(EPWM_T *epwm, uint32_t u32ChannelNum);
  493. void EPWM_EnableDACTrigger(EPWM_T *epwm, uint32_t u32ChannelNum, uint32_t u32Condition);
  494. void EPWM_DisableDACTrigger(EPWM_T *epwm, uint32_t u32ChannelNum);
  495. void EPWM_ClearDACTriggerFlag(EPWM_T *epwm, uint32_t u32ChannelNum, uint32_t u32Condition);
  496. uint32_t EPWM_GetDACTriggerFlag(EPWM_T *epwm, uint32_t u32ChannelNum);
  497. void EPWM_EnableFaultBrake(EPWM_T *epwm, uint32_t u32ChannelMask, uint32_t u32LevelMask, uint32_t u32BrakeSource);
  498. void EPWM_EnableCapture(EPWM_T *epwm, uint32_t u32ChannelMask);
  499. void EPWM_DisableCapture(EPWM_T *epwm, uint32_t u32ChannelMask);
  500. void EPWM_EnableOutput(EPWM_T *epwm, uint32_t u32ChannelMask);
  501. void EPWM_DisableOutput(EPWM_T *epwm, uint32_t u32ChannelMask);
  502. void EPWM_EnablePDMA(EPWM_T *epwm, uint32_t u32ChannelNum, uint32_t u32RisingFirst, uint32_t u32Mode);
  503. void EPWM_DisablePDMA(EPWM_T *epwm, uint32_t u32ChannelNum);
  504. void EPWM_EnableDeadZone(EPWM_T *epwm, uint32_t u32ChannelNum, uint32_t u32Duration);
  505. void EPWM_DisableDeadZone(EPWM_T *epwm, uint32_t u32ChannelNum);
  506. void EPWM_EnableCaptureInt(EPWM_T *epwm, uint32_t u32ChannelNum, uint32_t u32Edge);
  507. void EPWM_DisableCaptureInt(EPWM_T *epwm, uint32_t u32ChannelNum, uint32_t u32Edge);
  508. void EPWM_ClearCaptureIntFlag(EPWM_T *epwm, uint32_t u32ChannelNum, uint32_t u32Edge);
  509. uint32_t EPWM_GetCaptureIntFlag(EPWM_T *epwm, uint32_t u32ChannelNum);
  510. void EPWM_EnableDutyInt(EPWM_T *epwm, uint32_t u32ChannelNum, uint32_t u32IntDutyType);
  511. void EPWM_DisableDutyInt(EPWM_T *epwm, uint32_t u32ChannelNum);
  512. void EPWM_ClearDutyIntFlag(EPWM_T *epwm, uint32_t u32ChannelNum);
  513. uint32_t EPWM_GetDutyIntFlag(EPWM_T *epwm, uint32_t u32ChannelNum);
  514. void EPWM_EnableFaultBrakeInt(EPWM_T *epwm, uint32_t u32BrakeSource);
  515. void EPWM_DisableFaultBrakeInt(EPWM_T *epwm, uint32_t u32BrakeSource);
  516. void EPWM_ClearFaultBrakeIntFlag(EPWM_T *epwm, uint32_t u32BrakeSource);
  517. uint32_t EPWM_GetFaultBrakeIntFlag(EPWM_T *epwm, uint32_t u32BrakeSource);
  518. void EPWM_EnablePeriodInt(EPWM_T *epwm, uint32_t u32ChannelNum, uint32_t u32IntPeriodType);
  519. void EPWM_DisablePeriodInt(EPWM_T *epwm, uint32_t u32ChannelNum);
  520. void EPWM_ClearPeriodIntFlag(EPWM_T *epwm, uint32_t u32ChannelNum);
  521. uint32_t EPWM_GetPeriodIntFlag(EPWM_T *epwm, uint32_t u32ChannelNum);
  522. void EPWM_EnableZeroInt(EPWM_T *epwm, uint32_t u32ChannelNum);
  523. void EPWM_DisableZeroInt(EPWM_T *epwm, uint32_t u32ChannelNum);
  524. void EPWM_ClearZeroIntFlag(EPWM_T *epwm, uint32_t u32ChannelNum);
  525. uint32_t EPWM_GetZeroIntFlag(EPWM_T *epwm, uint32_t u32ChannelNum);
  526. void EPWM_EnableAcc(EPWM_T *epwm, uint32_t u32ChannelNum, uint32_t u32IntFlagCnt, uint32_t u32IntAccSrc);
  527. void EPWM_DisableAcc(EPWM_T *epwm, uint32_t u32ChannelNum);
  528. void EPWM_EnableAccInt(EPWM_T *epwm, uint32_t u32ChannelNum);
  529. void EPWM_DisableAccInt(EPWM_T *epwm, uint32_t u32ChannelNum);
  530. void EPWM_ClearAccInt(EPWM_T *epwm, uint32_t u32ChannelNum);
  531. uint32_t EPWM_GetAccInt(EPWM_T *epwm, uint32_t u32ChannelNum);
  532. void EPWM_EnableAccPDMA(EPWM_T *epwm, uint32_t u32ChannelNum);
  533. void EPWM_DisableAccPDMA(EPWM_T *epwm, uint32_t u32ChannelNum);
  534. void EPWM_ClearFTDutyIntFlag(EPWM_T *epwm, uint32_t u32ChannelNum);
  535. uint32_t EPWM_GetFTDutyIntFlag(EPWM_T *epwm, uint32_t u32ChannelNum);
  536. void EPWM_EnableLoadMode(EPWM_T *epwm, uint32_t u32ChannelNum, uint32_t u32LoadMode);
  537. void EPWM_DisableLoadMode(EPWM_T *epwm, uint32_t u32ChannelNum, uint32_t u32LoadMode);
  538. void EPWM_ConfigSyncPhase(EPWM_T *epwm, uint32_t u32ChannelNum, uint32_t u32SyncSrc, uint32_t u32Direction, uint32_t u32StartPhase);
  539. void EPWM_EnableSyncPhase(EPWM_T *epwm, uint32_t u32ChannelMask);
  540. void EPWM_DisableSyncPhase(EPWM_T *epwm, uint32_t u32ChannelMask);
  541. void EPWM_EnableSyncNoiseFilter(EPWM_T *epwm, uint32_t u32ClkCnt, uint32_t u32ClkDivSel);
  542. void EPWM_DisableSyncNoiseFilter(EPWM_T *epwm);
  543. void EPWM_EnableSyncPinInverse(EPWM_T *epwm);
  544. void EPWM_DisableSyncPinInverse(EPWM_T *epwm);
  545. void EPWM_SetClockSource(EPWM_T *epwm, uint32_t u32ChannelNum, uint32_t u32ClkSrcSel);
  546. void EPWM_EnableBrakeNoiseFilter(EPWM_T *epwm, uint32_t u32BrakePinNum, uint32_t u32ClkCnt, uint32_t u32ClkDivSel);
  547. void EPWM_DisableBrakeNoiseFilter(EPWM_T *epwm, uint32_t u32BrakePinNum);
  548. void EPWM_EnableBrakePinInverse(EPWM_T *epwm, uint32_t u32BrakePinNum);
  549. void EPWM_DisableBrakePinInverse(EPWM_T *epwm, uint32_t u32BrakePinNum);
  550. void EPWM_SetBrakePinSource(EPWM_T *epwm, uint32_t u32BrakePinNum, uint32_t u32SelAnotherModule);
  551. void EPWM_SetLeadingEdgeBlanking(EPWM_T *epwm, uint32_t u32TrigSrcSel, uint32_t u32TrigType, uint32_t u32BlankingCnt, uint32_t u32BlankingEnable);
  552. uint32_t EPWM_GetWrapAroundFlag(EPWM_T *epwm, uint32_t u32ChannelNum);
  553. void EPWM_ClearWrapAroundFlag(EPWM_T *epwm, uint32_t u32ChannelNum);
  554. /*@}*/ /* end of group EPWM_EXPORTED_FUNCTIONS */
  555. /*@}*/ /* end of group EPWM_Driver */
  556. /*@}*/ /* end of group Standard_Driver */
  557. #ifdef __cplusplus
  558. }
  559. #endif
  560. #endif /* __EPWM_H__ */
  561. /*** (C) COPYRIGHT 2016 Nuvoton Technology Corp. ***/