hc32_ll_tmr4.h 46 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838
  1. /**
  2. *******************************************************************************
  3. * @file hc32_ll_tmr4.h
  4. * @brief This file contains all the functions prototypes of the TMR4
  5. * driver library.
  6. @verbatim
  7. Change Logs:
  8. Date Author Notes
  9. 2022-12-31 CDT First version
  10. @endverbatim
  11. *******************************************************************************
  12. * Copyright (C) 2022, Xiaohua Semiconductor Co., Ltd. All rights reserved.
  13. *
  14. * This software component is licensed by XHSC under BSD 3-Clause license
  15. * (the "License"); You may not use this file except in compliance with the
  16. * License. You may obtain a copy of the License at:
  17. * opensource.org/licenses/BSD-3-Clause
  18. *
  19. *******************************************************************************
  20. */
  21. #ifndef __HC32_LL_TMR4_H__
  22. #define __HC32_LL_TMR4_H__
  23. /* C binding of definitions if building with C++ compiler */
  24. #ifdef __cplusplus
  25. extern "C"
  26. {
  27. #endif
  28. /*******************************************************************************
  29. * Include files
  30. ******************************************************************************/
  31. #include "hc32_ll_def.h"
  32. #include "hc32f4xx.h"
  33. #include "hc32f4xx_conf.h"
  34. /**
  35. * @addtogroup LL_Driver
  36. * @{
  37. */
  38. /**
  39. * @addtogroup LL_TMR4
  40. * @{
  41. */
  42. #if (LL_TMR4_ENABLE == DDL_ON)
  43. /*******************************************************************************
  44. * Global type definitions ('typedef')
  45. ******************************************************************************/
  46. /**
  47. * @defgroup TMR4_Global_Types TMR4 Global Types
  48. * @{
  49. */
  50. /**
  51. * @brief TMR4 Counter function initialization configuration
  52. * @note The TMR4 division(u16ClockDiv) is valid when clock source is the internal clock.
  53. */
  54. typedef struct {
  55. uint16_t u16ClockSrc; /*!< TMR4 counter clock source.
  56. This parameter can be a value of @ref TMR4_Count_Clock_Source */
  57. uint16_t u16ClockDiv; /*!< TMR4 counter internal clock division.
  58. This parameter can be a value of @ref TMR4_Count_Clock_Division. */
  59. uint16_t u16CountMode; /*!< TMR4 counter mode.
  60. This parameter can be a value of @ref TMR4_Count_Mode */
  61. uint16_t u16PeriodValue; /*!< TMR4 counter period value.
  62. This parameter can be a value of half-word */
  63. } stc_tmr4_init_t;
  64. /**
  65. * @brief The configuration of Output-Compare high channel(OUH/OVH/OWH)
  66. */
  67. typedef union {
  68. uint16_t OCMRx; /*!< OCMRxH(x=U/V/W) register */
  69. struct { /*!< OCMRxH(x=U/V/W) register struct field bit */
  70. uint16_t OCFDCH : 1; /*!< OCMRxh b0 High channel's OCF status when high channel match occurs at the condition that counter is counting down
  71. This parameter can be a value of @ref TMR4_OC_Count_Match_OCF_State */
  72. uint16_t OCFPKH : 1; /*!< OCMRxh b1 High channel's OCF status when high channel match occurs at the condition that counter count=Peak
  73. This parameter can be a value of @ref TMR4_OC_Count_Match_OCF_State */
  74. uint16_t OCFUCH : 1; /*!< OCMRxh b2 High channel's OCF status when high channel match occurs at the condition that counter is counting up
  75. This parameter can be a value of @ref TMR4_OC_Count_Match_OCF_State */
  76. uint16_t OCFZRH : 1; /*!< OCMRxh b3 High channel's OCF status when high channel match occurs at the condition that counter count=0x0000
  77. This parameter can be a value of @ref TMR4_OC_Count_Match_OCF_State */
  78. uint16_t OPDCH : 2; /*!< OCMRxh b5~b4 High channel's OP output status when high channel match occurs at the condition that counter is counting down
  79. This parameter can be a value of @ref TMR4_OC_Count_Match_Output_Polarity */
  80. uint16_t OPPKH : 2; /*!< OCMRxh b7~b6 High channel's OP output status when high channel match occurs at the condition that counter count=Peak
  81. This parameter can be a value of @ref TMR4_OC_Count_Match_Output_Polarity */
  82. uint16_t OPUCH : 2; /*!< OCMRxh b9~b8 High channel's OP output status when high channel match occurs at the condition that counter is counting up
  83. This parameter can be a value of @ref TMR4_OC_Count_Match_Output_Polarity */
  84. uint16_t OPZRH : 2; /*!< OCMRxh b11~b10 High channel's OP output status when high channel match occurs at the condition that counter count=0x0000
  85. This parameter can be a value of @ref TMR4_OC_Count_Match_Output_Polarity */
  86. uint16_t OPNPKH : 2; /*!< OCMRxh b13~b12 High channel's OP output status when high channel match doesn't occur at the condition that counter count=Peak
  87. This parameter can be a value of @ref TMR4_OC_Count_Match_Output_Polarity */
  88. uint16_t OPNZRH : 2; /*!< OCMRxh b15~b14 High channel's OP output status when high channel match doesn't occur at the condition that counter count=0x0000
  89. This parameter can be a value of @ref TMR4_OC_Count_Match_Output_Polarity */
  90. } OCMRx_f;
  91. } un_tmr4_oc_ocmrh_t;
  92. /**
  93. * @brief The configuration of Output-Compare low channel(OUL/OVL/OWL)
  94. */
  95. typedef union {
  96. uint32_t OCMRx; /*!< OCMRxL(x=U/V/W) register */
  97. struct { /*!< OCMRxL(x=U/V/W) register struct field bit*/
  98. uint32_t OCFDCL : 1; /*!< OCMRxl b0 Low channel's OCF status when low channel match occurs at the condition that counter is counting down
  99. This parameter can be a value of @ref TMR4_OC_Count_Match_OCF_State */
  100. uint32_t OCFPKL : 1; /*!< OCMRxl b1 Low channel's OCF status when low channel match occurs at the condition that counter count=Peak
  101. This parameter can be a value of @ref TMR4_OC_Count_Match_OCF_State */
  102. uint32_t OCFUCL : 1; /*!< OCMRxl b2 Low channel's OCF status when low channel match occurs at the condition that counter is counting up
  103. This parameter can be a value of @ref TMR4_OC_Count_Match_OCF_State */
  104. uint32_t OCFZRL : 1; /*!< OCMRxl b3 Low channel's OCF status when low channel match occurs at the condition that counter count=0x0000
  105. This parameter can be a value of @ref TMR4_OC_Count_Match_OCF_State */
  106. uint32_t OPDCL : 2; /*!< OCMRxl b5~b4 Low channel's OP output status when high channel not match and low channel match occurs at the condition that counter is counting down
  107. This parameter can be a value of @ref TMR4_OC_Count_Match_Output_Polarity */
  108. uint32_t OPPKL : 2; /*!< OCMRxl b7~b6 Low channel's OP output status when high channel not match and low channel match occurs at the condition that counter count=Peak
  109. This parameter can be a value of @ref TMR4_OC_Count_Match_Output_Polarity */
  110. uint32_t OPUCL : 2; /*!< OCMRxl b9~b8 Low channel's OP output status when high channel not match and low channel match occurs at the condition that counter is counting up
  111. This parameter can be a value of @ref TMR4_OC_Count_Match_Output_Polarity */
  112. uint32_t OPZRL : 2; /*!< OCMRxl b11~b10 Low channel's OP output status when high channel not match and low channel match occurs at the condition that counter count=0x0000
  113. This parameter can be a value of @ref TMR4_OC_Count_Match_Output_Polarity */
  114. uint32_t OPNPKL : 2; /*!< OCMRxl b13~b12 Low channel's OP output status when high channel not match and low channel not match occurs at the condition that counter count=Peak
  115. This parameter can be a value of @ref TMR4_OC_Count_Match_Output_Polarity */
  116. uint32_t OPNZRL : 2; /*!< OCMRxl b15~b14 Low channel's OP output status when high channel not match and low channel not match occurs at the condition that counter count=0x0000
  117. This parameter can be a value of @ref TMR4_OC_Count_Match_Output_Polarity */
  118. uint32_t EOPNDCL : 2; /*!< OCMRxl b17~b16 Low channel's OP output status when high channel match and low channel not match occurs at the condition that counter is coutning down
  119. This parameter can be a value of @ref TMR4_OC_Count_Match_Output_Polarity */
  120. uint32_t EOPNUCL : 2; /*!< OCMRxl b19~b18 Low channel's OP output status when high channel match and low channel not match occurs at the condition that counter is counting up
  121. This parameter can be a value of @ref TMR4_OC_Count_Match_Output_Polarity */
  122. uint32_t EOPDCL : 2; /*!< OCMRxl b21~b20 Low channel's OP output status when high channel and low channel match occurs at the condition that counter is counting down
  123. This parameter can be a value of @ref TMR4_OC_Count_Match_Output_Polarity */
  124. uint32_t EOPPKL : 2; /*!< OCMRxl b23~b22 Low channel's OP output status when high channel and low channel match occurs at the condition that counter count=Peak
  125. This parameter can be a value of @ref TMR4_OC_Count_Match_Output_Polarity */
  126. uint32_t EOPUCL : 2; /*!< OCMRxl b25~b24 Low channel's OP output status when high channel and low channel match occurs at the condition that counter is counting up
  127. This parameter can be a value of @ref TMR4_OC_Count_Match_Output_Polarity */
  128. uint32_t EOPZRL : 2; /*!< OCMRxl b27~b26 Low channel's OP output status when high channel and low channel match occurs at the condition that counter count=0x0000
  129. This parameter can be a value of @ref TMR4_OC_Count_Match_Output_Polarity */
  130. uint32_t EOPNPKL : 2; /*!< OCMRxl b29~b28 Low channel's OP output status when high channel match and low channel not match occurs at the condition that counter count=Peak
  131. This parameter can be a value of @ref TMR4_OC_Count_Match_Output_Polarity */
  132. uint32_t EOPNZRL : 2; /*!< OCMRxl b31~b30 Low channel's OP output status when high channel match and low channel not match occurs at the condition that counter count=0x0000
  133. This parameter can be a value of @ref TMR4_OC_Count_Match_Output_Polarity */
  134. } OCMRx_f;
  135. } un_tmr4_oc_ocmrl_t;
  136. /**
  137. * @brief TMR4 Output-Compare(OC) initialization configuration
  138. */
  139. typedef struct {
  140. uint16_t u16CompareValue; /*!< TMR4 OC compare match value.
  141. This parameter can be a value of half-word. */
  142. uint16_t u16OcInvalidPolarity; /*!< Port output polarity when OC is disabled.
  143. This parameter can be a value of @ref TMR4_OC_Invalid_Output_Polarity. */
  144. uint16_t u16CompareModeBufCond; /*!< Register OCMR buffer transfer condition.
  145. This parameter can be a value of @ref TMR4_OC_Buffer_Transfer_Condition. */
  146. uint16_t u16CompareValueBufCond; /*!< Register OCCR buffer transfer condition.
  147. This parameter can be a value of @ref TMR4_OC_Buffer_Transfer_Condition. */
  148. uint16_t u16BufLinkTransObject; /*!< Enable the specified object(OCMR/OCCR) register buffer linked transfer with the counter interrupt mask.
  149. This parameter can be a value of @ref TMR4_OC_Buffer_Object. */
  150. } stc_tmr4_oc_init_t;
  151. /**
  152. * @brief TMR4 PWM initialization configuration
  153. * @note The clock division(u16ClockDiv) is valid when TMR4 clock source is the internal clock.
  154. */
  155. typedef struct {
  156. uint16_t u16Mode; /*!< Select PWM mode
  157. This parameter can be a value of @ref TMR4_PWM_Mode */
  158. uint16_t u16ClockDiv; /*!< The internal clock division of PWM timer.
  159. This parameter can be a value of @ref TMR4_PWM_Clock_Division. */
  160. uint16_t u16Polarity; /*!< TMR4 PWM polarity
  161. This parameter can be a value of @ref TMR4_PWM_Polarity */
  162. } stc_tmr4_pwm_init_t;
  163. /**
  164. * @brief TMR4 Special-Event(EVT) initialization configuration
  165. */
  166. typedef struct {
  167. uint16_t u16Mode; /*!< TMR4 event mode
  168. This parameter can be a value of @ref TMR4_Event_Mode */
  169. uint16_t u16CompareValue; /*!< TMR4 event compare match value.
  170. This parameter can be a value of half-word */
  171. uint16_t u16OutputEvent; /*!< TMR4 event output event when match count compare condition.
  172. This parameter can be a value of @ref TMR4_Event_Output_Event */
  173. uint16_t u16MatchCond; /*!< Enable the specified count compare type with counter count to generate event.
  174. This parameter can be a value of @ref TMR4_Event_Match_Condition */
  175. } stc_tmr4_evt_init_t;
  176. /**
  177. * @}
  178. */
  179. /*******************************************************************************
  180. * Global pre-processor symbols/macros ('#define')
  181. ******************************************************************************/
  182. /**
  183. * @defgroup TMR4_Global_Macros TMR4 Global Macros
  184. * @{
  185. */
  186. /**
  187. * @defgroup TMR4_Counter_Macros TMR4 Counter Macros
  188. * @{
  189. */
  190. /**
  191. * @defgroup TMR4_Count_Clock_Source TMR4 Count Clock Source
  192. * @{
  193. */
  194. #define TMR4_CLK_SRC_INTERNCLK (0U)
  195. #define TMR4_CLK_SRC_EXTCLK (TMR4_CCSR_ECKEN)
  196. /**
  197. * @}
  198. */
  199. /**
  200. * @defgroup TMR4_Count_Clock_Division TMR4 Count Clock Division
  201. * @{
  202. */
  203. #define TMR4_CLK_DIV1 (0U << TMR4_CCSR_CKDIV_POS) /*!< CLK */
  204. #define TMR4_CLK_DIV2 (1U << TMR4_CCSR_CKDIV_POS) /*!< CLK/2 */
  205. #define TMR4_CLK_DIV4 (2U << TMR4_CCSR_CKDIV_POS) /*!< CLK/4 */
  206. #define TMR4_CLK_DIV8 (3U << TMR4_CCSR_CKDIV_POS) /*!< CLK/8 */
  207. #define TMR4_CLK_DIV16 (4U << TMR4_CCSR_CKDIV_POS) /*!< CLK/16 */
  208. #define TMR4_CLK_DIV32 (5U << TMR4_CCSR_CKDIV_POS) /*!< CLK/32 */
  209. #define TMR4_CLK_DIV64 (6U << TMR4_CCSR_CKDIV_POS) /*!< CLK/64 */
  210. #define TMR4_CLK_DIV128 (7U << TMR4_CCSR_CKDIV_POS) /*!< CLK/128 */
  211. #define TMR4_CLK_DIV256 (8U << TMR4_CCSR_CKDIV_POS) /*!< CLK/256 */
  212. #define TMR4_CLK_DIV512 (9U << TMR4_CCSR_CKDIV_POS) /*!< CLK/512 */
  213. #define TMR4_CLK_DIV1024 (10U << TMR4_CCSR_CKDIV_POS) /*!< CLK/1024 */
  214. /**
  215. * @}
  216. */
  217. /**
  218. * @defgroup TMR4_Count_Mode TMR4 Count Mode
  219. * @{
  220. */
  221. #define TMR4_MD_SAWTOOTH (0U)
  222. #define TMR4_MD_TRIANGLE (TMR4_CCSR_MODE)
  223. /**
  224. * @}
  225. */
  226. /**
  227. * @defgroup TMR4_Flag TMR4 Flag
  228. * @{
  229. */
  230. #define TMR4_FLAG_CNT_PEAK ((uint32_t)TMR4_CCSR_IRQPF) /*!< Count peak flag */
  231. #define TMR4_FLAG_CNT_VALLEY ((uint32_t)TMR4_CCSR_IRQZF) /*!< Count valley flag */
  232. #define TMR4_FLAG_RELOAD_TMR_U (1UL << 0U) /*!< TMR4 PWM reload-timer flag - channel U */
  233. #define TMR4_FLAG_RELOAD_TMR_V (1UL << 4U) /*!< TMR4 PWM reload-timer flag - channel V */
  234. #define TMR4_FLAG_RELOAD_TMR_W (1UL << 8U) /*!< TMR4 PWM reload-timer flag - channel W */
  235. #define TMR4_FLAG_RELOAD_TMR_X (1UL << 12U) /*!< TMR4 PWM reload-timer flag - channel X */
  236. #define TMR4_FLAG_OC_CMP_UH (1UL << 16U) /*!< TMR4 output-compare compare flag - channel UH */
  237. #define TMR4_FLAG_OC_CMP_UL (1UL << 17U) /*!< TMR4 output-compare compare flag - channel UL */
  238. #define TMR4_FLAG_OC_CMP_VH (1UL << 18U) /*!< TMR4 output-compare compare flag - channel VH */
  239. #define TMR4_FLAG_OC_CMP_VL (1UL << 19U) /*!< TMR4 output-compare compare flag - channel VL */
  240. #define TMR4_FLAG_OC_CMP_WH (1UL << 20U) /*!< TMR4 output-compare compare flag - channel WH */
  241. #define TMR4_FLAG_OC_CMP_WL (1UL << 21U) /*!< TMR4 output-compare compare flag - channel WL */
  242. #define TMR4_FLAG_OC_CMP_XH (1UL << 22U) /*!< TMR4 output-compare compare flag - channel XH */
  243. #define TMR4_FLAG_OC_CMP_XL (1UL << 23U) /*!< TMR4 output-compare compare flag - channel XL */
  244. #define TMR4_FLAG_EVT_CMP_UH (1UL << 24U) /*!< TMR4 event-compare compare interrupt - channel UH */
  245. #define TMR4_FLAG_EVT_CMP_UL (1UL << 25U) /*!< TMR4 event-compare compare interrupt - channel UL */
  246. #define TMR4_FLAG_EVT_CMP_VH (1UL << 26U) /*!< TMR4 event-compare compare interrupt - channel VH */
  247. #define TMR4_FLAG_EVT_CMP_VL (1UL << 27U) /*!< TMR4 event-compare compare interrupt - channel VL */
  248. #define TMR4_FLAG_EVT_CMP_WH (1UL << 28U) /*!< TMR4 event-compare compare interrupt - channel WH */
  249. #define TMR4_FLAG_EVT_CMP_WL (1UL << 29U) /*!< TMR4 event-compare compare interrupt - channel WL */
  250. #define TMR4_FLAG_EVT_CMP_XH (1UL << 30U) /*!< TMR4 event-compare compare interrupt - channel XH */
  251. #define TMR4_FLAG_EVT_CMP_XL (1UL << 31U) /*!< TMR4 event-compare compare interrupt - channel ZL */
  252. #define TMR4_FLAG_ALL (TMR4_FLAG_CNT_PEAK | TMR4_FLAG_CNT_VALLEY | TMR4_FLAG_RELOAD_TMR_U | \
  253. TMR4_FLAG_RELOAD_TMR_V | TMR4_FLAG_RELOAD_TMR_W | TMR4_FLAG_RELOAD_TMR_X | \
  254. TMR4_FLAG_OC_CMP_UH | TMR4_FLAG_OC_CMP_UL | TMR4_FLAG_OC_CMP_VH | \
  255. TMR4_FLAG_OC_CMP_VL | TMR4_FLAG_OC_CMP_WH | TMR4_FLAG_OC_CMP_WL | \
  256. TMR4_FLAG_OC_CMP_XH | TMR4_FLAG_OC_CMP_XL | TMR4_FLAG_EVT_CMP_UH | \
  257. TMR4_FLAG_EVT_CMP_UL | TMR4_FLAG_EVT_CMP_VH | TMR4_FLAG_EVT_CMP_VL | \
  258. TMR4_FLAG_EVT_CMP_WH | TMR4_FLAG_EVT_CMP_WL | TMR4_FLAG_EVT_CMP_XH | \
  259. TMR4_FLAG_EVT_CMP_XL)
  260. /**
  261. * @}
  262. */
  263. /**
  264. * @defgroup TMR4_Interrupt TMR4 Interrupt
  265. * @{
  266. */
  267. #define TMR4_INT_CNT_PEAK ((uint32_t)TMR4_CCSR_IRQPEN) /*!< Count peak interrupt */
  268. #define TMR4_INT_CNT_VALLEY ((uint32_t)TMR4_CCSR_IRQZEN) /*!< Count valley interrupt */
  269. #define TMR4_INT_RELOAD_TMR_U (1UL << 0U) /*!< TMR4 PWM reload-timer interrupt - channel U */
  270. #define TMR4_INT_RELOAD_TMR_V (1UL << 1U) /*!< TMR4 PWM reload-timer interrupt - channel W */
  271. #define TMR4_INT_RELOAD_TMR_W (1UL << 2U) /*!< TMR4 PWM reload-timer interrupt - channel V */
  272. #define TMR4_INT_RELOAD_TMR_X (1UL << 3U) /*!< TMR4 PWM reload-timer interrupt - channel V */
  273. #define TMR4_INT_OC_CMP_UH (1UL << 16U) /*!< TMR4 output-compare compare interrupt - channel UH */
  274. #define TMR4_INT_OC_CMP_UL (1UL << 17U) /*!< TMR4 output-compare compare interrupt - channel UL */
  275. #define TMR4_INT_OC_CMP_VH (1UL << 18U) /*!< TMR4 output-compare compare interrupt - channel VH */
  276. #define TMR4_INT_OC_CMP_VL (1UL << 19U) /*!< TMR4 output-compare compare interrupt - channel VL */
  277. #define TMR4_INT_OC_CMP_WH (1UL << 20U) /*!< TMR4 output-compare compare interrupt - channel WH */
  278. #define TMR4_INT_OC_CMP_WL (1UL << 21U) /*!< TMR4 output-compare compare interrupt - channel WL */
  279. #define TMR4_INT_OC_CMP_XH (1UL << 22U) /*!< TMR4 output-compare compare interrupt - channel XH */
  280. #define TMR4_INT_OC_CMP_XL (1UL << 23U) /*!< TMR4 output-compare compare interrupt - channel XL */
  281. #define TMR4_INT_EVT_CMP_UH (1UL << 24U) /*!< TMR4 event-compare compare interrupt - channel UH */
  282. #define TMR4_INT_EVT_CMP_UL (1UL << 25U) /*!< TMR4 event-compare compare interrupt - channel UL */
  283. #define TMR4_INT_EVT_CMP_VH (1UL << 26U) /*!< TMR4 event-compare compare interrupt - channel VH */
  284. #define TMR4_INT_EVT_CMP_VL (1UL << 27U) /*!< TMR4 event-compare compare interrupt - channel VL */
  285. #define TMR4_INT_EVT_CMP_WH (1UL << 28U) /*!< TMR4 event-compare compare interrupt - channel WH */
  286. #define TMR4_INT_EVT_CMP_WL (1UL << 29U) /*!< TMR4 event-compare compare interrupt - channel WL */
  287. #define TMR4_INT_EVT_CMP_XH (1UL << 30U) /*!< TMR4 event-compare compare interrupt - channel XH */
  288. #define TMR4_INT_EVT_CMP_XL (1UL << 31U) /*!< TMR4 event-compare compare interrupt - channel XL */
  289. #define TMR4_INT_ALL (TMR4_INT_CNT_PEAK | TMR4_INT_CNT_VALLEY | TMR4_INT_RELOAD_TMR_U | \
  290. TMR4_INT_RELOAD_TMR_V | TMR4_INT_RELOAD_TMR_W | TMR4_INT_RELOAD_TMR_X | \
  291. TMR4_INT_OC_CMP_UH | TMR4_INT_OC_CMP_UL | TMR4_INT_OC_CMP_VH | \
  292. TMR4_INT_OC_CMP_VL | TMR4_INT_OC_CMP_WH | TMR4_INT_OC_CMP_WL | \
  293. TMR4_INT_OC_CMP_XH | TMR4_INT_OC_CMP_XL | TMR4_INT_EVT_CMP_UH | \
  294. TMR4_INT_EVT_CMP_UL | TMR4_INT_EVT_CMP_VH | TMR4_INT_EVT_CMP_VL | \
  295. TMR4_INT_EVT_CMP_WH | TMR4_INT_EVT_CMP_WL | TMR4_INT_EVT_CMP_XH | \
  296. TMR4_INT_EVT_CMP_XL)
  297. /**
  298. * @}
  299. */
  300. /**
  301. * @defgroup TMR4_Count_Interrupt_Mask_Time TMR4 Count Interrupt Mask Time
  302. * @{
  303. */
  304. #define TMR4_INT_CNT_MASK0 (0U) /*!< Counter interrupt flag is always set(not masked) for counter count every time at "0x0000" or peak */
  305. #define TMR4_INT_CNT_MASK1 (1U) /*!< Counter interrupt flag is set once when counter counts 2 times at "0x0000" or peak (skiping 1 count) */
  306. #define TMR4_INT_CNT_MASK2 (2U) /*!< Counter interrupt flag is set once when counter counts 3 times at "0x0000" or peak (skiping 2 count) */
  307. #define TMR4_INT_CNT_MASK3 (3U) /*!< Counter interrupt flag is set once when counter counts 4 times at "0x0000" or peak (skiping 3 count) */
  308. #define TMR4_INT_CNT_MASK4 (4U) /*!< Counter interrupt flag is set once when counter counts 5 times at "0x0000" or peak (skiping 4 count) */
  309. #define TMR4_INT_CNT_MASK5 (5U) /*!< Counter interrupt flag is set once when counter counts 6 times at "0x0000" or peak (skiping 5 count) */
  310. #define TMR4_INT_CNT_MASK6 (6U) /*!< Counter interrupt flag is set once when counter counts 7 times at "0x0000" or peak (skiping 6 count) */
  311. #define TMR4_INT_CNT_MASK7 (7U) /*!< Counter interrupt flag is set once when counter counts 8 times at "0x0000" or peak (skiping 7 count) */
  312. #define TMR4_INT_CNT_MASK8 (8U) /*!< Counter interrupt flag is set once when counter counts 9 times at "0x0000" or peak (skiping 8 count) */
  313. #define TMR4_INT_CNT_MASK9 (9U) /*!< Counter interrupt flag is set once when counter counts 10 times at "0x0000" or peak (skiping 9 count) */
  314. #define TMR4_INT_CNT_MASK10 (10U) /*!< Counter interrupt flag is set once when counter counts 11 times at "0x0000" or peak (skiping 10 count) */
  315. #define TMR4_INT_CNT_MASK11 (11U) /*!< Counter interrupt flag is set once when counter counts 12 times at "0x0000" or peak (skiping 11 count) */
  316. #define TMR4_INT_CNT_MASK12 (12U) /*!< Counter interrupt flag is set once when counter counts 13 times at "0x0000" or peak (skiping 12 count) */
  317. #define TMR4_INT_CNT_MASK13 (13U) /*!< Counter interrupt flag is set once when counter counts 14 times at "0x0000" or peak (skiping 13 count) */
  318. #define TMR4_INT_CNT_MASK14 (14U) /*!< Counter interrupt flag is set once when counter counts 15 times at "0x0000" or peak (skiping 14 count) */
  319. #define TMR4_INT_CNT_MASK15 (15U) /*!< Counter interrupt flag is set once when counter counts 16 times at "0x0000" or peak (skiping 15 count) */
  320. /**
  321. * @}
  322. */
  323. /**
  324. * @}
  325. */
  326. /**
  327. * @defgroup TMR4_Output_Compare_Macros TMR4 Output-Compare Macros
  328. * @{
  329. */
  330. /**
  331. * @defgroup TMR4_OC_Channel TMR4 OC Channel
  332. * @{
  333. */
  334. #define TMR4_OC_CH_UH (0UL) /*!< TMR4 OC channel:UH */
  335. #define TMR4_OC_CH_UL (1UL) /*!< TMR4 OC channel:UL */
  336. #define TMR4_OC_CH_VH (2UL) /*!< TMR4 OC channel:VH */
  337. #define TMR4_OC_CH_VL (3UL) /*!< TMR4 OC channel:VL */
  338. #define TMR4_OC_CH_WH (4UL) /*!< TMR4 OC channel:WH */
  339. #define TMR4_OC_CH_WL (5UL) /*!< TMR4 OC channel:WL */
  340. #define TMR4_OC_CH_XH (6UL) /*!< TMR4 OC channel:XH */
  341. #define TMR4_OC_CH_XL (7UL) /*!< TMR4 OC channel:XL */
  342. /**
  343. * @}
  344. */
  345. /**
  346. * @defgroup TMR4_OC_Invalid_Output_Polarity TMR4 OC Invalid Output Polarity
  347. * @{
  348. */
  349. #define TMR4_OC_INVD_LOW (0U) /*!< TMR4 OC Output low level when OC is invalid */
  350. #define TMR4_OC_INVD_HIGH (TMR4_OCSR_OCPH) /*!< TMR4 OC Output high level when OC is invalid */
  351. /**
  352. * @}
  353. */
  354. /**
  355. * @defgroup TMR4_OC_Buffer_Object TMR4 OC Buffer Object
  356. * @{
  357. */
  358. #define TMR4_OC_BUF_CMP_VALUE (0x01U) /*!< The register OCCR buffer function index */
  359. #define TMR4_OC_BUF_CMP_MD (0x02U) /*!< The register OCMR buffer function index */
  360. /**
  361. * @}
  362. */
  363. /**
  364. * @defgroup TMR4_OC_Buffer_Transfer_Condition TMR4 OC OCCR Buffer Transfer Condition
  365. * @{
  366. */
  367. #define TMR4_OC_BUF_COND_IMMED (0U) /*!< Buffer transfer is made when writing to the OCCR/OCMR register. */
  368. #define TMR4_OC_BUF_COND_VALLEY (1U) /*!< Buffer transfer is made when counter count valley */
  369. #define TMR4_OC_BUF_COND_PEAK (2U) /*!< Buffer transfer is made when counter count peak */
  370. #define TMR4_OC_BUF_COND_PEAK_VALLEY (3U) /*!< Buffer transfer is made when counter count peak or valley */
  371. /**
  372. * @}
  373. */
  374. /**
  375. * @defgroup TMR4_OC_Count_Match_OCF_State TMR4 OC Count Match OCF State
  376. * @{
  377. */
  378. #define TMR4_OC_OCF_HOLD (0U) /*!< Hold OCF when the TMR4 OC count match */
  379. #define TMR4_OC_OCF_SET (TMR4_OCMRH_OCFDCH) /*!< Set OCF when the TMR4 OC count match */
  380. /**
  381. * @}
  382. */
  383. /**
  384. * @defgroup TMR4_OC_Count_Match_Output_Polarity TMR4 OC Count Match Output Polarity
  385. * @{
  386. */
  387. #define TMR4_OC_HOLD (0U) /*!< Hold output when the TMR4 OC count match */
  388. #define TMR4_OC_HIGH (1U) /*!< Output high when the TMR4 OC count match */
  389. #define TMR4_OC_LOW (2U) /*!< Output low when the TMR4 OC count match */
  390. #define TMR4_OC_INVT (3U) /*!< Invert output when the TMR4 OC count match */
  391. /**
  392. * @}
  393. */
  394. /**
  395. * @}
  396. */
  397. /**
  398. * @defgroup TMR4_PWM_Macros TMR4 PWM Macros
  399. * @{
  400. */
  401. /**
  402. * @defgroup TMR4_PWM_Channel TMR4 PWM Channel
  403. * @{
  404. */
  405. #define TMR4_PWM_CH_U (0UL) /*!< TMR4 PWM couple channel: U */
  406. #define TMR4_PWM_CH_V (1UL) /*!< TMR4 PWM couple channel: V */
  407. #define TMR4_PWM_CH_W (2UL) /*!< TMR4 PWM couple channel: W */
  408. #define TMR4_PWM_CH_X (3UL) /*!< TMR4 PWM couple channel: X */
  409. /**
  410. * @}
  411. */
  412. /**
  413. * @defgroup TMR4_PWM_Pin TMR4 PWM Pin
  414. * @{
  415. */
  416. #define TMR4_PWM_PIN_OUH (0UL) /*!< TMR4 PWM port: TIM4_<t>_OUH */
  417. #define TMR4_PWM_PIN_OUL (1UL) /*!< TMR4 PWM port: TIM4_<t>_OUL */
  418. #define TMR4_PWM_PIN_OVH (2UL) /*!< TMR4 PWM port: TIM4_<t>_OVH */
  419. #define TMR4_PWM_PIN_OVL (3UL) /*!< TMR4 PWM port: TIM4_<t>_OVL */
  420. #define TMR4_PWM_PIN_OWH (4UL) /*!< TMR4 PWM port: TIM4_<t>_OWH */
  421. #define TMR4_PWM_PIN_OWL (5UL) /*!< TMR4 PWM port: TIM4_<t>_OWL */
  422. #define TMR4_PWM_PIN_OXH (6UL) /*!< TMR4 PWM port: TIM4_<t>_OXH */
  423. #define TMR4_PWM_PIN_OXL (7UL) /*!< TMR4 PWM port: TIM4_<t>_OXL */
  424. /**
  425. * @}
  426. */
  427. /**
  428. * @defgroup TMR4_PWM_Clock_Division TMR4 PWM Clock Division
  429. * @{
  430. */
  431. #define TMR4_PWM_CLK_DIV1 (0U) /*!< CLK */
  432. #define TMR4_PWM_CLK_DIV2 (1U << TMR4_POCR_DIVCK_POS) /*!< CLK/2 */
  433. #define TMR4_PWM_CLK_DIV4 (2U << TMR4_POCR_DIVCK_POS) /*!< CLK/8 */
  434. #define TMR4_PWM_CLK_DIV8 (3U << TMR4_POCR_DIVCK_POS) /*!< CLK/8 */
  435. #define TMR4_PWM_CLK_DIV16 (4U << TMR4_POCR_DIVCK_POS) /*!< CLK/16 */
  436. #define TMR4_PWM_CLK_DIV32 (5U << TMR4_POCR_DIVCK_POS) /*!< CLK/32 */
  437. #define TMR4_PWM_CLK_DIV64 (6U << TMR4_POCR_DIVCK_POS) /*!< CLK/64 */
  438. #define TMR4_PWM_CLK_DIV128 (7U << TMR4_POCR_DIVCK_POS) /*!< CLK/128 */
  439. /**
  440. * @}
  441. */
  442. /**
  443. * @defgroup TMR4_PWM_Mode TMR4 PWM Mode
  444. * @{
  445. */
  446. #define TMR4_PWM_MD_THROUGH (0U) /*!< Through mode */
  447. #define TMR4_PWM_MD_DEAD_TMR (TMR4_POCR_PWMMD_0) /*!< Dead timer mode */
  448. #define TMR4_PWM_MD_DEAD_TMR_FILTER (TMR4_POCR_PWMMD_1) /*!< Dead timer filter mode */
  449. /**
  450. * @}
  451. */
  452. /**
  453. * @defgroup TMR4_PWM_Polarity TMR4 PWM Polarity
  454. * @{
  455. */
  456. #define TMR4_PWM_OXH_HOLD_OXL_HOLD (0U) /*!< Output PWML and PWMH signals without changing the level */
  457. #define TMR4_PWM_OXH_INVT_OXL_INVT (TMR4_POCR_LVLS_0) /*!< Output both PWML and PWMH signals reversed */
  458. #define TMR4_PWM_OXH_INVT_OXL_HOLD (TMR4_POCR_LVLS_1) /*!< Output the PWMH signal reversed, outputs the PWML signal without changing the level. */
  459. #define TMR4_PWM_OXH_HOLD_OXL_INVT (TMR4_POCR_LVLS) /*!< Output the PWMH signal without changing the level, Outputs the PWML signal reversed. */
  460. /**
  461. * @}
  462. */
  463. /**
  464. * @defgroup TMR4_PWM_Dead_Time_Register_Index TMR4 PWM Dead Time Register Index
  465. * @{
  466. */
  467. #define TMR4_PWM_PDAR_IDX (0UL) /*!< TMR4_PDARn(n=U/V/W) */
  468. #define TMR4_PWM_PDBR_IDX (1UL) /*!< TMR4_PDBRn(n=U/V/W) */
  469. /**
  470. * @}
  471. */
  472. /**
  473. * @defgroup TMR4_PWM_Abnormal_Pin_Status TMR4 PWM Abnormal Pin Status
  474. * @{
  475. */
  476. #define TMR4_PWM_ABNORMAL_PIN_NORMAL (0UL) /*!< TIM4_<t>_Oxy(x=U/V/W, y=H/L) output normal */
  477. #define TMR4_PWM_ABNORMAL_PIN_HIZ (1UL) /*!< TIM4_<t>_Oxy(x=U/V/W, y=H/L) to Hi-z */
  478. #define TMR4_PWM_ABNORMAL_PIN_LOW (2UL) /*!< TIM4_<t>_Oxy(x=U/V/W, y=H/L) output low level */
  479. #define TMR4_PWM_ABNORMAL_PIN_HIGH (3UL) /*!< TIM4_<t>_Oxy(x=U/V/W, y=H/L) output high level */
  480. /**
  481. * @}
  482. */
  483. /**
  484. * @defgroup TMR4_PWM_Pin_Output_Mode TMR4 PWM Pin Mode
  485. * @{
  486. */
  487. #define TMR4_PWM_PIN_OUTPUT_OS (0UL) /*!< TIM4_<t>_Oxy(x=U/V/W, y=H/L) output polarity by specified register TMR4_PSCR.OSxy */
  488. #define TMR4_PWM_PIN_OUTPUT_NORMAL (TMR4_PSCR_OEUH) /*!< TIM4_<t>_Oxy(x=U/V/W, y=H/L) output normal PWM */
  489. /**
  490. * @}
  491. */
  492. /**
  493. * @defgroup TMR4_PWM_OE_Bit_Effect_Time TMR4 PWM Register TMR4_PSCR.OE Bit Effect Time
  494. * @{
  495. */
  496. #define TMR4_PWM_OE_EFFECT_IMMED (TMR4_PSCR_ODT_0) /*!< TMR4 PWM reister TMR4_PSCR.OE bit immediate effect. */
  497. #define TMR4_PWM_OE_EFFECT_COUNT_PEAK (TMR4_PSCR_ODT) /*!< TMR4 PWM reister TMR4_PSCR.OE bit effect when TMR4 counter count peak. */
  498. #define TMR4_PWM_OE_EFFECT_COUNT_VALLEY (TMR4_PSCR_ODT_1) /*!< TMR4 PWM reister TMR4_PSCR.OE bit effect when TMR4 counter count valley. */
  499. /**
  500. * @}
  501. */
  502. /**
  503. * @}
  504. */
  505. /**
  506. * @defgroup TMR4_Event_Macros TMR4 Event Macros
  507. * @{
  508. */
  509. /**
  510. * @defgroup TMR4_Event_Channel TMR4 Event Channel
  511. * @{
  512. */
  513. #define TMR4_EVT_CH_UH (0UL) /*!< TMR4 EVT channel:UH */
  514. #define TMR4_EVT_CH_UL (1UL) /*!< TMR4 EVT channel:UL */
  515. #define TMR4_EVT_CH_VH (2UL) /*!< TMR4 EVT channel:VH */
  516. #define TMR4_EVT_CH_VL (3UL) /*!< TMR4 EVT channel:VL */
  517. #define TMR4_EVT_CH_WH (4UL) /*!< TMR4 EVT channel:WH */
  518. #define TMR4_EVT_CH_WL (5UL) /*!< TMR4 EVT channel:WL */
  519. #define TMR4_EVT_CH_XH (6UL) /*!< TMR4 EVT channel:XH */
  520. #define TMR4_EVT_CH_XL (7UL) /*!< TMR4 EVT channel:XL */
  521. /**
  522. * @}
  523. */
  524. /**
  525. * @defgroup TMR4_Event_Match_Condition TMR4 Event Match Condition
  526. * @{
  527. */
  528. #define TMR4_EVT_MATCH_CNT_UP (TMR4_SCSR_UEN) /*!< Start event operation when match with SCCR&SCMR and TMR4 counter count up */
  529. #define TMR4_EVT_MATCH_CNT_DOWN (TMR4_SCSR_DEN) /*!< Start event operation when match with SCCR&SCMR and TMR4 counter count down */
  530. #define TMR4_EVT_MATCH_CNT_PEAK (TMR4_SCSR_PEN) /*!< Start event operation when match with SCCR&SCMR and TMR4 counter count peak */
  531. #define TMR4_EVT_MATCH_CNT_VALLEY (TMR4_SCSR_ZEN) /*!< Start event operation when match with SCCR&SCMR and TMR4 counter count vallay */
  532. #define TMR4_EVT_MATCH_CNT_ALL (TMR4_EVT_MATCH_CNT_DOWN | TMR4_EVT_MATCH_CNT_UP | \
  533. TMR4_EVT_MATCH_CNT_PEAK | TMR4_EVT_MATCH_CNT_VALLEY)
  534. /**
  535. * @}
  536. */
  537. /**
  538. * @defgroup TMR4_Event_Mask TMR4 Event Mask
  539. * @{
  540. */
  541. #define TMR4_EVT_MASK_PEAK (TMR4_SCMR_MPCE) /*!< Match with the count peak interrupt mask of the counter */
  542. #define TMR4_EVT_MASK_VALLEY (TMR4_SCMR_MZCE) /*!< Match with the count valley interrupt mask of the counter */
  543. #define TMR4_EVT_MASK_TYPE_ALL (TMR4_EVT_MASK_PEAK | TMR4_EVT_MASK_VALLEY)
  544. /**
  545. * @}
  546. */
  547. /**
  548. * @defgroup TMR4_Event_Buffer_Transfer_Condition TMR4 Event Buffer Transfer Condition
  549. * @{
  550. */
  551. #define TMR4_EVT_BUF_COND_IMMED (0U) /*!< Register SCCR&SCMR buffer transfer when writing to the SCCR&SCMR register */
  552. #define TMR4_EVT_BUF_COND_VALLEY (TMR4_SCSR_BUFEN_0) /*!< Register SCCR&SCMR buffer transfer when counter count valley */
  553. #define TMR4_EVT_BUF_COND_PEAK (TMR4_SCSR_BUFEN_1) /*!< Register SCCR&SCMR buffer transfer when counter count peak */
  554. #define TMR4_EVT_BUF_COND_PEAK_VALLEY (TMR4_SCSR_BUFEN) /*!< Register SCCR&SCMR buffer transfer when counter count peak or valley */
  555. /**
  556. * @}
  557. */
  558. /**
  559. * @defgroup TMR4_Event_Mode TMR4 Event Mode
  560. * @{
  561. */
  562. #define TMR4_EVT_MD_CMP (0U) /*!< TMR4 EVT compare mode */
  563. #define TMR4_EVT_MD_DELAY (TMR4_SCSR_EVTMS) /*!< TMR4 EVT delay mode */
  564. /**
  565. * @}
  566. */
  567. /**
  568. * @defgroup TMR4_Event_Delay_Object TMR4 Event Delay Object
  569. * @{
  570. */
  571. #define TMR4_EVT_DELAY_OCCRXH (0U) /*!< TMR4 EVT delay object: OCCRxh(x=u/v/w) */
  572. #define TMR4_EVT_DELAY_OCCRXL (TMR4_SCSR_EVTDS) /*!< TMR4 EVT delay object: OCCRxl(x=u/v/w) */
  573. /**
  574. * @}
  575. */
  576. /**
  577. * @defgroup TMR4_Event_Mask_Times TMR4 Event Mask Times
  578. * @{
  579. */
  580. #define TMR4_EVT_MASK0 (0U << TMR4_SCMR_AMC_POS) /*!< Mask 0 time */
  581. #define TMR4_EVT_MASK1 (1U << TMR4_SCMR_AMC_POS) /*!< Mask 1 times */
  582. #define TMR4_EVT_MASK2 (2U << TMR4_SCMR_AMC_POS) /*!< Mask 2 times */
  583. #define TMR4_EVT_MASK3 (3U << TMR4_SCMR_AMC_POS) /*!< Mask 3 times */
  584. #define TMR4_EVT_MASK4 (4U << TMR4_SCMR_AMC_POS) /*!< Mask 4 times */
  585. #define TMR4_EVT_MASK5 (5U << TMR4_SCMR_AMC_POS) /*!< Mask 5 times */
  586. #define TMR4_EVT_MASK6 (6U << TMR4_SCMR_AMC_POS) /*!< Mask 6 times */
  587. #define TMR4_EVT_MASK7 (7U << TMR4_SCMR_AMC_POS) /*!< Mask 7 times */
  588. #define TMR4_EVT_MASK8 (8U << TMR4_SCMR_AMC_POS) /*!< Mask 8 times */
  589. #define TMR4_EVT_MASK9 (9U << TMR4_SCMR_AMC_POS) /*!< Mask 9 times */
  590. #define TMR4_EVT_MASK10 (10U << TMR4_SCMR_AMC_POS) /*!< Mask 10 times */
  591. #define TMR4_EVT_MASK11 (11U << TMR4_SCMR_AMC_POS) /*!< Mask 11 times */
  592. #define TMR4_EVT_MASK12 (12U << TMR4_SCMR_AMC_POS) /*!< Mask 12 times */
  593. #define TMR4_EVT_MASK13 (13U << TMR4_SCMR_AMC_POS) /*!< Mask 13 times */
  594. #define TMR4_EVT_MASK14 (14U << TMR4_SCMR_AMC_POS) /*!< Mask 14 times */
  595. #define TMR4_EVT_MASK15 (15U << TMR4_SCMR_AMC_POS) /*!< Mask 15 times */
  596. /**
  597. * @}
  598. */
  599. /**
  600. * @defgroup TMR4_Event_Output_Event TMR4 Event Output Event
  601. * @{
  602. */
  603. #define TMR4_EVT_OUTPUT_EVT0 (0U << TMR4_SCSR_EVTOS_POS) /*!< TMR4 event output special event 0 */
  604. #define TMR4_EVT_OUTPUT_EVT1 (1U << TMR4_SCSR_EVTOS_POS) /*!< TMR4 event output special event 1 */
  605. #define TMR4_EVT_OUTPUT_EVT2 (2U << TMR4_SCSR_EVTOS_POS) /*!< TMR4 event output special event 2 */
  606. #define TMR4_EVT_OUTPUT_EVT3 (3U << TMR4_SCSR_EVTOS_POS) /*!< TMR4 event output special event 3 */
  607. #define TMR4_EVT_OUTPUT_EVT4 (4U << TMR4_SCSR_EVTOS_POS) /*!< TMR4 event output special event 4 */
  608. #define TMR4_EVT_OUTPUT_EVT5 (5U << TMR4_SCSR_EVTOS_POS) /*!< TMR4 event output special event 5 */
  609. #define TMR4_EVT_OUTPUT_EVT6 (6U << TMR4_SCSR_EVTOS_POS) /*!< TMR4 event output special event 6 */
  610. #define TMR4_EVT_OUTPUT_EVT7 (7U << TMR4_SCSR_EVTOS_POS) /*!< TMR4 event output special event 7 */
  611. /**
  612. * @}
  613. */
  614. /**
  615. * @defgroup TMR4_Event_Output_Signal TMR4 Event Output Signal
  616. * @{
  617. */
  618. #define TMR4_EVT_OUTPUT_NONE (0U) /*!< Disable output event signal of TMR4 Special-EVT */
  619. #define TMR4_EVT_OUTPUT_EVT0_SIGNAL (1U) /*!< Output the specified event 0 signal of TMR4 Special-EVT */
  620. #define TMR4_EVT_OUTPUT_EVT1_SIGNAL (2U) /*!< Output the specified event 1 signal of TMR4 Special-EVT */
  621. #define TMR4_EVT_OUTPUT_EVT2_SIGNAL (3U) /*!< Output the specified event 2 signal of TMR4 Special-EVT */
  622. #define TMR4_EVT_OUTPUT_EVT3_SIGNAL (4U) /*!< Output the specified event 3 signal of TMR4 Special-EVT */
  623. #define TMR4_EVT_OUTPUT_EVT4_SIGNAL (5U) /*!< Output the specified event 4 signal of TMR4 Special-EVT */
  624. #define TMR4_EVT_OUTPUT_EVT5_SIGNAL (6U) /*!< Output the specified event 5 signal of TMR4 Special-EVT */
  625. #define TMR4_EVT_OUTPUT_EVT6_SIGNAL (8U) /*!< Output the specified event 6 signal of TMR4 Special-EVT */
  626. #define TMR4_EVT_OUTPUT_EVT7_SIGNAL (9U) /*!< Output the specified event 7 signal of TMR4 Special-EVT */
  627. /**
  628. * @}
  629. */
  630. /**
  631. * @}
  632. */
  633. /**
  634. * @}
  635. */
  636. /*******************************************************************************
  637. * Global variable definitions ('extern')
  638. ******************************************************************************/
  639. /*******************************************************************************
  640. Global function prototypes (definition in C source)
  641. ******************************************************************************/
  642. /**
  643. * @addtogroup TMR4_Global_Functions
  644. * @{
  645. */
  646. /**
  647. * @addtogroup TMR4_Counter_Global_Functions
  648. * @{
  649. */
  650. /* Initialization and configuration TMR4 counter functions */
  651. int32_t TMR4_StructInit(stc_tmr4_init_t *pstcTmr4Init);
  652. int32_t TMR4_Init(CM_TMR4_TypeDef *TMR4x, const stc_tmr4_init_t *pstcTmr4Init);
  653. void TMR4_DeInit(CM_TMR4_TypeDef *TMR4x);
  654. void TMR4_SetClockSrc(CM_TMR4_TypeDef *TMR4x, uint16_t u16Src);
  655. void TMR4_SetClockDiv(CM_TMR4_TypeDef *TMR4x, uint16_t u16Div);
  656. void TMR4_SetCountMode(CM_TMR4_TypeDef *TMR4x, uint16_t u16Mode);
  657. uint16_t TMR4_GetPeriodValue(const CM_TMR4_TypeDef *TMR4x);
  658. void TMR4_SetPeriodValue(CM_TMR4_TypeDef *TMR4x, uint16_t u16Value);
  659. uint16_t TMR4_GetCountValue(const CM_TMR4_TypeDef *TMR4x);
  660. void TMR4_SetCountValue(CM_TMR4_TypeDef *TMR4x, uint16_t u16Value);
  661. void TMR4_ClearCountValue(CM_TMR4_TypeDef *TMR4x);
  662. void TMR4_Start(CM_TMR4_TypeDef *TMR4x);
  663. void TMR4_Stop(CM_TMR4_TypeDef *TMR4x);
  664. void TMR4_ClearStatus(CM_TMR4_TypeDef *TMR4x, uint32_t u32Flag);
  665. en_flag_status_t TMR4_GetStatus(const CM_TMR4_TypeDef *TMR4x, uint32_t u32Flag);
  666. void TMR4_IntCmd(CM_TMR4_TypeDef *TMR4x, uint32_t u32IntType, en_functional_state_t enNewState);
  667. void TMR4_PeriodBufCmd(CM_TMR4_TypeDef *TMR4x, en_functional_state_t enNewState);
  668. uint16_t TMR4_GetCountIntMaskTime(const CM_TMR4_TypeDef *TMR4x, uint32_t u32IntType);
  669. void TMR4_SetCountIntMaskTime(CM_TMR4_TypeDef *TMR4x, uint32_t u32IntType, uint16_t u16MaskTime);
  670. uint16_t TMR4_GetCurrentCountIntMaskTime(const CM_TMR4_TypeDef *TMR4x, uint32_t u32IntType);
  671. void TMR4_PortOutputCmd(CM_TMR4_TypeDef *TMR4x, en_functional_state_t enNewState);
  672. void TMR4_SyncStartCmd(CM_TMR4_TypeDef *TMR4x, en_functional_state_t enNewState);
  673. void TMR4_HWStartCmd(CM_TMR4_TypeDef *TMR4x, en_functional_state_t enNewState);
  674. /**
  675. * @}
  676. */
  677. /**
  678. * @addtogroup TMR4_Output_Compare_Global_Functions
  679. * @{
  680. */
  681. /* Initialization and configuration TMR4 Output-Compare functions */
  682. int32_t TMR4_OC_StructInit(stc_tmr4_oc_init_t *pstcTmr4OcInit);
  683. int32_t TMR4_OC_Init(CM_TMR4_TypeDef *TMR4x, uint32_t u32Ch, const stc_tmr4_oc_init_t *pstcTmr4OcInit);
  684. void TMR4_OC_DeInit(CM_TMR4_TypeDef *TMR4x, uint32_t u32Ch);
  685. uint16_t TMR4_OC_GetCompareValue(const CM_TMR4_TypeDef *TMR4x, uint32_t u32Ch);
  686. void TMR4_OC_SetCompareValue(CM_TMR4_TypeDef *TMR4x, uint32_t u32Ch, uint16_t u16Value);
  687. void TMR4_OC_Cmd(CM_TMR4_TypeDef *TMR4x, uint32_t u32Ch, en_functional_state_t enNewState);
  688. void TMR4_OC_ExtendControlCmd(CM_TMR4_TypeDef *TMR4x, uint32_t u32Ch, en_functional_state_t enNewState);
  689. void TMR4_OC_BufIntervalReponseCmd(CM_TMR4_TypeDef *TMR4x, uint32_t u32Ch,
  690. uint16_t u16Object, en_functional_state_t enNewState);
  691. uint16_t TMR4_OC_GetPolarity(const CM_TMR4_TypeDef *TMR4x, uint32_t u32Ch);
  692. void TMR4_OC_SetOcInvalidPolarity(CM_TMR4_TypeDef *TMR4x, uint32_t u32Ch, uint16_t u16Polarity);
  693. void TMR4_OC_SetCompareBufCond(CM_TMR4_TypeDef *TMR4x, uint32_t u32Ch, uint16_t u16Object, uint16_t u16BufCond);
  694. uint16_t TMR4_OC_GetHighChCompareMode(const CM_TMR4_TypeDef *TMR4x, uint32_t u32Ch);
  695. void TMR4_OC_SetHighChCompareMode(CM_TMR4_TypeDef *TMR4x, uint32_t u32Ch, un_tmr4_oc_ocmrh_t unTmr4Ocmrh);
  696. uint32_t TMR4_OC_GetLowChCompareMode(const CM_TMR4_TypeDef *TMR4x, uint32_t u32Ch);
  697. void TMR4_OC_SetLowChCompareMode(CM_TMR4_TypeDef *TMR4x, uint32_t u32Ch, un_tmr4_oc_ocmrl_t unTmr4Ocmrl);
  698. /**
  699. * @}
  700. */
  701. /**
  702. * @addtogroup TMR4_PWM_Global_Functions
  703. * @{
  704. */
  705. /* Initialization and configuration TMR4 PWM functions */
  706. int32_t TMR4_PWM_StructInit(stc_tmr4_pwm_init_t *pstcTmr4PwmInit);
  707. int32_t TMR4_PWM_Init(CM_TMR4_TypeDef *TMR4x, uint32_t u32Ch, const stc_tmr4_pwm_init_t *pstcTmr4PwmInit);
  708. void TMR4_PWM_DeInit(CM_TMR4_TypeDef *TMR4x, uint32_t u32Ch);
  709. void TMR4_PWM_SetClockDiv(CM_TMR4_TypeDef *TMR4x, uint32_t u32Ch, uint16_t u16Div);
  710. void TMR4_PWM_SetPolarity(CM_TMR4_TypeDef *TMR4x, uint32_t u32Ch, uint16_t u16Polarity);
  711. void TMR4_PWM_StartReloadTimer(CM_TMR4_TypeDef *TMR4x, uint32_t u32Ch);
  712. void TMR4_PWM_StopReloadTimer(CM_TMR4_TypeDef *TMR4x, uint32_t u32Ch);
  713. void TMR4_PWM_SetFilterCountValue(CM_TMR4_TypeDef *TMR4x, uint32_t u32Ch, uint16_t u16Value);
  714. void TMR4_PWM_SetDeadTimeValue(CM_TMR4_TypeDef *TMR4x, uint32_t u32Ch, uint32_t u32DeadTimeIndex, uint16_t u16Value);
  715. uint16_t TMR4_PWM_GetDeadTimeValue(const CM_TMR4_TypeDef *TMR4x, uint32_t u32Ch, uint32_t u32DeadTimeIndex);
  716. void TMR4_PWM_SetAbnormalPinStatus(CM_TMR4_TypeDef *TMR4x, uint32_t u32PwmPin, uint32_t u32PinStatus);
  717. void TMR4_PWM_SetOEEffectTime(CM_TMR4_TypeDef *TMR4x, uint32_t u32Time);
  718. void TMR4_PWM_EmbHWMainOutputCmd(CM_TMR4_TypeDef *TMR4x, en_functional_state_t enNewState);
  719. void TMR4_PWM_MainOutputCmd(CM_TMR4_TypeDef *TMR4x, en_functional_state_t enNewState);
  720. void TMR4_PWM_SetPortOutputMode(CM_TMR4_TypeDef *TMR4x, uint32_t u32PwmPin, uint32_t u32Mode);
  721. /**
  722. * @}
  723. */
  724. /**
  725. * @addtogroup TMR4_Event_Global_Functions
  726. * @{
  727. */
  728. /* Initialization and configuration TMR4 event functions */
  729. int32_t TMR4_EVT_StructInit(stc_tmr4_evt_init_t *pstcTmr4EventInit);
  730. int32_t TMR4_EVT_Init(CM_TMR4_TypeDef *TMR4x, uint32_t u32Ch, const stc_tmr4_evt_init_t *pstcTmr4EventInit);
  731. void TMR4_EVT_DeInit(CM_TMR4_TypeDef *TMR4x, uint32_t u32Ch);
  732. void TMR4_EVT_SetDelayObject(CM_TMR4_TypeDef *TMR4x, uint32_t u32Ch, uint16_t u16Object);
  733. void TMR4_EVT_SetMaskTime(CM_TMR4_TypeDef *TMR4x, uint32_t u32Ch, uint16_t u16MaskTime);
  734. uint16_t TMR4_EVT_GetMaskTime(const CM_TMR4_TypeDef *TMR4x, uint32_t u32Ch);
  735. void TMR4_EVT_SetCompareValue(CM_TMR4_TypeDef *TMR4x, uint32_t u32Ch, uint16_t u16Value);
  736. uint16_t TMR4_EVT_GetCompareValue(const CM_TMR4_TypeDef *TMR4x, uint32_t u32Ch);
  737. void TMR4_EVT_SetOutputEvent(CM_TMR4_TypeDef *TMR4x, uint32_t u32Ch, uint16_t u16Event);
  738. void TMR4_EVT_SetCompareBufCond(CM_TMR4_TypeDef *TMR4x, uint32_t u32Ch, uint16_t u16BufCond);
  739. void TMR4_EVT_BufIntervalReponseCmd(CM_TMR4_TypeDef *TMR4x, uint32_t u32Ch, en_functional_state_t enNewState);
  740. void TMR4_EVT_EventIntervalReponseCmd(CM_TMR4_TypeDef *TMR4x, uint32_t u32Ch,
  741. uint16_t u16MaskType, en_functional_state_t enNewState);
  742. void TMR4_EVT_MatchCondCmd(CM_TMR4_TypeDef *TMR4x, uint32_t u32Ch, uint16_t u16Cond, en_functional_state_t enNewState);
  743. void TMR4_EVT_SetOutputEventSignal(CM_TMR4_TypeDef *TMR4x, uint16_t u16Signal);
  744. /**
  745. * @}
  746. */
  747. /**
  748. * @}
  749. */
  750. #endif /* LL_TMR4_ENABLE */
  751. /**
  752. * @}
  753. */
  754. /**
  755. * @}
  756. */
  757. #ifdef __cplusplus
  758. }
  759. #endif
  760. #endif /* __HC32_LL_TMR4_H__ */
  761. /*******************************************************************************
  762. * EOF (not truncated)
  763. ******************************************************************************/