hc32f460_clk.h 29 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647
  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_clk.h
  11. **
  12. ** A detailed description is available at
  13. ** @link CmuGroup Clock description @endlink
  14. **
  15. ** - 2018-10-13 CDT First version for Device Driver Library of CMU.
  16. **
  17. ******************************************************************************/
  18. #ifndef __HC32F460_CLK_H__
  19. #define __HC32F460_CLK_H__
  20. /*******************************************************************************
  21. * Include files
  22. ******************************************************************************/
  23. #include "hc32_common.h"
  24. #include "ddl_config.h"
  25. #if (DDL_CLK_ENABLE == DDL_ON)
  26. /* C binding of definitions if building with C++ compiler */
  27. #ifdef __cplusplus
  28. extern "C"
  29. {
  30. #endif
  31. /**
  32. *******************************************************************************
  33. ** \defgroup CmuGroup Clock Manage Unit(CMU)
  34. **
  35. ******************************************************************************/
  36. //@{
  37. /*******************************************************************************
  38. * Global type definitions ('typedef')
  39. ******************************************************************************/
  40. /**
  41. *******************************************************************************
  42. ** \brief The system clock source.
  43. **
  44. ******************************************************************************/
  45. typedef enum en_clk_sys_source
  46. {
  47. ClkSysSrcHRC = 0u, ///< The system clock source is HRC.
  48. ClkSysSrcMRC = 1u, ///< The system clock source is MRC.
  49. ClkSysSrcLRC = 2u, ///< The system clock source is LRC.
  50. ClkSysSrcXTAL = 3u, ///< The system clock source is XTAL.
  51. ClkSysSrcXTAL32 = 4u, ///< The system clock source is XTAL32.
  52. CLKSysSrcMPLL = 5u, ///< The system clock source is MPLL.
  53. }en_clk_sys_source_t;
  54. /**
  55. *******************************************************************************
  56. ** \brief The pll clock source.
  57. **
  58. ******************************************************************************/
  59. typedef enum en_clk_pll_source
  60. {
  61. ClkPllSrcXTAL = 0u, ///< The pll clock source is XTAL.
  62. ClkPllSrcHRC = 1u, ///< The pll clock source is HRC.
  63. }en_clk_pll_source_t;
  64. /**
  65. *******************************************************************************
  66. ** \brief The usb clock source.
  67. **
  68. ******************************************************************************/
  69. typedef enum en_clk_usb_source
  70. {
  71. ClkUsbSrcSysDiv2 = 2u, ///< The usb clock source is 1/2 system clock.
  72. ClkUsbSrcSysDiv3 = 3u, ///< The usb clock source is 1/3 system clock.
  73. ClkUsbSrcSysDiv4 = 4u, ///< The usb clock source is 1/4 system clock.
  74. ClkUsbSrcMpllp = 8u, ///< The usb clock source is MPLLP.
  75. ClkUsbSrcMpllq = 9u, ///< The usb clock source is MPLLQ.
  76. ClkUsbSrcMpllr = 10u, ///< The usb clock source is MPLLR.
  77. ClkUsbSrcUpllp = 11u, ///< The usb clock source is UPLLP.
  78. ClkUsbSrcUpllq = 12u, ///< The usb clock source is UPLLQ.
  79. ClkUsbSrcUpllr = 13u, ///< The usb clock source is UPLLR.
  80. }en_clk_usb_source_t;
  81. /**
  82. *******************************************************************************
  83. ** \brief The peripheral(adc/trng/I2S) clock source.
  84. **
  85. ******************************************************************************/
  86. typedef enum en_clk_peri_source
  87. {
  88. ClkPeriSrcPclk = 0u, ///< The peripheral(adc/trng/I2S) clock source is division from system clock.
  89. ClkPeriSrcMpllp = 8u, ///< The peripheral(adc/trng/I2S) clock source is MPLLP.
  90. ClkPeriSrcMpllq = 9u, ///< The peripheral(adc/trng/I2S) clock source is MPLLQ.
  91. ClkPeriSrcMpllr = 10u, ///< The peripheral(adc/trng/I2S) clock source is MPLLR.
  92. ClkPeriSrcUpllp = 11u, ///< The peripheral(adc/trng/I2S) clock source is UPLLP.
  93. ClkPeriSrcUpllq = 12u, ///< The peripheral(adc/trng/I2S) clock source is UPLLQ.
  94. ClkPeriSrcUpllr = 13u, ///< The peripheral(adc/trng/I2S) clock source is UPLLR.
  95. }en_clk_peri_source_t;
  96. /**
  97. *******************************************************************************
  98. ** \brief The clock output source.
  99. **
  100. ******************************************************************************/
  101. typedef enum en_clk_output_source
  102. {
  103. ClkOutputSrcHrc = 0u, ///< The clock output source is HRC
  104. ClkOutputSrcMrc = 1u, ///< The clock output source is MRC.
  105. ClkOutputSrcLrc = 2u, ///< The clock output source is LRC.
  106. ClkOutputSrcXtal = 3u, ///< The clock output source is XTAL.
  107. ClkOutputSrcXtal32 = 4u, ///< The clock output source is XTAL32
  108. ClkOutputSrcMpllp = 6u, ///< The clock output source is MPLLP.
  109. ClkOutputSrcUpllp = 7u, ///< The clock output source is UPLLP.
  110. ClkOutputSrcMpllq = 8u, ///< The clock output source is MPLLQ.
  111. ClkOutputSrcUpllq = 9u, ///< The clock output source is UPLLQ.
  112. ClkOutputSrcSysclk = 11u, ///< The clock output source is system clock.
  113. }en_clk_output_source_t;
  114. /**
  115. *******************************************************************************
  116. ** \brief The clock frequency source for measure or reference.
  117. **
  118. ******************************************************************************/
  119. typedef enum en_clk_fcm_source
  120. {
  121. ClkFcmSrcXtal = 0u, ///< The clock frequency measure or reference source is XTAL
  122. ClkFcmSrcXtal32 = 1u, ///< The clock frequency measure or reference source is XTAL32.
  123. ClkFcmSrcHrc = 2u, ///< The clock frequency measure or reference source is HRC.
  124. ClkFcmSrcLrc = 3u, ///< The clock frequency measure or reference source is LRC.
  125. ClkFcmSrcSwdtrc = 4u, ///< The clock frequency measure or reference source is SWDTRC
  126. ClkFcmSrcPclk1 = 5u, ///< The clock frequency measure or reference source is PCLK1.
  127. ClkFcmSrcUpllp = 6u, ///< The clock frequency measure or reference source is UPLLP.
  128. ClkFcmSrcMrc = 7u, ///< The clock frequency measure or reference source is MRC.
  129. ClkFcmSrcMpllp = 8u, ///< The clock frequency measure or reference source is MPLLP.
  130. ClkFcmSrcRtcLrc = 9u, ///< The clock frequency measure or reference source is RTCLRC.
  131. }en_clk_fcm_intref_source_t,en_clk_fcm_measure_source_t;
  132. /**
  133. *******************************************************************************
  134. ** \brief The clock flag status.
  135. **
  136. ******************************************************************************/
  137. typedef enum en_clk_flag
  138. {
  139. ClkFlagHRCRdy = 0u, ///< The clock flag is HRC ready.
  140. ClkFlagXTALRdy = 1u, ///< The clock flag is XTAL ready.
  141. ClkFlagMPLLRdy = 2u, ///< The clock flag is MPLL ready.
  142. ClkFlagUPLLRdy = 3u, ///< The clock flag is UPLL ready.
  143. ClkFlagXTALStoppage = 4u, ///< The clock flag is XTAL stoppage.
  144. }en_clk_flag_t;
  145. /**
  146. *******************************************************************************
  147. ** \brief The clock frequency measure flag status.
  148. **
  149. ******************************************************************************/
  150. typedef enum en_clk_fcm_flag
  151. {
  152. ClkFcmFlagErrf = 0u, ///< The clock frequency flag is frequency abnormal.
  153. ClkFcmFlagMendf = 1u, ///< The clock frequency flag is end of measurement.
  154. ClkFcmFlagOvf = 2u, ///< The clock frequency flag is counter overflow.
  155. }en_clk_fcm_flag_t;
  156. /**
  157. *******************************************************************************
  158. ** \brief The source of xtal.
  159. **
  160. ******************************************************************************/
  161. typedef enum en_clk_xtal_mode
  162. {
  163. ClkXtalModeOsc = 0u, ///< Use external high speed osc as source.
  164. ClkXtalModeExtClk = 1u, ///< Use external clk as source.
  165. }en_clk_xtal_mode_t;
  166. /**
  167. *******************************************************************************
  168. ** \brief The drive capability of xtal.
  169. **
  170. ******************************************************************************/
  171. typedef enum en_clk_xtal_drv
  172. {
  173. ClkXtalHighDrv = 0u, ///< High drive capability.20MHz~24MHz.
  174. ClkXtalMidDrv = 1u, ///< Middle drive capability.16MHz~20MHz.
  175. ClkXtalLowDrv = 2u, ///< Low drive capability.8MHz~16MHz.
  176. ClkXtalTinyDrv = 3u, ///< Tiny drive capability.8MHz.
  177. }en_clk_xtal_drv_t;
  178. /**
  179. *******************************************************************************
  180. ** \brief The stable time of XTAL.
  181. **
  182. ** \note It depends on SUPDRV bit.
  183. ******************************************************************************/
  184. typedef enum en_clk_xtal_stb_cycle
  185. {
  186. ClkXtalStbCycle35 = 1u, ///< stable time is 35(36) cycle.
  187. ClkXtalStbCycle67 = 2u, ///< stable time is 67(68) cycle.
  188. ClkXtalStbCycle131 = 3u, ///< stable time is 131(132) cycle.
  189. ClkXtalStbCycle259 = 4u, ///< stable time is 259(260) cycle.
  190. ClkXtalStbCycle547 = 5u, ///< stable time is 547(548) cycle.
  191. ClkXtalStbCycle1059 = 6u, ///< stable time is 1059(1060) cycle.
  192. ClkXtalStbCycle2147 = 7u, ///< stable time is 2147(2148) cycle.
  193. ClkXtalStbCycle4291 = 8u, ///< stable time is 4291(4292) cycle.
  194. ClkXtalStbCycle8163 = 9u, ///< stable time is 8163(8164) cycle.
  195. }en_clk_xtal_stb_cycle_t;
  196. /**
  197. *******************************************************************************
  198. ** \brief The handle of xtal stoppage.
  199. **
  200. ******************************************************************************/
  201. typedef enum en_clk_xtal_stp_mode
  202. {
  203. ClkXtalStpModeInt = 0u, ///< The handle of stoppage is interrupt.
  204. ClkXtalStpModeReset = 1u, ///< The handle of stoppage is reset.
  205. }en_clk_xtal_stp_mode_t;
  206. /**
  207. *******************************************************************************
  208. ** \brief The drive capability of xtal32.
  209. **
  210. ******************************************************************************/
  211. typedef enum en_clk_xtal32_drv
  212. {
  213. ClkXtal32MidDrv = 0u, ///< Middle drive capability.32.768KHz.
  214. ClkXtal32HighDrv = 1u, ///< High drive capability.32.768KHz.
  215. }en_clk_xtal32_drv_t;
  216. /**
  217. *******************************************************************************
  218. ** \brief The filter mode of xtal32.
  219. **
  220. ******************************************************************************/
  221. typedef enum en_clk_xtal32_filter_mode
  222. {
  223. ClkXtal32FilterModeFull = 0u, ///< Valid in run,stop,power down mode.
  224. ClkXtal32FilterModePart = 2u, ///< Valid in run mode.
  225. ClkXtal32FilterModeNone = 3u, ///< Invalid in run,stop,power down mode.
  226. }en_clk_xtal32_filter_mode_t;
  227. /**
  228. *******************************************************************************
  229. ** \brief The division factor of system clock.
  230. **
  231. ******************************************************************************/
  232. typedef enum en_clk_sysclk_div_factor
  233. {
  234. ClkSysclkDiv1 = 0u, ///< 1 division.
  235. ClkSysclkDiv2 = 1u, ///< 2 division.
  236. ClkSysclkDiv4 = 2u, ///< 4 division.
  237. ClkSysclkDiv8 = 3u, ///< 8 division.
  238. ClkSysclkDiv16 = 4u, ///< 16 division.
  239. ClkSysclkDiv32 = 5u, ///< 32 division.
  240. ClkSysclkDiv64 = 6u, ///< 64 division.
  241. }en_clk_sysclk_div_factor_t;
  242. /**
  243. *******************************************************************************
  244. ** \brief The division factor of system clock.It will be used for debug clock.
  245. **
  246. ******************************************************************************/
  247. typedef enum en_clk_tpiuclk_div_factor
  248. {
  249. ClkTpiuclkDiv1 = 0u, ///< 1 division.
  250. ClkTpiuclkDiv2 = 1u, ///< 2 division.
  251. ClkTpiuclkDiv4 = 2u, ///< 4 division.
  252. }en_clk_tpiuclk_div_factor_t;
  253. /**
  254. *******************************************************************************
  255. ** \brief The division factor of clock output.
  256. **
  257. ******************************************************************************/
  258. typedef enum en_clk_output_div_factor
  259. {
  260. ClkOutputDiv1 = 0u, ///< 1 division.
  261. ClkOutputDiv2 = 1u, ///< 2 division.
  262. ClkOutputDiv4 = 2u, ///< 4 division.
  263. ClkOutputDiv8 = 3u, ///< 8 division.
  264. ClkOutputDiv16 = 4u, ///< 16 division.
  265. ClkOutputDiv32 = 5u, ///< 32 division.
  266. ClkOutputDiv64 = 6u, ///< 64 division.
  267. ClkOutputDiv128 = 7u, ///< 128 division.
  268. }en_clk_output_div_factor_t;
  269. /**
  270. *******************************************************************************
  271. ** \brief The division factor of fcm measure source.
  272. **
  273. ******************************************************************************/
  274. typedef enum en_clk_fcm_measure_div_factor
  275. {
  276. ClkFcmMeaDiv1 = 0u, ///< 1 division.
  277. ClkFcmMeaDiv4 = 1u, ///< 4 division.
  278. ClkFcmMeaDiv8 = 2u, ///< 8 division.
  279. ClkFcmMeaDiv32 = 3u, ///< 32 division.
  280. }en_clk_fcm_measure_div_factor_t;
  281. /**
  282. *******************************************************************************
  283. ** \brief The division factor of fcm reference source.
  284. **
  285. ******************************************************************************/
  286. typedef enum en_clk_fcm_intref_div_factor
  287. {
  288. ClkFcmIntrefDiv32 = 0u, ///< 32 division.
  289. ClkFcmIntrefDiv128 = 1u, ///< 128 division.
  290. ClkFcmIntrefDiv1024 = 2u, ///< 1024 division.
  291. ClkFcmIntrefDiv8192 = 3u, ///< 8192 division.
  292. }en_clk_fcm_intref_div_factor_t;
  293. /**
  294. *******************************************************************************
  295. ** \brief The edge of the fcm reference source.
  296. **
  297. ******************************************************************************/
  298. typedef enum en_clk_fcm_edge
  299. {
  300. ClkFcmEdgeRising = 0u, ///< Rising edge.
  301. ClkFcmEdgeFalling = 1u, ///< Falling edge.
  302. ClkFcmEdgeBoth = 2u, ///< Both edge.
  303. }en_clk_fcm_edge_t;
  304. /**
  305. *******************************************************************************
  306. ** \brief The filter clock of the fcm reference source.
  307. **
  308. ******************************************************************************/
  309. typedef enum en_clk_fcm_filter_clk
  310. {
  311. ClkFcmFilterClkNone = 0u, ///< None filter.
  312. ClkFcmFilterClkFcmSrc = 1u, ///< Use fcm measurement source as filter clock.
  313. ClkFcmFilterClkFcmSrcDiv4 = 2u, ///< Use 1/4 fcm measurement source as filter clock.
  314. ClkFcmFilterClkFcmSrcDiv16 = 3u, ///< Use 1/16 fcm measurement source as filter clock.
  315. }en_clk_fcm_filter_clk_t;
  316. /**
  317. *******************************************************************************
  318. ** \brief The fcm reference source.
  319. **
  320. ******************************************************************************/
  321. typedef enum en_clk_fcm_refer
  322. {
  323. ClkFcmExtRef = 0u, ///< Use external reference.
  324. ClkFcmInterRef = 1u, ///< Use internal reference.
  325. }en_clk_fcm_refer_t;
  326. /**
  327. *******************************************************************************
  328. ** \brief The handle of fcm abnormal.
  329. **
  330. ******************************************************************************/
  331. typedef enum en_clk_fcm_abnormal_handle
  332. {
  333. ClkFcmHandleInterrupt = 0u, ///< The handle of fcm abnormal is interrupt.
  334. ClkFcmHandleReset = 1u, ///< The handle of fcm abnormal is reset.
  335. }en_clk_fcm_abnormal_handle_t;
  336. /**
  337. *******************************************************************************
  338. ** \brief The channel of clock output.
  339. **
  340. ******************************************************************************/
  341. typedef enum en_clk_output_ch
  342. {
  343. ClkOutputCh1 = 1u, ///< The output of clk is MCO_1.
  344. ClkOutputCh2 = 2u, ///< The output of clk is MCO_2.
  345. }en_clk_output_ch_t;
  346. /**
  347. *******************************************************************************
  348. ** \brief Configuration structure of XTAL.
  349. **
  350. ** \note Configures the XTAL if needed.
  351. **
  352. ******************************************************************************/
  353. typedef struct stc_clk_xtal_cfg
  354. {
  355. en_functional_state_t enFastStartup; ///< Enable fast start up or not.
  356. en_clk_xtal_mode_t enMode; ///< Select xtal mode.
  357. en_clk_xtal_drv_t enDrv; ///< Select xtal drive capability.
  358. }stc_clk_xtal_cfg_t;
  359. /**
  360. *******************************************************************************
  361. ** \brief Configuration structure of XTAL stoppage.
  362. **
  363. ** \note Configures the XTAL stoppage if needed.
  364. **
  365. ******************************************************************************/
  366. typedef struct stc_clk_xtal_stp_cfg
  367. {
  368. en_functional_state_t enDetect; ///< Enable detect stoppage or not.
  369. en_clk_xtal_stp_mode_t enMode; ///< Select the handle of xtal stoppage.
  370. en_functional_state_t enModeReset; ///< Enable reset for handle the xtal stoppage.
  371. en_functional_state_t enModeInt; ///< Enable interrupt for handle the xtal stoppage.
  372. }stc_clk_xtal_stp_cfg_t;
  373. /**
  374. *******************************************************************************
  375. ** \brief Configuration structure of XTAL32.
  376. **
  377. ** \note Configures the XTAL32 if needed.
  378. **
  379. ******************************************************************************/
  380. typedef struct stc_clk_xtal32_cfg
  381. {
  382. en_clk_xtal32_drv_t enDrv; ///< Select xtal32 drive capability.
  383. en_clk_xtal32_filter_mode_t enFilterMode; ///< The filter mode of xtal32.
  384. }stc_clk_xtal32_cfg_t;
  385. /**
  386. *******************************************************************************
  387. ** \brief Configuration structure of PLL.
  388. **
  389. ** \note Configures the PLL if needed.
  390. **
  391. ******************************************************************************/
  392. typedef struct stc_clk_pll_cfg
  393. {
  394. uint32_t PllpDiv; ///< Pllp clk, division factor of VCO out.
  395. uint32_t PllqDiv; ///< Pllq clk, division factor of VCO out.
  396. uint32_t PllrDiv; ///< Pllr clk, division factor of VCO out.
  397. uint32_t plln; ///< Multiplication factor of vco out, ensure between 240M~480M
  398. uint32_t pllmDiv; ///< Division factor of VCO in, ensure between 1M~12M.
  399. }stc_clk_mpll_cfg_t, stc_clk_upll_cfg_t;
  400. /**
  401. *******************************************************************************
  402. ** \brief Configuration structure of system clock.
  403. **
  404. ** \note Configures the system clock if needed.
  405. **
  406. ******************************************************************************/
  407. typedef struct stc_clk_sysclk_cfg
  408. {
  409. en_clk_sysclk_div_factor_t enHclkDiv; ///< Division for hclk.
  410. en_clk_sysclk_div_factor_t enExclkDiv; ///< Division for exclk.
  411. en_clk_sysclk_div_factor_t enPclk0Div; ///< Division for pclk0.
  412. en_clk_sysclk_div_factor_t enPclk1Div; ///< Division for pclk1.
  413. en_clk_sysclk_div_factor_t enPclk2Div; ///< Division for pclk2.
  414. en_clk_sysclk_div_factor_t enPclk3Div; ///< Division for pclk3.
  415. en_clk_sysclk_div_factor_t enPclk4Div; ///< Division for pclk4.
  416. }stc_clk_sysclk_cfg_t;
  417. /**
  418. *******************************************************************************
  419. ** \brief Configuration structure of clock output.
  420. **
  421. ** \note Configures the clock output if needed.
  422. **
  423. ******************************************************************************/
  424. typedef struct stc_clk_output_cfg
  425. {
  426. en_clk_output_source_t enOutputSrc; ///< The clock output source.
  427. en_clk_output_div_factor_t enOutputDiv; ///< The division factor of clock output source.
  428. }stc_clk_output_cfg_t;
  429. /**
  430. *******************************************************************************
  431. ** \brief Configuration structure of fcm window.
  432. **
  433. ** \note Configures the fcm window if needed.
  434. **
  435. ******************************************************************************/
  436. typedef struct stc_clk_fcm_window_cfg
  437. {
  438. uint16_t windowLower; ///< The lower value of the window.
  439. uint16_t windowUpper; ///< The upper value of the window.
  440. }stc_clk_fcm_window_cfg_t;
  441. /**
  442. *******************************************************************************
  443. ** \brief Configuration structure of fcm measurement.
  444. **
  445. ** \note Configures the fcm measurement if needed.
  446. **
  447. ******************************************************************************/
  448. typedef struct stc_clk_fcm_measure_cfg
  449. {
  450. en_clk_fcm_measure_source_t enSrc; ///< The measurement source.
  451. en_clk_fcm_measure_div_factor_t enSrcDiv; ///< The division factor of measurement source.
  452. }stc_clk_fcm_measure_cfg_t;
  453. /**
  454. *******************************************************************************
  455. ** \brief Configuration structure of fcm reference.
  456. **
  457. ** \note Configures the fcm reference if needed.
  458. **
  459. ******************************************************************************/
  460. typedef struct stc_clk_fcm_reference_cfg
  461. {
  462. en_functional_state_t enExtRef; ///< Enable external reference or not.
  463. en_clk_fcm_edge_t enEdge; ///< The edge of internal reference.
  464. en_clk_fcm_filter_clk_t enFilterClk; ///< The filter clock of internal reference.
  465. en_clk_fcm_refer_t enRefSel; ///< Select reference.
  466. en_clk_fcm_intref_source_t enIntRefSrc; ///< Select internal reference.
  467. en_clk_fcm_intref_div_factor_t enIntRefDiv; ///< The division factor of internal reference.
  468. }stc_clk_fcm_reference_cfg_t;
  469. /**
  470. *******************************************************************************
  471. ** \brief Configuration structure of fcm interrupt.
  472. **
  473. ** \note Configures the fcm interrupt if needed.
  474. **
  475. ******************************************************************************/
  476. typedef struct stc_clk_fcm_interrupt_cfg
  477. {
  478. en_clk_fcm_abnormal_handle_t enHandleSel; ///< Use interrupt or reset.
  479. en_functional_state_t enHandleReset; ///< Enable reset or not.
  480. en_functional_state_t enHandleInterrupt; ///< Enable interrupt or not.
  481. en_functional_state_t enOvfInterrupt; ///< Enable overflow interrupt or not.
  482. en_functional_state_t enEndInterrupt; ///< Enable measurement end interrupt or not.
  483. }stc_clk_fcm_interrupt_cfg_t;
  484. /**
  485. *******************************************************************************
  486. ** \brief Configuration structure of fcm.
  487. **
  488. ** \note Configures the fcm if needed.
  489. **
  490. ******************************************************************************/
  491. typedef struct stc_clk_fcm_cfg
  492. {
  493. stc_clk_fcm_window_cfg_t *pstcFcmWindowCfg; ///< Window configuration struct.
  494. stc_clk_fcm_measure_cfg_t *pstcFcmMeaCfg; ///< Measurement configuration struct.
  495. stc_clk_fcm_reference_cfg_t *pstcFcmRefCfg; ///< Reference configuration struct.
  496. stc_clk_fcm_interrupt_cfg_t *pstcFcmIntCfg; ///< Interrupt configuration struct.
  497. }stc_clk_fcm_cfg_t;
  498. /**
  499. *******************************************************************************
  500. ** \brief Clock frequency structure.
  501. **
  502. ******************************************************************************/
  503. typedef struct stc_clk_freq
  504. {
  505. uint32_t sysclkFreq; ///< System clock frequency.
  506. uint32_t hclkFreq; ///< Hclk frequency.
  507. uint32_t exckFreq; ///< Exclk frequency.
  508. uint32_t pclk0Freq; ///< Pclk0 frequency.
  509. uint32_t pclk1Freq; ///< Pclk1 frequency.
  510. uint32_t pclk2Freq; ///< Pclk2 frequency.
  511. uint32_t pclk3Freq; ///< Pclk3 frequency.
  512. uint32_t pclk4Freq; ///< Pclk4 frequency.
  513. }stc_clk_freq_t;
  514. /**
  515. *******************************************************************************
  516. ** \brief PLL Clock frequency structure.
  517. **
  518. ******************************************************************************/
  519. typedef struct stc_pll_clk_freq
  520. {
  521. uint32_t mpllp; ///< mpllp clock frequency.
  522. uint32_t mpllq; ///< mpllq clock frequency.
  523. uint32_t mpllr; ///< mpllr clock frequency.
  524. uint32_t upllp; ///< upllp clock frequency.
  525. uint32_t upllq; ///< upllq clock frequency.
  526. uint32_t upllr; ///< upllr clock frequency.
  527. }stc_pll_clk_freq_t;
  528. /*******************************************************************************
  529. * Global pre-processor symbols/macros ('#define')
  530. ******************************************************************************/
  531. /*******************************************************************************
  532. * Global variable definitions ('extern')
  533. ******************************************************************************/
  534. /*******************************************************************************
  535. * Global function prototypes (definition in C source)
  536. ******************************************************************************/
  537. void CLK_XtalConfig(const stc_clk_xtal_cfg_t *pstcXtalCfg);
  538. void CLK_XtalStbConfig(const en_clk_xtal_stb_cycle_t enXtalStb);
  539. void CLK_XtalStpConfig(const stc_clk_xtal_stp_cfg_t *pstcXtalStpCfg);
  540. en_result_t CLK_XtalCmd(en_functional_state_t enNewState);
  541. void CLK_Xtal32Config(const stc_clk_xtal32_cfg_t *pstcXtal32Cfg);
  542. en_result_t CLK_Xtal32Cmd(en_functional_state_t enNewState);
  543. void CLK_HrcTrim(int8_t trimValue);
  544. en_result_t CLK_HrcCmd(en_functional_state_t enNewState);
  545. void CLK_MrcTrim(int8_t trimValue);
  546. en_result_t CLK_MrcCmd(en_functional_state_t enNewState);
  547. void CLK_LrcTrim(int8_t trimValue);
  548. en_result_t CLK_LrcCmd(en_functional_state_t enNewState);
  549. void CLK_SetPllSource(en_clk_pll_source_t enPllSrc);
  550. void CLK_MpllConfig(const stc_clk_mpll_cfg_t *pstcMpllCfg);
  551. en_result_t CLK_MpllCmd(en_functional_state_t enNewState);
  552. void CLK_UpllConfig(const stc_clk_upll_cfg_t *pstcUpllCfg);
  553. en_result_t CLK_UpllCmd(en_functional_state_t enNewState);
  554. void CLK_SetSysClkSource(en_clk_sys_source_t enTargetSysSrc);
  555. en_clk_sys_source_t CLK_GetSysClkSource(void);
  556. void CLK_SysClkConfig(const stc_clk_sysclk_cfg_t *pstcSysclkCfg);
  557. void CLK_GetClockFreq(stc_clk_freq_t *pstcClkFreq);
  558. void CLK_GetPllClockFreq(stc_pll_clk_freq_t *pstcPllClkFreq);
  559. void CLK_SetUsbClkSource(en_clk_usb_source_t enTargetUsbSrc);
  560. void CLK_SetPeriClkSource(en_clk_peri_source_t enTargetPeriSrc);
  561. void CLK_SetI2sClkSource(const M4_I2S_TypeDef* pstcI2sReg, en_clk_peri_source_t enTargetPeriSrc);
  562. en_clk_peri_source_t CLK_GetI2sClkSource(const M4_I2S_TypeDef* pstcI2sReg);
  563. void CLK_TpiuClkConfig(const en_clk_tpiuclk_div_factor_t enTpiuDiv);
  564. void CLK_TpiuClkCmd(en_functional_state_t enNewState);
  565. void CLK_OutputClkConfig(en_clk_output_ch_t enCh, const stc_clk_output_cfg_t *pstcOutputCfg);
  566. void CLK_OutputClkCmd(en_clk_output_ch_t enCh, en_functional_state_t enNewState);
  567. en_flag_status_t CLK_GetFlagStatus(en_clk_flag_t enClkFlag);
  568. void CLK_FcmConfig(const stc_clk_fcm_cfg_t *pstcClkFcmCfg);
  569. void CLK_FcmCmd(en_functional_state_t enNewState);
  570. uint16_t CLK_GetFcmCounter(void);
  571. en_flag_status_t CLK_GetFcmFlag(en_clk_fcm_flag_t enFcmFlag);
  572. void CLK_ClearFcmFlag(en_clk_fcm_flag_t enFcmFlag);
  573. void CLK_ClearXtalStdFlag(void);
  574. //@} // CmuGroup
  575. #ifdef __cplusplus
  576. }
  577. #endif
  578. #endif /* DDL_CLK_ENABLE */
  579. #endif /* __HC32F460_CLK_H__ */
  580. /*******************************************************************************
  581. * EOF (not truncated)
  582. ******************************************************************************/