hc32f460_timer6.h 34 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734
  1. /*******************************************************************************
  2. * Copyright (C) 2020, Huada Semiconductor Co., Ltd. All rights reserved.
  3. *
  4. * This software component is licensed by HDSC under BSD 3-Clause license
  5. * (the "License"); You may not use this file except in compliance with the
  6. * License. You may obtain a copy of the License at:
  7. * opensource.org/licenses/BSD-3-Clause
  8. */
  9. /******************************************************************************/
  10. /** \file hc32f460_timer6.h
  11. **
  12. ** A detailed description is available at
  13. ** @link Timer6Group Timer 6 description @endlink
  14. **
  15. ** - 2018-11-19 CDT First version for Device Driver Library of Timer6.
  16. **
  17. ******************************************************************************/
  18. #ifndef __HC32F460_TIMER6_H__
  19. #define __HC32F460_TIMER6_H__
  20. /*******************************************************************************
  21. * Include files
  22. ******************************************************************************/
  23. #include "hc32_common.h"
  24. #include "ddl_config.h"
  25. #if (DDL_TIMER6_ENABLE == DDL_ON)
  26. /* C binding of definitions if building with C++ compiler */
  27. #ifdef __cplusplus
  28. extern "C" {
  29. #endif
  30. /**
  31. *******************************************************************************
  32. ** \defgroup Timer6Group Timer6
  33. **
  34. ******************************************************************************/
  35. //@{
  36. /*******************************************************************************
  37. * Global type definitions ('typedef')
  38. ******************************************************************************/
  39. /**
  40. *******************************************************************************
  41. ** \brief Timer6 channel enumeration
  42. ******************************************************************************/
  43. /**
  44. ******************************************************************************
  45. ** \brief Timer6 PWMx port define
  46. *****************************************************************************/
  47. typedef enum en_timer6_chx_port
  48. {
  49. Timer6PWMA = 0u, ///< PWM A port
  50. Timer6PWMB = 1u, ///< PWM B port
  51. }en_timer6_chx_port_t;
  52. /**
  53. ******************************************************************************
  54. ** \brief Timer6 TRIG port define
  55. *****************************************************************************/
  56. typedef enum en_timer6_input_port
  57. {
  58. Timer6xCHA = 0u, ///< PWM A port
  59. Timer6xCHB = 1u, ///< PWM B port
  60. Timer6TrigA = 2u, ///< Timer6x trigger A port
  61. Timer6TrigB = 3u, ///< Timer6x trigger B port
  62. }en_timer6_input_port_t;
  63. /**
  64. ******************************************************************************
  65. ** \brief Timer6 general control - Z Phase input mask periods
  66. **
  67. ** \note
  68. ******************************************************************************/
  69. typedef enum en_timer6_gconr_zmsk
  70. {
  71. Timer6ZMaskDis = 0u, ///< Z Phase input mask disable
  72. Timer6ZMask4Cyl = 1u, ///< Mask Z phase input during 4 periods when over fllow or under fllow of position count
  73. Timer6ZMask8Cyl = 2u, ///< Mask Z phase input during 8 periods when over fllow or under fllow of position count
  74. Tiemr6ZMask16Cyl = 3u, ///< Mask Z phase input during 16 periods when over fllow or under fllow of position count
  75. }en_timer6_gconr_zmsk_t;
  76. /**
  77. *******************************************************************************
  78. ** \brief Clock division enumeration
  79. ******************************************************************************/
  80. typedef enum en_timer6_clk_div
  81. {
  82. Timer6PclkDiv1 = 0u, ///< Count clock: pclk
  83. Timer6PclkDiv2 = 1u, ///< Count clock: pclk/2
  84. Timer6PclkDiv4 = 2u, ///< Count clock: pclk/4
  85. Timer6PclkDiv8 = 3u, ///< Count clock: pclk/8
  86. Timer6PclkDiv16 = 4u, ///< Count clock: pclk/16
  87. Timer6PclkDiv64 = 5u, ///< Count clock: pclk/64
  88. Timer6PclkDiv256 = 6u, ///< Count clock: pclk/256
  89. Timer6PclkDiv1024 = 7u, ///< Count clock: pclk/1024
  90. } en_timer6_clk_div_t;
  91. /**
  92. *******************************************************************************
  93. ** \brief Count mode enumeration
  94. ******************************************************************************/
  95. typedef enum en_timer6_count_mode
  96. {
  97. Timer6CntSawtoothMode = 0u, ///< Sawtooth wave mode
  98. Timer6CntTriangularModeA = 4u, ///< Triangular wave mode
  99. Timer6CntTriangularModeB = 5u, ///< Triangular wave mode
  100. } en_timer6_count_mode_t;
  101. /**
  102. *******************************************************************************
  103. ** \brief Count direction enumeration
  104. ******************************************************************************/
  105. typedef enum en_timer6_count_dir
  106. {
  107. Timer6CntDirDown = 0u, ///< Counter counting up
  108. Timer6CntDirUp = 1u, ///< Counter counting down
  109. } en_timer6_count_dir_t;
  110. /**
  111. ******************************************************************************
  112. ** \brief Timer6 period register
  113. **
  114. ** \note
  115. ******************************************************************************/
  116. typedef enum en_timer6_period
  117. {
  118. Timer6PeriodA = 0u, ///< Period Register A
  119. Timer6PeriodB = 1u, ///< Period Register B
  120. Timer6PeriodC = 2u, ///< Period Register C
  121. }en_timer6_period_t;
  122. /**
  123. ******************************************************************************
  124. ** \brief Timer6 general compare match register
  125. **
  126. ** \note
  127. ******************************************************************************/
  128. typedef enum en_timer6_compare
  129. {
  130. Timer6GenCompareA = 0u, ///< General Compare Match A Register
  131. Timer6GenCompareB = 1u, ///< General Compare Match B Register
  132. Timer6GenCompareC = 2u, ///< General Compare Match C Register
  133. Timer6GenCompareD = 3u, ///< General Compare Match D Register
  134. Timer6GenCompareE = 4u, ///< General Compare Match E Register
  135. Timer6GenCompareF = 5u, ///< General Compare Match F Register
  136. }en_timer6_compare_t;
  137. /**
  138. ******************************************************************************
  139. ** \brief Timer6 special compare match register
  140. **
  141. ** \note
  142. ******************************************************************************/
  143. typedef enum en_timer6_special_compare
  144. {
  145. Timer6SpclCompA = 0u, ///< Special Compare Match A Register
  146. Timer6SpclCompB = 1u, ///< Special Compare Match B Register
  147. Timer6SpclCompC = 2u, ///< Special Compare Match C Register
  148. Timer6SpclCompD = 3u, ///< Special Compare Match D Register
  149. Timer6SpclCompE = 4u, ///< Special Compare Match E Register
  150. Timer6SpclCompF = 5u, ///< Special Compare Match F Register
  151. }en_timer6_special_compare_t;
  152. /**
  153. ******************************************************************************
  154. ** \brief Timer6 dead timer value register
  155. **
  156. ** \note
  157. ******************************************************************************/
  158. typedef enum en_timer6_dead_time_reg
  159. {
  160. Timer6DeadTimUpAR = 0u, ///< Dead timer for up count A Register
  161. Timer6DeadTimUpBR = 1u, ///< Dead timer for up count B Register
  162. Timer6DeadTimDwnAR = 2u, ///< Dead timer for down count A Register
  163. Timer6DeadTimDwnBR = 3u, ///< Dead timer for down count B Register
  164. }en_timer6_dead_time_reg_t;
  165. /**
  166. ******************************************************************************
  167. ** \brief Timer6 port control - port output control of brake status
  168. **
  169. ** \note
  170. ******************************************************************************/
  171. typedef enum en_timer6_pconr_disval
  172. {
  173. Timer6PWMxDisValNorm = 0u, ///< PWMx port output normal when brake
  174. Timer6PWMxDisValHiZ = 1u, ///< PWMx port Hi-z when brake
  175. Timer6PWMxDisValLow = 2u, ///< PWMx port output low level when brake
  176. Timer6PWMxDisValHigh = 3u, ///< PWMx port output high level when brake
  177. }en_timer6_pconr_disval_t;
  178. /**
  179. ******************************************************************************
  180. ** \brief Timer6 port - PWMx port output status when CNTER value match GCMxR or PERAR
  181. **
  182. ** \note
  183. ******************************************************************************/
  184. typedef enum en_timer6_pconr_cmpc
  185. {
  186. Timer6PWMxCompareLow = 0u, ///< PWMx port output Low level when CNTER value match with GCMxR or PERAR
  187. Timer6PWMxCompareHigh = 1u, ///< PWMx port output high level when CNTER value match with GCMxR or PERAR
  188. Timer6PWMxCompareKeep = 2u, ///< PWMx port output keep former level when CNTER value match GCMxR or PERAR
  189. Timer6PWMxCompareInv = 3u, ///< PWMx port output inverse level when CNTER value match with GCMxR or PERAR
  190. }en_timer6_pconr_cmpc_t;
  191. /**
  192. ******************************************************************************
  193. ** \brief Timer6 port- PWMx port output set(STA STP)
  194. **
  195. ** \note
  196. ******************************************************************************/
  197. typedef enum en_timer6_pconr_port_out
  198. {
  199. Timer6PWMxPortOutLow = 0u, ///< PWMx port output set low level
  200. Timer6PWMxPortOutHigh = 1u, ///< PWMx port output set high level
  201. }en_timer6_pconr_port_out_t;
  202. /**
  203. *******************************************************************************
  204. ** \brief Timer6 function mode selection enumeration
  205. ******************************************************************************/
  206. typedef enum en_timer6_func_mode
  207. {
  208. Timer6ModeCompareOutput = 0u, ///< Compare output function
  209. Timer6ModeCaptureInput = 1u, ///< Capture input function
  210. } en_timer6_func_mode_t;
  211. /**
  212. ******************************************************************************
  213. ** \brief Timer6 port - PWMx STA STP function selection
  214. **
  215. ** \note
  216. ******************************************************************************/
  217. typedef enum en_timer6_pconr_stastps
  218. {
  219. Timer6PWMxStateSelSS = 0u, ///< PWMx output status is decide by STACx STPCx when CNTER start and stop
  220. Timer6PWMxStateSelKeep = 1u, ///< PWMx output status keep former level when CNTER start and stop
  221. }en_timer6_pconr_stastps_t;
  222. /**
  223. ******************************************************************************
  224. ** \brief Timer6 buffer - General compare register / Period register transfer function selection
  225. **
  226. ** \note
  227. ** For General compare register:
  228. ** Single buffer stransfer: Compare Ouput: GCMCR-->GCMAR / GCMDR-->GCMBR Capture Input: GCMAR-->GCMCR / GCMDR-->GCMBR
  229. ** Double buffer stransfer: Compare Ouput: GCMER-->GCMCR-->GCMAR / GCMFR-->GCMDR-->GCMBR Capture Input: GCMAR-->GCMCR-->GCMER /GCMFR-->GCMDR-->GCMBR
  230. ** For Period register:
  231. ** Single buffer stransfer: PERBR-->PERAR
  232. ** Double buffer stransfer: PERCR-->PERBR-->PERAR
  233. ******************************************************************************/
  234. typedef enum en_timer6_buf_gcmp_prd
  235. {
  236. Timer6GcmpPrdSingleBuf = 0u, ///< Single buffer stransfer
  237. Timer6GcmpPrdDoubleBuf = 1u, ///< Double buffer stransfer
  238. }en_timer6_buf_gcmp_prd_t;
  239. /**
  240. ******************************************************************************
  241. ** \brief Timer6 buffer - Special compare register transfer function selection
  242. **
  243. ** \note
  244. ******************************************************************************/
  245. typedef enum en_timer6_buf_spcl_cmp
  246. {
  247. Timer6SpclSingleBuf = 0u, ///< Single buffer stransfer: Compare Ouput: SCMCR-->SCMAR / SCMDR-->SCMBR
  248. Timer6SpclDoubleBuf = 1u, ///< Double buffer stransfer: Compare Ouput: SCMER-->SCMCR-->SCMAR / SCMFR-->SCMDR-->SCMBR
  249. }en_timer6_buf_spcl_cmp_t;
  250. /**
  251. ******************************************************************************
  252. ** \brief Timer6 buffer - Special compare register transfer opportunity selection
  253. **
  254. ** \note
  255. ******************************************************************************/
  256. typedef enum en_timer6_buf_spcl_opt
  257. {
  258. Timer6SplcOptNone = 0u, ///< No transfer
  259. Timer6SplcOptOverFlow = 1u, ///< Transfer when over flow (About sawtooth mode,accord to the count direction)
  260. Timer6SplcOptUnderFlow = 2u, ///< Transfer when under flow (About sawtooth mode,accord to the count direction)
  261. Timer6SplcOptBoth = 3u, ///< Transfer when over flow or under flow (About sawtooth mode,accord to the count direction)
  262. }en_timer6_buf_spcl_opt_t;
  263. /**
  264. ******************************************************************************
  265. ** \brief ADT dead timer control - PWMx dead timer separate set
  266. **
  267. ** \note
  268. ******************************************************************************/
  269. typedef enum en_timer6_dconr_sepa
  270. {
  271. Timer6PWMxDtSeparate = 0u, ///< The dead timer of up count and down count separate set by DTUAR and DTDAR
  272. Timer6PWMxDtEqual = 1u, ///< the values of DTUAR and DTDAR are equal automatically
  273. }en_timer6_dconr_sepa_t;
  274. /**
  275. ******************************************************************************
  276. ** \brief ADT filter control- TRIx/PWMx port filter sample clock selection
  277. **
  278. ** \note
  279. ******************************************************************************/
  280. typedef enum en_timer6_fconr_fltclk
  281. {
  282. Timer6FltClkPclk0Div1 = 0u, ///< PCLK0
  283. Timer6FltClkPclk0Div4 = 1u, ///< PCLK0/4
  284. Timer6FltClkPclk0Div16 = 2u, ///< PCLK0/16
  285. Timer6FltClkPclk0Div64 = 3u, ///< PCLK0/64
  286. }en_timer6_fconr_fltclk_t;
  287. /**
  288. ******************************************************************************
  289. ** \brief Timer6 valid period repeat- TIMx valid period repeat function selection(trigger interrupt or AOS event)
  290. **
  291. ** \note
  292. ******************************************************************************/
  293. typedef enum en_timer6_vperr_pcnts
  294. {
  295. Timer6PeriodCnts0 = 0u, ///< Valid period repeat function disable
  296. Timer6PeriodCnts1 = 1u, ///< Enable every other one period
  297. Timer6PeriodCnts2 = 2u, ///< Enable every other two periods
  298. Timer6PeriodCnts3 = 3u, ///< Enable every other three periods
  299. Timer6PeriodCnts4 = 4u, ///< Enable every other four periods
  300. Timer6PeriodCnts5 = 5u, ///< Enable every other five periods
  301. Timer6PeriodCnts6 = 6u, ///< Enable every other six periods
  302. Timer6PeriodCnts7 = 7u, ///< Enable every other seven periods
  303. }en_timer6_vperr_pcnts_t;
  304. /**
  305. ******************************************************************************
  306. ** \brief Timer6 valid period repeat- Count condition select
  307. **
  308. ** \note
  309. ******************************************************************************/
  310. typedef enum en_timer6_vperr_pcnte
  311. {
  312. Timer6PeriodCnteDisable = 0u, ///< Valid period repeat function disable
  313. Timer6PeriodCnteMin = 1u, ///< Over flow and under flow point of Sawtooth wave mode, or under flow point of Triangular wave mode
  314. Timer6PeriodCnteMax = 2u, ///< Over flow and under flow point of Sawtooth wave mode, or voer flow point of Triangular wave mode
  315. Timer6PeriodCnteBoth = 3u, ///< Over flow and under flow point of Sawtooth wave mode, or voer flow and under flow point of Triangular wave mode
  316. }en_timer6_vperr_pcnte_t;
  317. /**
  318. ******************************************************************************
  319. ** \brief Timer6 Hardware(Start/Stop/Clear/Capture) event trigger select
  320. **
  321. ** \note
  322. ******************************************************************************/
  323. typedef enum en_timer6_hw_trig
  324. {
  325. Timer6HwTrigAos0 = 0u, ///< Hardware trigger event from AOS0(HTSSR0)
  326. Timer6HwTrigAos1 = 1u, ///< Hardware trigger event from AOS1(HTSSR1)
  327. Timer6HwTrigPWMARise = 4u, ///< Hardware trigger event from PWMA rising
  328. Timer6HwTrigPWMAFall = 5u, ///< Hardware trigger event from PWMA falling
  329. Timer6HwTrigPWMBRise = 6u, ///< Hardware trigger event from PWMA rising
  330. Timer6HwTrigPWMBFall = 7u, ///< Hardware trigger event from PWMA falling
  331. Timer6HwTrigTimTriARise = 8u, ///< Hardware trigger event from TRIGA rising
  332. Timer6HwTrigTimTriAFall = 9u, ///< Hardware trigger event from TRIGA falling
  333. Timer6HwTrigTimTriBRise = 10u, ///< Hardware trigger event from TRIGB rising
  334. Timer6HwTrigTimTriBFall = 11u, ///< Hardware trigger event from TRIGB falling
  335. Timer6HwTrigEnd = 16u,
  336. }en_timer6_hw_trig_t;
  337. /**
  338. ******************************************************************************
  339. ** \brief Timer6 hardware (up count/down count) event trigger select
  340. **
  341. ** \note
  342. ******************************************************************************/
  343. typedef enum en_timer6_hw_cnt
  344. {
  345. Timer6HwCntPWMALowPWMBRise = 0u, ///< PWMB Rising trigger when PWMA is low level
  346. Timer6HwCntPWMALowPWMBFall = 1u, ///< PWMB falling trigger when PWMA is low level
  347. Timer6HwCntPWMAHighPWMBRise = 2u, ///< PWMB Rising trigger when PWMA is high level
  348. Timer6HwCntPWMAHighPWMBFall = 3u, ///< PWMB falling trigger when PWMA is high level
  349. Timer6HwCntPWMBLowPWMARise = 4u, ///< PWMA Rising trigger when PWMB is low level
  350. Timer6HwCntPWMBLowPWMAFall = 5u, ///< PWMA falling trigger when PWMB is low level
  351. Timer6HwCntPWMBHighPWMARise = 6u, ///< PWMA Rising trigger when PWMB is high level
  352. Timer6HwCntPWMBHighPWMAFall = 7u, ///< PWMA falling trigger when PWMB is high level
  353. Timer6HwCntTRIGARise = 8u, ///< TRIGA rising trigger
  354. Timer6HwCntTRIGAFall = 9u, ///< TRIGA falling trigger
  355. Timer6HwCntTRIGBRise = 10u, ///< TRIGB rising trigger
  356. Timer6HwCntTRIGBFall = 11u, ///< TRIGB falling trigger
  357. Timer6HwCntAos0 = 16u, ///< AOS0 trigger
  358. Timer6HwCntAos1 = 17u, ///< AOS1 trigger
  359. Timer6HwCntMax = 18u,
  360. }en_timer6_hw_cnt_t;
  361. /**
  362. ******************************************************************************
  363. ** \brief Timer6 interrupt type
  364. **
  365. ** \note
  366. ******************************************************************************/
  367. typedef enum en_timer6_irq_type
  368. {
  369. Timer6INTENA = 0u, ///< Interrupt of count equal to GCMA (or capture input A)
  370. Timer6INTENB = 1u, ///< Interrupt of count equal to GCMB (or capture input B)
  371. Timer6INTENC = 2u, ///< Interrupt of count equal to GCMC
  372. Timer6INTEND = 3u, ///< Interrupt of count equal to GCMD
  373. Timer6INTENE = 4u, ///< Interrupt of count equal to GCME
  374. Timer6INTENF = 5u, ///< Interrupt of count equal to GCMF
  375. Timer6INTENOVF = 6u, ///< Interrupt of over flow of sawtooth wave mode or peak point of triangular wave mode
  376. Timer6INTENUDF = 7u, ///< Interrupt of under flow of sawtooth wave mode or valley point of triangular wave mode
  377. Timer6INTENDTE = 8u, ///< Interrupt of dead timer error
  378. Timer6INTENSAU = 16u, ///< Interrupt of count up equally compared with SCMA
  379. Timer6INTENSAD = 17u, ///< Interrupt of count down equally compared with SCMA
  380. Timer6INTENSBU = 18u, ///< Interrupt of count up equally compared with SCMB
  381. Timer6INTENSBD = 19u, ///< Interrupt of count down equally compared with SCMB
  382. }en_timer6_irq_type_t;
  383. /**
  384. ******************************************************************************
  385. ** \brief Timer6 status flag
  386. **
  387. ** \note
  388. ******************************************************************************/
  389. typedef enum en_timer6_status
  390. {
  391. Timer6CMAF = 0u, ///< Status flag of count equal to GCMA (or capture input A)
  392. Timer6CMBF = 1u, ///< Status flag of count equal to GCMB (or capture input B)
  393. Timer6CMCF = 2u, ///< Status flag of count equal to GCMC
  394. Timer6CMDF = 3u, ///< Status flag of count equal to GCMD
  395. Timer6CMEF = 4u, ///< Status flag of count equal to GCME
  396. Timer6CMFF = 5u, ///< Status flag of count equal to GCMF
  397. Timer6OVFF = 6u, ///< Status flag of over flow of sawtooth wave mode or peak point of triangular wave mode
  398. Timer6UDFF = 7u, ///< Status flag of under flow of sawtooth wave mode or valley point of triangular wave mode
  399. Timer6DTEF = 8u, ///< Status flag of dead timer error
  400. Timer6CMSAUF = 9u, ///< Status flag of count up equally compared with SCMA
  401. Timer6CMSADF = 10u, ///< Status flag of count down equally compared with SCMA
  402. Timer6CMSBUF = 11u, ///< Status flag of count up equally compared with SCMB
  403. Timer6CMSBDF = 12u, ///< Status flag of count down equally compared with SCMB
  404. Timer6VPERNUM = 21, ///< Number of valid period
  405. Timer6DIRF = 31, ///< Count direction
  406. }en_timer6_status_t;
  407. /**
  408. *******************************************************************************
  409. ** \brief Timer6 common trigger source select enumeration
  410. **
  411. ******************************************************************************/
  412. typedef enum en_timer6_com_trigger
  413. {
  414. Timer6ComTrigger_1 = 1u, ///< Select common trigger 1.
  415. Timer6ComTrigger_2 = 2u, ///< Select common trigger 2.
  416. Timer6ComTrigger_1_2 = 3u, ///< Select common trigger 1 and 2.
  417. } en_timer6_com_trigger_t;
  418. /**
  419. ******************************************************************************
  420. ** \brief Timer6 software synchronous config
  421. ** \note
  422. ******************************************************************************/
  423. typedef struct stc_timer6_sw_sync
  424. {
  425. bool bTimer61; ///< Timer6 unit1
  426. bool bTimer62; ///< Timer6 unit2
  427. bool bTimer63; ///< Timer6 unit3
  428. }stc_timer6_sw_sync_t;
  429. /**
  430. ******************************************************************************
  431. ** \brief Timer6 base init structure definition
  432. ** \note
  433. ******************************************************************************/
  434. typedef struct stc_timer6_basecnt_cfg
  435. {
  436. en_timer6_count_mode_t enCntMode; ///< Count mode
  437. en_timer6_count_dir_t enCntDir; ///< Count direction
  438. en_timer6_clk_div_t enCntClkDiv; ///< Count clock division select
  439. }stc_timer6_basecnt_cfg_t;
  440. /**
  441. ******************************************************************************
  442. ** \brief Timer6 Trig port config
  443. ** \note
  444. ******************************************************************************/
  445. typedef struct stc_timer6_port_trig_cfg
  446. {
  447. bool bFltEn; ///< trig source capture input filter enable
  448. en_timer6_fconr_fltclk_t enFltClk; ///< Filter clock
  449. }stc_tiemr6_port_trig_cfg_t;
  450. /**
  451. ******************************************************************************
  452. ** \brief Timer6 port output config
  453. ** \note
  454. ******************************************************************************/
  455. typedef struct stc_timer6_port_output_cfg
  456. {
  457. en_timer6_func_mode_t enPortMode; ///< Port mode
  458. bool bOutEn; ///< Output enable / disable
  459. en_timer6_pconr_cmpc_t enPerc; ///< Port state when counter match the period
  460. en_timer6_pconr_cmpc_t enCmpc; ///< Port state when counter match GCMAR(GCMBR)
  461. en_timer6_pconr_stastps_t enStaStp; ///< Post state selection when count start/stop
  462. en_timer6_pconr_port_out_t enStaOut; ///< Port state when count start
  463. en_timer6_pconr_port_out_t enStpOut; ///< port stop when count stop
  464. en_timer6_pconr_disval_t enDisVal; ///< Port output state when brake
  465. }stc_timer6_port_output_cfg_t;
  466. /**
  467. ******************************************************************************
  468. ** \brief Timer6 port input config
  469. ** \note
  470. ******************************************************************************/
  471. typedef struct stc_timer6_port_input_cfg
  472. {
  473. en_timer6_input_port_t enPortSel; ///< Port select
  474. en_timer6_func_mode_t enPortMode; ///< Port mode
  475. bool bFltEn; ///< trig source capture input filter enable
  476. en_timer6_fconr_fltclk_t enFltClk; ///< Filter clock
  477. }stc_timer6_port_input_cfg_t;
  478. /**
  479. ******************************************************************************
  480. ** \brief Timer6 hardware dead time function config
  481. ** \note
  482. ******************************************************************************/
  483. typedef struct stc_timer6_deadtime_cfg
  484. {
  485. bool bEnDeadtime; ///< Enable hardware dead time function
  486. bool bEnDtBufUp; ///< Enable buffer transfer for up count dead time register(DTUBR-->DTUAR)
  487. bool bEnDtBufDwn; ///< Enable buffer transfer for down count dead time register(DTDBR-->DTDAR)
  488. bool bEnDtEqualUpDwn; ///< Enable down count dead time register equal to up count DT register
  489. }stc_timer6_deadtime_cfg_t;
  490. /**
  491. ******************************************************************************
  492. ** \brief Timer6 valid period config
  493. ** \note
  494. ******************************************************************************/
  495. typedef struct stc_timer6_validper_cfg
  496. {
  497. en_timer6_vperr_pcnts_t enValidCntNum; ///< Valid period selection
  498. en_timer6_vperr_pcnte_t enValidCdtEn; ///< Count condition of valid period
  499. bool bPeriodSCMA; ///< Sepcial signal A valid period selection enable
  500. bool bPeriodSCMB; ///< Sepcial signal A valid period selection enable
  501. }stc_timer6_validper_cfg_t;
  502. /**
  503. ******************************************************************************
  504. ** \brief Timer6 general compare register buffer transfer config
  505. ** \note
  506. ******************************************************************************/
  507. typedef struct stc_timer6_gcmp_buf_cfg
  508. {
  509. bool bEnGcmpTransBuf; ///< Enable/Disable buffer transfer
  510. en_timer6_buf_gcmp_prd_t enGcmpBufTransType; ///< Sigle or double buffer transfer
  511. }stc_timer6_gcmp_buf_cfg_t;
  512. /**
  513. ******************************************************************************
  514. ** \brief Timer6 period register buffer transfer config
  515. ** \note
  516. ******************************************************************************/
  517. typedef struct stc_timer6_period_buf_cfg
  518. {
  519. bool bEnPeriodTransBuf; ///< Enable/Disable buffer transfer
  520. en_timer6_buf_gcmp_prd_t enPeriodBufTransType; ///< Sigle or double buffer transfer
  521. }stc_timer6_period_buf_cfg_t;
  522. /**
  523. ******************************************************************************
  524. ** \brief Timer6 Specila compare register buffer transfer config
  525. ** \note
  526. ******************************************************************************/
  527. typedef struct stc_timer6_spcl_buf_cfg
  528. {
  529. bool bEnSpclTransBuf; ///< Enable/Disable buffer transfer
  530. en_timer6_buf_spcl_cmp_t enSpclBufTransType; ///< Sigle or double buffer transfer
  531. en_timer6_buf_spcl_opt_t enSpclBufOptType; ///< Buffer transfer opportunity
  532. }stc_timer6_spcl_buf_cfg_t;
  533. /**
  534. ******************************************************************************
  535. ** \brief Timer6 Z phase input mask config
  536. ** \note
  537. ******************************************************************************/
  538. typedef struct stc_timer6_zmask_cfg
  539. {
  540. en_timer6_gconr_zmsk_t enZMaskCycle; ///< Z phase input mask periods selection
  541. bool bFltPosCntMaksEn; ///< As position count timer, position counter clear function enable(TRUE) or disable(FALSE) during the time of Z phase input mask
  542. bool bFltRevCntMaksEn; ///< As revolution count timer, the counter function enable(TRUE) or disable(FALSE) during the time of Z phase input mask
  543. }stc_timer6_zmask_cfg_t;
  544. /*******************************************************************************
  545. * Global pre-processor symbols/macros ('#define')
  546. ******************************************************************************/
  547. /*******************************************************************************
  548. * Global variable definitions ('extern')
  549. ******************************************************************************/
  550. /*******************************************************************************
  551. Global function prototypes (definition in C source)
  552. ******************************************************************************/
  553. /* IRQ config */
  554. en_result_t Timer6_ConfigIrq(M4_TMR6_TypeDef *TMR6x, en_timer6_irq_type_t enTimer6Irq, bool bEn);
  555. /* Get status(flag) */
  556. uint8_t Timer6_GetStatus(M4_TMR6_TypeDef *TMR6x, en_timer6_status_t enStatus);
  557. /* Base functions */
  558. en_result_t Timer6_DeInit(M4_TMR6_TypeDef *TMR6x);
  559. en_result_t Timer6_Init(M4_TMR6_TypeDef *TMR6x, const stc_timer6_basecnt_cfg_t* pstcTimer6BaseCntCfg);
  560. /* Timer6 unit start count*/
  561. en_result_t Timer6_StartCount(M4_TMR6_TypeDef *TMR6x);
  562. /* Timer6 unit stop count*/
  563. en_result_t Timer6_StopCount(M4_TMR6_TypeDef *TMR6x);
  564. /* Timer6 unit Set Count Value*/
  565. en_result_t Timer6_SetCount(M4_TMR6_TypeDef *TMR6x, uint16_t u16Value);
  566. /* Timer6 unit Get Count Value*/
  567. uint16_t Timer6_GetCount(M4_TMR6_TypeDef *TMR6x);
  568. /* Timer6 unit Clear Count Value*/
  569. en_result_t Timer6_ClearCount(M4_TMR6_TypeDef *TMR6x);
  570. /* Timer6 unit Set Period and buffer Value*/
  571. en_result_t Timer6_SetPeriod(M4_TMR6_TypeDef *TMR6x, en_timer6_period_t enTimer6Periodx, uint16_t u16Period);
  572. /* Timer6 unit set general compare register value*/
  573. en_result_t Timer6_SetGeneralCmpValue(M4_TMR6_TypeDef *TMR6x, en_timer6_compare_t enTimer6Compare, uint16_t u16Compare);
  574. /* Timer6 unit set specoal compare register value*/
  575. en_result_t Timer6_SetSpecialCmpValue(M4_TMR6_TypeDef *TMR6x, en_timer6_special_compare_t enTimer6SpclCmp, uint16_t u16SpclCmp);
  576. /* Timer6 unit get general compare register value*/
  577. uint16_t Timer6_GetGeneralCmpValue(M4_TMR6_TypeDef *TMR6x, en_timer6_compare_t enTimer6Compare);
  578. /* Timer6 unit set period buffer transfer function*/
  579. en_result_t Timer6_SetPeriodBuf(M4_TMR6_TypeDef *TMR6x, const stc_timer6_period_buf_cfg_t* pstcTimer6PrdBufCfg);
  580. /* Timer6 unit set general compare buffer transfer function*/
  581. en_result_t Timer6_SetGeneralBuf(M4_TMR6_TypeDef *TMR6x, en_timer6_chx_port_t enTimer6PWMPort, const stc_timer6_gcmp_buf_cfg_t* pstcTimer6GenBufCfg);
  582. /* Timer6 unit set special compare buffer transfer function*/
  583. en_result_t Timer6_SetSpecialBuf(M4_TMR6_TypeDef *TMR6x,en_timer6_special_compare_t enTimer6SpclCmp, const stc_timer6_spcl_buf_cfg_t* pstcTimer6SpclBufCfg);
  584. /* Timer6 unit Set valid period Value*/
  585. en_result_t Timer6_SetValidPeriod(M4_TMR6_TypeDef *TMR6x, const stc_timer6_validper_cfg_t* pstcTimer6ValidPerCfg);
  586. /* Config Input prot and filter function */
  587. en_result_t Timer6_PortInputConfig(M4_TMR6_TypeDef *TMR6x, const stc_timer6_port_input_cfg_t* pstcTimer6PortInputCfg);
  588. /* Config output prot function */
  589. en_result_t Timer6_PortOutputConfig(M4_TMR6_TypeDef *TMR6x, en_timer6_chx_port_t enTimer6PWMPort, const stc_timer6_port_output_cfg_t* pstcTimer6PortOutCfg);
  590. /* Set dead time register value */
  591. en_result_t Timer6_SetDeadTimeValue(M4_TMR6_TypeDef *TMR6x, en_timer6_dead_time_reg_t enTimer6DTReg, uint16_t u16DTValue);
  592. /* Config dead time function */
  593. en_result_t Timer6_ConfigDeadTime(M4_TMR6_TypeDef *TMR6x, const stc_timer6_deadtime_cfg_t* pstcTimer6DTCfg);
  594. /* Config Software Synchrony Stop */
  595. en_result_t Timer6_SwSyncStart(const stc_timer6_sw_sync_t* pstcTimer6SwSyncStart);
  596. /* Config Software Synchrony Start */
  597. en_result_t Timer6_SwSyncStop(const stc_timer6_sw_sync_t* pstcTimer6SwSyncStop);
  598. /* Config Software Synchrony Clear */
  599. en_result_t Timer6_SwSyncClear(const stc_timer6_sw_sync_t* pstcTimer6SwSyncClear);
  600. /* Get Software Synchrony Status */
  601. en_result_t Timer6_GetSwSyncState(stc_timer6_sw_sync_t* pstcTimer6SwSyncState);
  602. /* Config Hardware up count event */
  603. en_result_t Timer6_ConfigHwCntUp(M4_TMR6_TypeDef *TMR6x, en_timer6_hw_cnt_t enTimer6HwCntUp);
  604. /* Clear Hardware up count event */
  605. en_result_t Timer6_ClearHwCntUp(M4_TMR6_TypeDef *TMR6x);
  606. /* Config Hardware down count event */
  607. en_result_t Timer6_ConfigHwCntDwn(M4_TMR6_TypeDef *TMR6x, en_timer6_hw_cnt_t enTimer6HwCntDwn);
  608. /* Clear Hardware down count event */
  609. en_result_t Timer6_ClearHwCntDwn(M4_TMR6_TypeDef *TMR6x);
  610. /* Config Hardware start event */
  611. en_result_t Timer6_ConfigHwStart(M4_TMR6_TypeDef *TMR6x, en_timer6_hw_trig_t enTimer6HwStart);
  612. /* Clear Hardware start event */
  613. en_result_t Timer6_ClearHwStart(M4_TMR6_TypeDef *TMR6x);
  614. /* Enable Hardware start event */
  615. en_result_t Timer6_EnableHwStart(M4_TMR6_TypeDef *TMR6x);
  616. /* Dsiable Hardware start event */
  617. en_result_t Timer6_DisableHwStart(M4_TMR6_TypeDef *TMR6x);
  618. /* Config Hardware stop event */
  619. en_result_t Timer6_ConfigHwStop(M4_TMR6_TypeDef *TMR6x, en_timer6_hw_trig_t enTimer6HwStop);
  620. /* Clear Hardware stop event */
  621. en_result_t Timer6_ClearHwStop(M4_TMR6_TypeDef *TMR6x);
  622. /* Enable Hardware stop event */
  623. en_result_t Timer6_EnableHwStop(M4_TMR6_TypeDef *TMR6x);
  624. /* Disable Hardware stop event */
  625. en_result_t Timer6_DisableHwStop(M4_TMR6_TypeDef *TMR6x);
  626. /* Config Hardware clear event */
  627. en_result_t Timer6_ConfigHwClear(M4_TMR6_TypeDef *TMR6x, en_timer6_hw_trig_t enTimer6HwClear);
  628. /* Clear Hardware clear event */
  629. en_result_t Timer6_ClearHwClear(M4_TMR6_TypeDef *TMR6x);
  630. /* Enable Hardware clear event */
  631. en_result_t Timer6_EnableHwClear(M4_TMR6_TypeDef *TMR6x);
  632. /* Dsiable Hardware clear event */
  633. en_result_t Timer6_DisableHwClear(M4_TMR6_TypeDef *TMR6x);
  634. /* Config Hardware capture event A */
  635. en_result_t Timer6_ConfigHwCaptureA(M4_TMR6_TypeDef *TMR6x, en_timer6_hw_trig_t enTimer6HwCaptureA);
  636. /* Clear Hardware capture event A */
  637. en_result_t Timer6_ClearHwCaptureA(M4_TMR6_TypeDef *TMR6x);
  638. /* Config Hardware capture event B */
  639. en_result_t Timer6_ConfigHwCaptureB(M4_TMR6_TypeDef *TMR6x, en_timer6_hw_trig_t enTimer6HwCaptureB);
  640. /* Clear Hardware capture event B */
  641. en_result_t Timer6_ClearHwCaptureB(M4_TMR6_TypeDef *TMR6x);
  642. /* Set trigger source 0 of hardware event */
  643. en_result_t Timer6_SetTriggerSrc0(en_event_src_t enTriggerSrc);
  644. /* Set trigger source 1 of hardware event */
  645. en_result_t Timer6_SetTriggerSrc1(en_event_src_t enTriggerSrc);
  646. /* Enable or disable Timer6 common trigger for Hardware trigger source 0 */
  647. void TIMER6_ComTriggerCmd0(en_timer6_com_trigger_t enComTrigger, en_functional_state_t enState);
  648. /* Enable or disable Timer6 common trigger for Hardware trigger source 1 */
  649. void TIMER6_ComTriggerCmd1(en_timer6_com_trigger_t enComTrigger, en_functional_state_t enState);
  650. /* Z phase input mask config */
  651. en_result_t Timer6_ConfigZMask(M4_TMR6_TypeDef *TMR6x, const stc_timer6_zmask_cfg_t* pstcTimer6ZMaskCfg);
  652. //@} // Timer6Group
  653. #ifdef __cplusplus
  654. }
  655. #endif
  656. #endif /* DDL_TIMER6_ENABLE */
  657. #endif /* __HC32F460_TIMER6_H__ */
  658. /*******************************************************************************
  659. * EOF (not truncated)
  660. ******************************************************************************/