at32f415_crm.h 40 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917
  1. /**
  2. **************************************************************************
  3. * @file at32f415_crm.h
  4. * @version v2.0.5
  5. * @date 2022-05-20
  6. * @brief at32f415 crm header file
  7. **************************************************************************
  8. * Copyright notice & Disclaimer
  9. *
  10. * The software Board Support Package (BSP) that is made available to
  11. * download from Artery official website is the copyrighted work of Artery.
  12. * Artery authorizes customers to use, copy, and distribute the BSP
  13. * software and its related documentation for the purpose of design and
  14. * development in conjunction with Artery microcontrollers. Use of the
  15. * software is governed by this copyright notice and the following disclaimer.
  16. *
  17. * THIS SOFTWARE IS PROVIDED ON "AS IS" BASIS WITHOUT WARRANTIES,
  18. * GUARANTEES OR REPRESENTATIONS OF ANY KIND. ARTERY EXPRESSLY DISCLAIMS,
  19. * TO THE FULLEST EXTENT PERMITTED BY LAW, ALL EXPRESS, IMPLIED OR
  20. * STATUTORY OR OTHER WARRANTIES, GUARANTEES OR REPRESENTATIONS,
  21. * INCLUDING BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY,
  22. * FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT.
  23. *
  24. **************************************************************************
  25. */
  26. /* define to prevent recursive inclusion -------------------------------------*/
  27. #ifndef __AT32F415_CRM_H
  28. #define __AT32F415_CRM_H
  29. #ifdef __cplusplus
  30. extern "C" {
  31. #endif
  32. /* includes ------------------------------------------------------------------*/
  33. #include "at32f415.h"
  34. /** @addtogroup AT32F415_periph_driver
  35. * @{
  36. */
  37. /** @addtogroup CRM
  38. * @{
  39. */
  40. #define CRM_REG(value) PERIPH_REG(CRM_BASE, value)
  41. #define CRM_REG_BIT(value) PERIPH_REG_BIT(value)
  42. /** @defgroup CRM_flags_definition
  43. * @brief crm flag
  44. * @{
  45. */
  46. #define CRM_HICK_STABLE_FLAG MAKE_VALUE(0x00, 1) /*!< high speed internal clock stable flag */
  47. #define CRM_HEXT_STABLE_FLAG MAKE_VALUE(0x00, 17) /*!< high speed external crystal stable flag */
  48. #define CRM_PLL_STABLE_FLAG MAKE_VALUE(0x00, 25) /*!< phase locking loop stable flag */
  49. #define CRM_LEXT_STABLE_FLAG MAKE_VALUE(0x20, 1) /*!< low speed external crystal stable flag */
  50. #define CRM_LICK_STABLE_FLAG MAKE_VALUE(0x24, 1) /*!< low speed internal clock stable flag */
  51. #define CRM_ALL_RESET_FLAG MAKE_VALUE(0x24, 24) /*!< all reset flag */
  52. #define CRM_NRST_RESET_FLAG MAKE_VALUE(0x24, 26) /*!< nrst pin reset flag */
  53. #define CRM_POR_RESET_FLAG MAKE_VALUE(0x24, 27) /*!< power on reset flag */
  54. #define CRM_SW_RESET_FLAG MAKE_VALUE(0x24, 28) /*!< software reset flag */
  55. #define CRM_WDT_RESET_FLAG MAKE_VALUE(0x24, 29) /*!< watchdog timer reset flag */
  56. #define CRM_WWDT_RESET_FLAG MAKE_VALUE(0x24, 30) /*!< window watchdog timer reset flag */
  57. #define CRM_LOWPOWER_RESET_FLAG MAKE_VALUE(0x24, 31) /*!< low-power reset flag */
  58. #define CRM_LICK_READY_INT_FLAG MAKE_VALUE(0x08, 0) /*!< low speed internal clock stable interrupt ready flag */
  59. #define CRM_LEXT_READY_INT_FLAG MAKE_VALUE(0x08, 1) /*!< low speed external crystal stable interrupt ready flag */
  60. #define CRM_HICK_READY_INT_FLAG MAKE_VALUE(0x08, 2) /*!< high speed internal clock stable interrupt ready flag */
  61. #define CRM_HEXT_READY_INT_FLAG MAKE_VALUE(0x08, 3) /*!< high speed external crystal stable interrupt ready flag */
  62. #define CRM_PLL_READY_INT_FLAG MAKE_VALUE(0x08, 4) /*!< phase locking loop stable interrupt ready flag */
  63. #define CRM_CLOCK_FAILURE_INT_FLAG MAKE_VALUE(0x08, 7) /*!< clock failure interrupt ready flag */
  64. /**
  65. * @}
  66. */
  67. /** @defgroup CRM_interrupts_definition
  68. * @brief crm interrupt
  69. * @{
  70. */
  71. #define CRM_LICK_STABLE_INT ((uint32_t)0x00000100) /*!< low speed internal clock stable interrupt */
  72. #define CRM_LEXT_STABLE_INT ((uint32_t)0x00000200) /*!< low speed external crystal stable interrupt */
  73. #define CRM_HICK_STABLE_INT ((uint32_t)0x00000400) /*!< high speed internal clock stable interrupt */
  74. #define CRM_HEXT_STABLE_INT ((uint32_t)0x00000800) /*!< high speed external crystal stable interrupt */
  75. #define CRM_PLL_STABLE_INT ((uint32_t)0x00001000) /*!< phase locking loop stable interrupt */
  76. #define CRM_CLOCK_FAILURE_INT ((uint32_t)0x00800000) /*!< clock failure interrupt */
  77. /**
  78. * @}
  79. */
  80. /** @defgroup CRM_exported_types
  81. * @{
  82. */
  83. /**
  84. * @brief crm periph clock
  85. */
  86. typedef enum
  87. {
  88. /* ahb periph */
  89. CRM_DMA1_PERIPH_CLOCK = MAKE_VALUE(0x14, 0), /*!< dma1 periph clock */
  90. CRM_DMA2_PERIPH_CLOCK = MAKE_VALUE(0x14, 1), /*!< dma2 periph clock */
  91. CRM_CRC_PERIPH_CLOCK = MAKE_VALUE(0x14, 6), /*!< crc periph clock */
  92. CRM_SDIO1_PERIPH_CLOCK = MAKE_VALUE(0x14, 10), /*!< sdio1 periph clock */
  93. CRM_OTGFS1_PERIPH_CLOCK = MAKE_VALUE(0x14, 12), /*!< otgfs1 periph clock */
  94. /* apb2 periph */
  95. CRM_IOMUX_PERIPH_CLOCK = MAKE_VALUE(0x18, 0), /*!< iomux periph clock */
  96. CRM_GPIOA_PERIPH_CLOCK = MAKE_VALUE(0x18, 2), /*!< gpioa periph clock */
  97. CRM_GPIOB_PERIPH_CLOCK = MAKE_VALUE(0x18, 3), /*!< gpiob periph clock */
  98. CRM_GPIOC_PERIPH_CLOCK = MAKE_VALUE(0x18, 4), /*!< gpioc periph clock */
  99. CRM_GPIOD_PERIPH_CLOCK = MAKE_VALUE(0x18, 5), /*!< gpiod periph clock */
  100. CRM_GPIOF_PERIPH_CLOCK = MAKE_VALUE(0x18, 7), /*!< gpiof periph clock */
  101. CRM_ADC1_PERIPH_CLOCK = MAKE_VALUE(0x18, 9), /*!< adc1 periph clock */
  102. CRM_TMR1_PERIPH_CLOCK = MAKE_VALUE(0x18, 11), /*!< tmr1 periph clock */
  103. CRM_SPI1_PERIPH_CLOCK = MAKE_VALUE(0x18, 12), /*!< spi1 periph clock */
  104. CRM_USART1_PERIPH_CLOCK = MAKE_VALUE(0x18, 14), /*!< usart1 periph clock */
  105. CRM_TMR9_PERIPH_CLOCK = MAKE_VALUE(0x18, 19), /*!< tmr9 periph clock */
  106. CRM_TMR10_PERIPH_CLOCK = MAKE_VALUE(0x18, 20), /*!< tmr10 periph clock */
  107. CRM_TMR11_PERIPH_CLOCK = MAKE_VALUE(0x18, 21), /*!< tmr11 periph clock */
  108. /* apb1 periph */
  109. CRM_TMR2_PERIPH_CLOCK = MAKE_VALUE(0x1C, 0), /*!< tmr2 periph clock */
  110. CRM_TMR3_PERIPH_CLOCK = MAKE_VALUE(0x1C, 1), /*!< tmr3 periph clock */
  111. CRM_TMR4_PERIPH_CLOCK = MAKE_VALUE(0x1C, 2), /*!< tmr4 periph clock */
  112. CRM_TMR5_PERIPH_CLOCK = MAKE_VALUE(0x1C, 3), /*!< tmr5 periph clock */
  113. CRM_CMP_PERIPH_CLOCK = MAKE_VALUE(0x1C, 9), /*!< cmparator periph clock */
  114. CRM_WWDT_PERIPH_CLOCK = MAKE_VALUE(0x1C, 11), /*!< wwdt periph clock */
  115. CRM_SPI2_PERIPH_CLOCK = MAKE_VALUE(0x1C, 14), /*!< spi2 periph clock */
  116. CRM_USART2_PERIPH_CLOCK = MAKE_VALUE(0x1C, 17), /*!< usart2 periph clock */
  117. CRM_USART3_PERIPH_CLOCK = MAKE_VALUE(0x1C, 18), /*!< usart3 periph clock */
  118. CRM_UART4_PERIPH_CLOCK = MAKE_VALUE(0x1C, 19), /*!< uart4 periph clock */
  119. CRM_UART5_PERIPH_CLOCK = MAKE_VALUE(0x1C, 20), /*!< uart5 periph clock */
  120. CRM_I2C1_PERIPH_CLOCK = MAKE_VALUE(0x1C, 21), /*!< i2c1 periph clock */
  121. CRM_I2C2_PERIPH_CLOCK = MAKE_VALUE(0x1C, 22), /*!< i2c2 periph clock */
  122. CRM_CAN1_PERIPH_CLOCK = MAKE_VALUE(0x1C, 25), /*!< can1 periph clock */
  123. CRM_PWC_PERIPH_CLOCK = MAKE_VALUE(0x1C, 28), /*!< pwc periph clock */
  124. } crm_periph_clock_type;
  125. /**
  126. * @brief crm periph reset
  127. */
  128. typedef enum
  129. {
  130. /* ahb periph */
  131. CRM_OTGFS1_PERIPH_RESET = MAKE_VALUE(0x28, 12), /*!< otgfs1 periph reset */
  132. /* apb2 periph */
  133. CRM_IOMUX_PERIPH_RESET = MAKE_VALUE(0x0C, 0), /*!< iomux periph reset */
  134. CRM_EXINT_PERIPH_RESET = MAKE_VALUE(0x0C, 1), /*!< exint periph reset */
  135. CRM_GPIOA_PERIPH_RESET = MAKE_VALUE(0x0C, 2), /*!< gpioa periph reset */
  136. CRM_GPIOB_PERIPH_RESET = MAKE_VALUE(0x0C, 3), /*!< gpiob periph reset */
  137. CRM_GPIOC_PERIPH_RESET = MAKE_VALUE(0x0C, 4), /*!< gpioc periph reset */
  138. CRM_GPIOD_PERIPH_RESET = MAKE_VALUE(0x0C, 5), /*!< gpiod periph reset */
  139. CRM_GPIOF_PERIPH_RESET = MAKE_VALUE(0x0C, 7), /*!< gpiof periph reset */
  140. CRM_ADC1_PERIPH_RESET = MAKE_VALUE(0x0C, 9), /*!< adc1 periph reset */
  141. CRM_TMR1_PERIPH_RESET = MAKE_VALUE(0x0C, 11), /*!< tmr1 periph reset */
  142. CRM_SPI1_PERIPH_RESET = MAKE_VALUE(0x0C, 12), /*!< spi2 periph reset */
  143. CRM_USART1_PERIPH_RESET = MAKE_VALUE(0x0C, 14), /*!< usart1 periph reset */
  144. CRM_TMR9_PERIPH_RESET = MAKE_VALUE(0x0C, 19), /*!< tmr9 periph reset */
  145. CRM_TMR10_PERIPH_RESET = MAKE_VALUE(0x0C, 20), /*!< tmr10 periph reset */
  146. CRM_TMR11_PERIPH_RESET = MAKE_VALUE(0x0C, 21), /*!< tmr11 periph reset */
  147. /* apb1 periph */
  148. CRM_TMR2_PERIPH_RESET = MAKE_VALUE(0x10, 0), /*!< tmr2 periph reset */
  149. CRM_TMR3_PERIPH_RESET = MAKE_VALUE(0x10, 1), /*!< tmr3 periph reset */
  150. CRM_TMR4_PERIPH_RESET = MAKE_VALUE(0x10, 2), /*!< tmr4 periph reset */
  151. CRM_TMR5_PERIPH_RESET = MAKE_VALUE(0x10, 3), /*!< tmr5 periph reset */
  152. CRM_CMP_PERIPH_RESET = MAKE_VALUE(0x10, 9), /*!< comparator periph reset */
  153. CRM_WWDT_PERIPH_RESET = MAKE_VALUE(0x10, 11), /*!< wwdt periph reset */
  154. CRM_SPI2_PERIPH_RESET = MAKE_VALUE(0x10, 14), /*!< spi2 periph reset */
  155. CRM_USART2_PERIPH_RESET = MAKE_VALUE(0x10, 17), /*!< usart2 periph reset */
  156. CRM_USART3_PERIPH_RESET = MAKE_VALUE(0x10, 18), /*!< usart3 periph reset */
  157. CRM_UART4_PERIPH_RESET = MAKE_VALUE(0x10, 19), /*!< uart4 periph reset */
  158. CRM_UART5_PERIPH_RESET = MAKE_VALUE(0x10, 20), /*!< uart5 periph reset */
  159. CRM_I2C1_PERIPH_RESET = MAKE_VALUE(0x10, 21), /*!< i2c1 periph reset */
  160. CRM_I2C2_PERIPH_RESET = MAKE_VALUE(0x10, 22), /*!< i2c2 periph reset */
  161. CRM_CAN1_PERIPH_RESET = MAKE_VALUE(0x10, 25), /*!< can1 periph reset */
  162. CRM_PWC_PERIPH_RESET = MAKE_VALUE(0x10, 28), /*!< pwc periph reset */
  163. } crm_periph_reset_type;
  164. /**
  165. * @brief crm periph clock in sleep mode
  166. */
  167. typedef enum
  168. {
  169. /* ahb periph */
  170. CRM_SRAM_PERIPH_CLOCK_SLEEP_MODE = MAKE_VALUE(0x14, 2), /*!< sram sleep mode periph clock */
  171. CRM_FLASH_PERIPH_CLOCK_SLEEP_MODE = MAKE_VALUE(0x14, 4) /*!< flash sleep mode periph clock */
  172. } crm_periph_clock_sleepmd_type;
  173. /**
  174. * @brief crm pll mult_x
  175. */
  176. typedef enum
  177. {
  178. CRM_PLL_MULT_2 = 0, /*!< pll multiplication factor 2 */
  179. CRM_PLL_MULT_3 = 1, /*!< pll multiplication factor 3 */
  180. CRM_PLL_MULT_4 = 2, /*!< pll multiplication factor 4 */
  181. CRM_PLL_MULT_5 = 3, /*!< pll multiplication factor 5 */
  182. CRM_PLL_MULT_6 = 4, /*!< pll multiplication factor 6 */
  183. CRM_PLL_MULT_7 = 5, /*!< pll multiplication factor 7 */
  184. CRM_PLL_MULT_8 = 6, /*!< pll multiplication factor 8 */
  185. CRM_PLL_MULT_9 = 7, /*!< pll multiplication factor 9 */
  186. CRM_PLL_MULT_10 = 8, /*!< pll multiplication factor 10 */
  187. CRM_PLL_MULT_11 = 9, /*!< pll multiplication factor 11 */
  188. CRM_PLL_MULT_12 = 10, /*!< pll multiplication factor 12 */
  189. CRM_PLL_MULT_13 = 11, /*!< pll multiplication factor 13 */
  190. CRM_PLL_MULT_14 = 12, /*!< pll multiplication factor 14 */
  191. CRM_PLL_MULT_15 = 13, /*!< pll multiplication factor 15 */
  192. CRM_PLL_MULT_16 = 15, /*!< pll multiplication factor 16 */
  193. CRM_PLL_MULT_17 = 16, /*!< pll multiplication factor 17 */
  194. CRM_PLL_MULT_18 = 17, /*!< pll multiplication factor 18 */
  195. CRM_PLL_MULT_19 = 18, /*!< pll multiplication factor 19 */
  196. CRM_PLL_MULT_20 = 19, /*!< pll multiplication factor 20 */
  197. CRM_PLL_MULT_21 = 20, /*!< pll multiplication factor 21 */
  198. CRM_PLL_MULT_22 = 21, /*!< pll multiplication factor 22 */
  199. CRM_PLL_MULT_23 = 22, /*!< pll multiplication factor 23 */
  200. CRM_PLL_MULT_24 = 23, /*!< pll multiplication factor 24 */
  201. CRM_PLL_MULT_25 = 24, /*!< pll multiplication factor 25 */
  202. CRM_PLL_MULT_26 = 25, /*!< pll multiplication factor 26 */
  203. CRM_PLL_MULT_27 = 26, /*!< pll multiplication factor 27 */
  204. CRM_PLL_MULT_28 = 27, /*!< pll multiplication factor 28 */
  205. CRM_PLL_MULT_29 = 28, /*!< pll multiplication factor 29 */
  206. CRM_PLL_MULT_30 = 29, /*!< pll multiplication factor 30 */
  207. CRM_PLL_MULT_31 = 30, /*!< pll multiplication factor 31 */
  208. CRM_PLL_MULT_32 = 31, /*!< pll multiplication factor 32 */
  209. CRM_PLL_MULT_33 = 32, /*!< pll multiplication factor 33 */
  210. CRM_PLL_MULT_34 = 33, /*!< pll multiplication factor 34 */
  211. CRM_PLL_MULT_35 = 34, /*!< pll multiplication factor 35 */
  212. CRM_PLL_MULT_36 = 35, /*!< pll multiplication factor 36 */
  213. CRM_PLL_MULT_37 = 36, /*!< pll multiplication factor 37 */
  214. CRM_PLL_MULT_38 = 37, /*!< pll multiplication factor 38 */
  215. CRM_PLL_MULT_39 = 38, /*!< pll multiplication factor 39 */
  216. CRM_PLL_MULT_40 = 39, /*!< pll multiplication factor 40 */
  217. CRM_PLL_MULT_41 = 40, /*!< pll multiplication factor 41 */
  218. CRM_PLL_MULT_42 = 41, /*!< pll multiplication factor 42 */
  219. CRM_PLL_MULT_43 = 42, /*!< pll multiplication factor 43 */
  220. CRM_PLL_MULT_44 = 43, /*!< pll multiplication factor 44 */
  221. CRM_PLL_MULT_45 = 44, /*!< pll multiplication factor 45 */
  222. CRM_PLL_MULT_46 = 45, /*!< pll multiplication factor 46 */
  223. CRM_PLL_MULT_47 = 46, /*!< pll multiplication factor 47 */
  224. CRM_PLL_MULT_48 = 47, /*!< pll multiplication factor 48 */
  225. CRM_PLL_MULT_49 = 48, /*!< pll multiplication factor 49 */
  226. CRM_PLL_MULT_50 = 49, /*!< pll multiplication factor 50 */
  227. CRM_PLL_MULT_51 = 50, /*!< pll multiplication factor 51 */
  228. CRM_PLL_MULT_52 = 51, /*!< pll multiplication factor 52 */
  229. CRM_PLL_MULT_53 = 52, /*!< pll multiplication factor 53 */
  230. CRM_PLL_MULT_54 = 53, /*!< pll multiplication factor 54 */
  231. CRM_PLL_MULT_55 = 54, /*!< pll multiplication factor 55 */
  232. CRM_PLL_MULT_56 = 55, /*!< pll multiplication factor 56 */
  233. CRM_PLL_MULT_57 = 56, /*!< pll multiplication factor 57 */
  234. CRM_PLL_MULT_58 = 57, /*!< pll multiplication factor 58 */
  235. CRM_PLL_MULT_59 = 58, /*!< pll multiplication factor 59 */
  236. CRM_PLL_MULT_60 = 59, /*!< pll multiplication factor 60 */
  237. CRM_PLL_MULT_61 = 60, /*!< pll multiplication factor 61 */
  238. CRM_PLL_MULT_62 = 61, /*!< pll multiplication factor 62 */
  239. CRM_PLL_MULT_63 = 62, /*!< pll multiplication factor 63 */
  240. CRM_PLL_MULT_64 = 63 /*!< pll multiplication factor 64 */
  241. } crm_pll_mult_type;
  242. /**
  243. * @brief crm pll fref_x
  244. */
  245. typedef enum
  246. {
  247. CRM_PLL_FREF_4M = 0, /*!< pll refrence clock between 3.9 mhz and 5 mhz */
  248. CRM_PLL_FREF_6M = 1, /*!< pll refrence clock between 5.2 mhz and 6.25 mhz */
  249. CRM_PLL_FREF_8M = 2, /*!< pll refrence clock between 7.8125 mhz and 8.33 mhz */
  250. CRM_PLL_FREF_12M = 3, /*!< pll refrence clock between 8.33 mhz and 12.5 mhz */
  251. CRM_PLL_FREF_16M = 4, /*!< pll refrence clock between 15.625 mhz and 20.83 mhz */
  252. CRM_PLL_FREF_25M = 5, /*!< pll refrence clock between 20.83 mhz and 31.255 mhz */
  253. } crm_pll_fref_type;
  254. /**
  255. * @brief crm pll clock source
  256. */
  257. typedef enum
  258. {
  259. CRM_PLL_SOURCE_HICK = 0x00, /*!< high speed internal clock as pll reference clock source */
  260. CRM_PLL_SOURCE_HEXT = 0x01, /*!< high speed external crystal as pll reference clock source */
  261. CRM_PLL_SOURCE_HEXT_DIV = 0x02 /*!< high speed external crystal div as pll reference clock source */
  262. } crm_pll_clock_source_type;
  263. /**
  264. * @brief crm pll fr
  265. */
  266. typedef enum
  267. {
  268. CRM_PLL_FR_1 = 0x00, /*!< pll post-division div1 */
  269. CRM_PLL_FR_2 = 0x01, /*!< pll post-division div2 */
  270. CRM_PLL_FR_4 = 0x02, /*!< pll post-division div4 */
  271. CRM_PLL_FR_8 = 0x03, /*!< pll post-division div8 */
  272. CRM_PLL_FR_16 = 0x04, /*!< pll post-division div16 */
  273. CRM_PLL_FR_32 = 0x05 /*!< pll post-division div32 */
  274. } crm_pll_fr_type;
  275. /**
  276. * @brief crm clock source
  277. */
  278. typedef enum
  279. {
  280. CRM_CLOCK_SOURCE_HICK = 0x00, /*!< high speed internal clock */
  281. CRM_CLOCK_SOURCE_HEXT = 0x01, /*!< high speed external crystal */
  282. CRM_CLOCK_SOURCE_PLL = 0x02, /*!< phase locking loop */
  283. CRM_CLOCK_SOURCE_LEXT = 0x03, /*!< low speed external crystal */
  284. CRM_CLOCK_SOURCE_LICK = 0x04 /*!< low speed internal clock */
  285. } crm_clock_source_type;
  286. /**
  287. * @brief crm ahb division
  288. */
  289. typedef enum
  290. {
  291. CRM_AHB_DIV_1 = 0x00, /*!< sclk div1 to ahbclk */
  292. CRM_AHB_DIV_2 = 0x08, /*!< sclk div2 to ahbclk */
  293. CRM_AHB_DIV_4 = 0x09, /*!< sclk div4 to ahbclk */
  294. CRM_AHB_DIV_8 = 0x0A, /*!< sclk div8 to ahbclk */
  295. CRM_AHB_DIV_16 = 0x0B, /*!< sclk div16 to ahbclk */
  296. CRM_AHB_DIV_64 = 0x0C, /*!< sclk div64 to ahbclk */
  297. CRM_AHB_DIV_128 = 0x0D, /*!< sclk div128 to ahbclk */
  298. CRM_AHB_DIV_256 = 0x0E, /*!< sclk div256 to ahbclk */
  299. CRM_AHB_DIV_512 = 0x0F /*!< sclk div512 to ahbclk */
  300. } crm_ahb_div_type;
  301. /**
  302. * @brief crm apb1 division
  303. */
  304. typedef enum
  305. {
  306. CRM_APB1_DIV_1 = 0x00, /*!< ahbclk div1 to apb1clk */
  307. CRM_APB1_DIV_2 = 0x04, /*!< ahbclk div2 to apb1clk */
  308. CRM_APB1_DIV_4 = 0x05, /*!< ahbclk div4 to apb1clk */
  309. CRM_APB1_DIV_8 = 0x06, /*!< ahbclk div8 to apb1clk */
  310. CRM_APB1_DIV_16 = 0x07 /*!< ahbclk div16 to apb1clk */
  311. } crm_apb1_div_type;
  312. /**
  313. * @brief crm apb2 division
  314. */
  315. typedef enum
  316. {
  317. CRM_APB2_DIV_1 = 0x00, /*!< ahbclk div1 to apb2clk */
  318. CRM_APB2_DIV_2 = 0x04, /*!< ahbclk div2 to apb2clk */
  319. CRM_APB2_DIV_4 = 0x05, /*!< ahbclk div4 to apb2clk */
  320. CRM_APB2_DIV_8 = 0x06, /*!< ahbclk div8 to apb2clk */
  321. CRM_APB2_DIV_16 = 0x07 /*!< ahbclk div16 to apb2clk */
  322. } crm_apb2_div_type;
  323. /**
  324. * @brief crm adc division
  325. */
  326. typedef enum
  327. {
  328. CRM_ADC_DIV_2 = 0x00, /*!< apb2clk div2 to adcclk */
  329. CRM_ADC_DIV_4 = 0x01, /*!< apb2clk div4 to adcclk */
  330. CRM_ADC_DIV_6 = 0x02, /*!< apb2clk div6 to adcclk */
  331. CRM_ADC_DIV_8 = 0x03, /*!< apb2clk div8 to adcclk */
  332. CRM_ADC_DIV_12 = 0x05, /*!< apb2clk div12 to adcclk */
  333. CRM_ADC_DIV_16 = 0x07 /*!< apb2clk div16 to adcclk */
  334. } crm_adc_div_type;
  335. /**
  336. * @brief crm usb division
  337. */
  338. typedef enum
  339. {
  340. CRM_USB_DIV_1_5 = 0x00, /*!< pllclk div1.5 to usbclk */
  341. CRM_USB_DIV_1 = 0x01, /*!< pllclk div1 to usbclk */
  342. CRM_USB_DIV_2_5 = 0x02, /*!< pllclk div2.5 to usbclk */
  343. CRM_USB_DIV_2 = 0x03, /*!< pllclk div2 to usbclk */
  344. CRM_USB_DIV_3_5 = 0x04, /*!< pllclk div3.5 to usbclk */
  345. CRM_USB_DIV_3 = 0x05, /*!< pllclk div3 to usbclk */
  346. CRM_USB_DIV_4 = 0x06 /*!< pllclk div4 to usbclk */
  347. } crm_usb_div_type;
  348. /**
  349. * @brief crm ertc clock
  350. */
  351. typedef enum
  352. {
  353. CRM_ERTC_CLOCK_NOCLK = 0x00, /*!< no clock as ertc clock source */
  354. CRM_ERTC_CLOCK_LEXT = 0x01, /*!< low speed external crystal as ertc clock source */
  355. CRM_ERTC_CLOCK_LICK = 0x02, /*!< low speed internal clock as ertc clock source */
  356. CRM_ERTC_CLOCK_HEXT_DIV = 0x03 /*!< high speed external crystal div as ertc clock source */
  357. } crm_ertc_clock_type;
  358. /**
  359. * @brief crm hick 48mhz division
  360. */
  361. typedef enum
  362. {
  363. CRM_HICK48_DIV6 = 0x00, /*!< high speed internal clock (48 mhz) div6 */
  364. CRM_HICK48_NODIV = 0x01 /*!< high speed internal clock (48 mhz) no div */
  365. } crm_hick_div_6_type;
  366. /**
  367. * @brief crm sclk select
  368. */
  369. typedef enum
  370. {
  371. CRM_SCLK_HICK = 0x00, /*!< select high speed internal clock as sclk */
  372. CRM_SCLK_HEXT = 0x01, /*!< select high speed external crystal as sclk */
  373. CRM_SCLK_PLL = 0x02 /*!< select phase locking loop clock as sclk */
  374. } crm_sclk_type;
  375. /**
  376. * @brief crm clkout select
  377. */
  378. typedef enum
  379. {
  380. CRM_CLKOUT_NOCLK = 0x00, /*!< output no clock to clkout pin */
  381. CRM_CLKOUT_LICK = 0x02, /*!< output low speed internal clock to clkout pin */
  382. CRM_CLKOUT_LEXT = 0x03, /*!< output low speed external crystal to clkout pin */
  383. CRM_CLKOUT_SCLK = 0x04, /*!< output system clock to clkout pin */
  384. CRM_CLKOUT_HICK = 0x05, /*!< output high speed internal clock to clkout pin */
  385. CRM_CLKOUT_HEXT = 0x06, /*!< output high speed external crystal to clkout pin */
  386. CRM_CLKOUT_PLL_DIV_2 = 0x07, /*!< output phase locking loop clock div2 to clkout pin */
  387. CRM_CLKOUT_PLL_DIV_4 = 0x0C, /*!< output phase locking loop clock div4 to clkout pin */
  388. CRM_CLKOUT_USB = 0x0D, /*!< output usbclk to clkout pin */
  389. CRM_CLKOUT_ADC = 0x0E /*!< output adcclk to clkout pin */
  390. } crm_clkout_select_type;
  391. /**
  392. * @brief crm clkout division
  393. */
  394. typedef enum
  395. {
  396. CRM_CLKOUT_DIV_1 = 0x00, /*!< clkout div1 */
  397. CRM_CLKOUT_DIV_2 = 0x08, /*!< clkout div2 */
  398. CRM_CLKOUT_DIV_4 = 0x09, /*!< clkout div4 */
  399. CRM_CLKOUT_DIV_8 = 0x0A, /*!< clkout div8 */
  400. CRM_CLKOUT_DIV_16 = 0x0B, /*!< clkout div16 */
  401. CRM_CLKOUT_DIV_64 = 0x0C, /*!< clkout div64 */
  402. CRM_CLKOUT_DIV_128 = 0x0D, /*!< clkout div128 */
  403. CRM_CLKOUT_DIV_256 = 0x0E, /*!< clkout div256 */
  404. CRM_CLKOUT_DIV_512 = 0x0F /*!< clkout div512 */
  405. } crm_clkout_div_type;
  406. /**
  407. * @brief crm auto step mode
  408. */
  409. typedef enum
  410. {
  411. CRM_AUTO_STEP_MODE_DISABLE = 0x00, /*!< disable auto step mode */
  412. CRM_AUTO_STEP_MODE_ENABLE = 0x03 /*!< enable auto step mode */
  413. } crm_auto_step_mode_type;
  414. /**
  415. * @brief crm usb 48 mhz clock source select
  416. */
  417. typedef enum
  418. {
  419. CRM_USB_CLOCK_SOURCE_PLL = 0x00, /*!< select phase locking loop clock as usb clock source */
  420. CRM_USB_CLOCK_SOURCE_HICK = 0x01 /*!< select high speed internal clock as usb clock source */
  421. } crm_usb_clock_source_type;
  422. /**
  423. * @brief crm hick as system clock frequency select
  424. */
  425. typedef enum
  426. {
  427. CRM_HICK_SCLK_8MHZ = 0x00, /*!< fixed 8 mhz when hick is selected as sclk */
  428. CRM_HICK_SCLK_48MHZ = 0x01 /*!< 8 mhz or 48 mhz depend on hickdiv when hick is selected as sclk */
  429. } crm_hick_sclk_frequency_type;
  430. /**
  431. * @brief crm clocks freqency structure
  432. */
  433. typedef struct
  434. {
  435. uint32_t sclk_freq; /*!< system clock frequency */
  436. uint32_t ahb_freq; /*!< ahb bus clock frequency */
  437. uint32_t apb2_freq; /*!< apb2 bus clock frequency */
  438. uint32_t apb1_freq; /*!< apb1 bus clock frequency */
  439. uint32_t adc_freq; /*!< adc clock frequency */
  440. } crm_clocks_freq_type;
  441. /**
  442. * @brief type define crm register all
  443. */
  444. typedef struct
  445. {
  446. /**
  447. * @brief crm ctrl register, offset:0x00
  448. */
  449. union
  450. {
  451. __IO uint32_t ctrl;
  452. struct
  453. {
  454. __IO uint32_t hicken : 1; /* [0] */
  455. __IO uint32_t hickstbl : 1; /* [1] */
  456. __IO uint32_t hicktrim : 6; /* [7:2] */
  457. __IO uint32_t hickcal : 8; /* [15:8] */
  458. __IO uint32_t hexten : 1; /* [16] */
  459. __IO uint32_t hextstbl : 1; /* [17] */
  460. __IO uint32_t hextbyps : 1; /* [18] */
  461. __IO uint32_t cfden : 1; /* [19] */
  462. __IO uint32_t reserved1 : 4; /* [23:20] */
  463. __IO uint32_t pllen : 1; /* [24] */
  464. __IO uint32_t pllstbl : 1; /* [25] */
  465. __IO uint32_t reserved2 : 6; /* [31:26] */
  466. } ctrl_bit;
  467. };
  468. /**
  469. * @brief crm cfg register, offset:0x04
  470. */
  471. union
  472. {
  473. __IO uint32_t cfg;
  474. struct
  475. {
  476. __IO uint32_t sclksel : 2; /* [1:0] */
  477. __IO uint32_t sclksts : 2; /* [3:2] */
  478. __IO uint32_t ahbdiv : 4; /* [7:4] */
  479. __IO uint32_t apb1div : 3; /* [10:8] */
  480. __IO uint32_t apb2div : 3; /* [13:11] */
  481. __IO uint32_t adcdiv_l : 2; /* [15:14] */
  482. __IO uint32_t pllrcs : 1; /* [16] */
  483. __IO uint32_t pllhextdiv : 1; /* [17] */
  484. __IO uint32_t pllmult_l : 4; /* [21:18] */
  485. __IO uint32_t usbdiv_l : 2; /* [23:22] */
  486. __IO uint32_t clkout_sel : 3; /* [26:24] */
  487. __IO uint32_t usbdiv_h : 1; /* [27] */
  488. __IO uint32_t adcdiv_h : 1; /* [28] */
  489. __IO uint32_t pllmult_h : 2; /* [30:29] */
  490. __IO uint32_t reserved1 : 1; /* [31] */
  491. } cfg_bit;
  492. };
  493. /**
  494. * @brief crm clkint register, offset:0x08
  495. */
  496. union
  497. {
  498. __IO uint32_t clkint;
  499. struct
  500. {
  501. __IO uint32_t lickstblf : 1; /* [0] */
  502. __IO uint32_t lextstblf : 1; /* [1] */
  503. __IO uint32_t hickstblf : 1; /* [2] */
  504. __IO uint32_t hextstblf : 1; /* [3] */
  505. __IO uint32_t pllstblf : 1; /* [4] */
  506. __IO uint32_t reserved1 : 2; /* [6:5] */
  507. __IO uint32_t cfdf : 1; /* [7] */
  508. __IO uint32_t lickstblien : 1; /* [8] */
  509. __IO uint32_t lextstblien : 1; /* [9] */
  510. __IO uint32_t hickstblien : 1; /* [10] */
  511. __IO uint32_t hextstblien : 1; /* [11] */
  512. __IO uint32_t pllstblien : 1; /* [12] */
  513. __IO uint32_t reserved2 : 3; /* [15:13] */
  514. __IO uint32_t lickstblfc : 1; /* [16] */
  515. __IO uint32_t lextstblfc : 1; /* [17] */
  516. __IO uint32_t hickstblfc : 1; /* [18] */
  517. __IO uint32_t hextstblfc : 1; /* [19] */
  518. __IO uint32_t pllstblfc : 1; /* [20] */
  519. __IO uint32_t reserved3 : 2; /* [22:21] */
  520. __IO uint32_t cfdfc : 1; /* [23] */
  521. __IO uint32_t reserved4 : 8; /* [31:24] */
  522. } clkint_bit;
  523. };
  524. /**
  525. * @brief crm apb2rst register, offset:0x0C
  526. */
  527. union
  528. {
  529. __IO uint32_t apb2rst;
  530. struct
  531. {
  532. __IO uint32_t iomuxrst : 1; /* [0] */
  533. __IO uint32_t exintrst : 1; /* [1] */
  534. __IO uint32_t gpioarst : 1; /* [2] */
  535. __IO uint32_t gpiobrst : 1; /* [3] */
  536. __IO uint32_t gpiocrst : 1; /* [4] */
  537. __IO uint32_t gpiodrst : 1; /* [5] */
  538. __IO uint32_t reserved1 : 1; /* [6] */
  539. __IO uint32_t gpiofrst : 1; /* [7] */
  540. __IO uint32_t reserved2 : 1; /* [8] */
  541. __IO uint32_t adc1rst : 1; /* [9] */
  542. __IO uint32_t reserved3 : 1; /* [10] */
  543. __IO uint32_t tmr1rst : 1; /* [11] */
  544. __IO uint32_t spi1rst : 1; /* [12] */
  545. __IO uint32_t reserved4 : 1; /* [13] */
  546. __IO uint32_t usart1rst : 1; /* [14] */
  547. __IO uint32_t reserved5 : 4; /* [18:15] */
  548. __IO uint32_t tmr9rst : 1; /* [19] */
  549. __IO uint32_t tmr10rst : 1; /* [20] */
  550. __IO uint32_t tmr11rst : 1; /* [21] */
  551. __IO uint32_t reserved6 : 10;/* [31:22] */
  552. } apb2rst_bit;
  553. };
  554. /**
  555. * @brief crm apb1rst register, offset:0x10
  556. */
  557. union
  558. {
  559. __IO uint32_t apb1rst;
  560. struct
  561. {
  562. __IO uint32_t tmr2rst : 1; /* [0] */
  563. __IO uint32_t tmr3rst : 1; /* [1] */
  564. __IO uint32_t tmr4rst : 1; /* [2] */
  565. __IO uint32_t tmr5rst : 1; /* [3] */
  566. __IO uint32_t reserved1 : 5; /* [8:4] */
  567. __IO uint32_t cmprst : 1; /* [9] */
  568. __IO uint32_t reserved2 : 1; /* [10] */
  569. __IO uint32_t wwdtrst : 1; /* [11] */
  570. __IO uint32_t reserved3 : 2; /* [13:12] */
  571. __IO uint32_t spi2rst : 1; /* [14] */
  572. __IO uint32_t reserved4 : 2; /* [16:15] */
  573. __IO uint32_t usart2rst : 1; /* [17] */
  574. __IO uint32_t usart3rst : 1; /* [18] */
  575. __IO uint32_t uart4rst : 1; /* [19] */
  576. __IO uint32_t uart5rst : 1; /* [20] */
  577. __IO uint32_t i2c1rst : 1; /* [21] */
  578. __IO uint32_t i2c2rst : 1; /* [22] */
  579. __IO uint32_t reserved5 : 2; /* [24:23] */
  580. __IO uint32_t can1rst : 1; /* [25] */
  581. __IO uint32_t reserved6 : 2; /* [27:26] */
  582. __IO uint32_t pwcrst : 1; /* [28] */
  583. __IO uint32_t reserved7 : 3; /* [31:29] */
  584. } apb1rst_bit;
  585. };
  586. /**
  587. * @brief crm ahben register, offset:0x14
  588. */
  589. union
  590. {
  591. __IO uint32_t ahben;
  592. struct
  593. {
  594. __IO uint32_t dma1en : 1; /* [0] */
  595. __IO uint32_t dma2en : 1; /* [1] */
  596. __IO uint32_t sramen : 1; /* [2] */
  597. __IO uint32_t reserved1 : 1; /* [3] */
  598. __IO uint32_t flashen : 1; /* [4] */
  599. __IO uint32_t reserved2 : 1; /* [5] */
  600. __IO uint32_t crcen : 1; /* [6] */
  601. __IO uint32_t reserved3 : 3; /* [9:7] */
  602. __IO uint32_t sdio1en : 1; /* [10] */
  603. __IO uint32_t reserved4 : 1; /* [11] */
  604. __IO uint32_t usben : 1; /* [12] */
  605. __IO uint32_t reserved5 : 19;/* [31:13] */
  606. } ahben_bit;
  607. };
  608. /**
  609. * @brief crm apb2en register, offset:0x18
  610. */
  611. union
  612. {
  613. __IO uint32_t apb2en;
  614. struct
  615. {
  616. __IO uint32_t iomuxen : 1; /* [0] */
  617. __IO uint32_t reserved1 : 1; /* [1] */
  618. __IO uint32_t gpioaen : 1; /* [2] */
  619. __IO uint32_t gpioben : 1; /* [3] */
  620. __IO uint32_t gpiocen : 1; /* [4] */
  621. __IO uint32_t gpioden : 1; /* [5] */
  622. __IO uint32_t reserved2 : 1; /* [6] */
  623. __IO uint32_t gpiofen : 1; /* [7] */
  624. __IO uint32_t reserved3 : 1; /* [8] */
  625. __IO uint32_t adc1en : 1; /* [9] */
  626. __IO uint32_t reserved4 : 1; /* [10] */
  627. __IO uint32_t tmr1en : 1; /* [11] */
  628. __IO uint32_t spi1en : 1; /* [12] */
  629. __IO uint32_t reserved5 : 1; /* [13] */
  630. __IO uint32_t usart1en : 1; /* [14] */
  631. __IO uint32_t reserved6 : 4; /* [18:15] */
  632. __IO uint32_t tmr9en : 1; /* [19] */
  633. __IO uint32_t tmr10en : 1; /* [20] */
  634. __IO uint32_t tmr11en : 1; /* [21] */
  635. __IO uint32_t reserved7 : 10;/* [31:22] */
  636. } apb2en_bit;
  637. };
  638. /**
  639. * @brief crm apb1en register, offset:0x1C
  640. */
  641. union
  642. {
  643. __IO uint32_t apb1en;
  644. struct
  645. {
  646. __IO uint32_t tmr2en : 1; /* [0] */
  647. __IO uint32_t tmr3en : 1; /* [1] */
  648. __IO uint32_t tmr4en : 1; /* [2] */
  649. __IO uint32_t tmr5en : 1; /* [3] */
  650. __IO uint32_t reserved1 : 5; /* [8:4] */
  651. __IO uint32_t cmpen : 1; /* [9] */
  652. __IO uint32_t reserved2 : 1; /* [10] */
  653. __IO uint32_t wwdten : 1; /* [11] */
  654. __IO uint32_t reserved3 : 2; /* [13:12] */
  655. __IO uint32_t spi2en : 1; /* [14] */
  656. __IO uint32_t reserved4 : 2; /* [16:15] */
  657. __IO uint32_t usart2en : 1; /* [17] */
  658. __IO uint32_t usart3en : 1; /* [18] */
  659. __IO uint32_t uart4en : 1; /* [19] */
  660. __IO uint32_t uart5en : 1; /* [20] */
  661. __IO uint32_t i2c1en : 1; /* [21] */
  662. __IO uint32_t i2c2en : 1; /* [22] */
  663. __IO uint32_t reserved5 : 2; /* [24:23] */
  664. __IO uint32_t can1en : 1; /* [25] */
  665. __IO uint32_t reserved6 : 1; /* [26] */
  666. __IO uint32_t bpren : 1; /* [27] */
  667. __IO uint32_t pwcen : 1; /* [28] */
  668. __IO uint32_t reserved7 : 2; /* [31:29] */
  669. } apb1en_bit;
  670. };
  671. /**
  672. * @brief crm bpdc register, offset:0x20
  673. */
  674. union
  675. {
  676. __IO uint32_t bpdc;
  677. struct
  678. {
  679. __IO uint32_t lexten : 1; /* [0] */
  680. __IO uint32_t lextstbl : 1; /* [1] */
  681. __IO uint32_t lextbyps : 1; /* [2] */
  682. __IO uint32_t reserved1 : 5; /* [7:3] */
  683. __IO uint32_t ertcsel : 2; /* [9:8] */
  684. __IO uint32_t reserved2 : 5; /* [14:10] */
  685. __IO uint32_t ertcen : 1; /* [15] */
  686. __IO uint32_t bpdrst : 1; /* [16] */
  687. __IO uint32_t reserved3 : 15;/* [31:17] */
  688. } bpdc_bit;
  689. };
  690. /**
  691. * @brief crm ctrlsts register, offset:0x24
  692. */
  693. union
  694. {
  695. __IO uint32_t ctrlsts;
  696. struct
  697. {
  698. __IO uint32_t licken : 1; /* [0] */
  699. __IO uint32_t lickstbl : 1; /* [1] */
  700. __IO uint32_t reserved1 : 22;/* [23:2] */
  701. __IO uint32_t rstfc : 1; /* [24] */
  702. __IO uint32_t reserved2 : 1; /* [25] */
  703. __IO uint32_t nrstf : 1; /* [26] */
  704. __IO uint32_t porrstf : 1; /* [27] */
  705. __IO uint32_t swrstf : 1; /* [28] */
  706. __IO uint32_t wdtrstf : 1; /* [29] */
  707. __IO uint32_t wwdtrstf : 1; /* [30] */
  708. __IO uint32_t lprstf : 1; /* [31] */
  709. } ctrlsts_bit;
  710. };
  711. /**
  712. * @brief crm ahbrst register, offset:0x28
  713. */
  714. union
  715. {
  716. __IO uint32_t ahbrst;
  717. struct
  718. {
  719. __IO uint32_t reserved1 : 12;/* [11:0] */
  720. __IO uint32_t usbrst : 1; /* [12] */
  721. __IO uint32_t reserved2 : 19;/* [31:13] */
  722. } ahbrst_bit;
  723. };
  724. /**
  725. * @brief crm pll register, offset:0x2C
  726. */
  727. union
  728. {
  729. __IO uint32_t pll;
  730. struct
  731. {
  732. __IO uint32_t pllfr : 3; /* [2:0] */
  733. __IO uint32_t reserved1 : 1; /* [3] */
  734. __IO uint32_t pllms : 4; /* [7:4] */
  735. __IO uint32_t pllns : 9; /* [16:8] */
  736. __IO uint32_t reserved2 : 7; /* [23:17] */
  737. __IO uint32_t pllfref : 3; /* [26:24] */
  738. __IO uint32_t reserved3 : 4; /* [30:27] */
  739. __IO uint32_t pllcfgen : 1; /* [31] */
  740. } pll_bit;
  741. };
  742. /**
  743. * @brief crm misc1 register, offset:0x30
  744. */
  745. union
  746. {
  747. __IO uint32_t misc1;
  748. struct
  749. {
  750. __IO uint32_t hickcal_key : 8; /* [7:0] */
  751. __IO uint32_t reserved1 : 8; /* [15:8] */
  752. __IO uint32_t clkout_sel : 1; /* [16] */
  753. __IO uint32_t reserved2 : 7; /* [23:17] */
  754. __IO uint32_t usbbufs : 1; /* [24] */
  755. __IO uint32_t hickdiv : 1; /* [25] */
  756. __IO uint32_t reserved3 : 2; /* [27:26] */
  757. __IO uint32_t clkoutdiv : 4; /* [31:28] */
  758. } misc1_bit;
  759. };
  760. /**
  761. * @brief crm reserved2 register, offset:0x40~0x34
  762. */
  763. __IO uint32_t reserved2[4];
  764. /**
  765. * @brief crm otg_extctrl register, offset:0x44
  766. */
  767. union
  768. {
  769. __IO uint32_t otg_extctrl;
  770. struct
  771. {
  772. __IO uint32_t reserved1 : 30;/* [29:0] */
  773. __IO uint32_t usbdivrst : 1; /* [30] */
  774. __IO uint32_t ep3_rmpen : 1; /* [31] */
  775. } otg_extctrl_bit;
  776. };
  777. /**
  778. * @brief crm reserved3 register, offset:0x50~0x48
  779. */
  780. __IO uint32_t reserved3[3];
  781. /**
  782. * @brief crm misc2 register, offset:0x54
  783. */
  784. union
  785. {
  786. __IO uint32_t misc2;
  787. struct
  788. {
  789. __IO uint32_t reserved1 : 4; /* [3:0] */
  790. __IO uint32_t auto_step_en : 2; /* [5:4] */
  791. __IO uint32_t reserved2 : 2; /* [7:6] */
  792. __IO uint32_t hick_to_usb : 1; /* [8] */
  793. __IO uint32_t hick_to_sclk : 1; /* [9] */
  794. __IO uint32_t reserved3 : 22;/* [31:10] */
  795. } misc2_bit;
  796. };
  797. } crm_type;
  798. /**
  799. * @}
  800. */
  801. #define CRM ((crm_type *) CRM_BASE)
  802. /** @defgroup CRM_exported_functions
  803. * @{
  804. */
  805. void crm_reset(void);
  806. void crm_lext_bypass(confirm_state new_state);
  807. void crm_hext_bypass(confirm_state new_state);
  808. flag_status crm_flag_get(uint32_t flag);
  809. error_status crm_hext_stable_wait(void);
  810. void crm_hick_clock_trimming_set(uint8_t trim_value);
  811. void crm_hick_clock_calibration_set(uint8_t cali_value);
  812. void crm_periph_clock_enable(crm_periph_clock_type value, confirm_state new_state);
  813. void crm_periph_reset(crm_periph_reset_type value, confirm_state new_state);
  814. void crm_periph_sleep_mode_clock_enable(crm_periph_clock_sleepmd_type value, confirm_state new_state);
  815. void crm_clock_source_enable(crm_clock_source_type source, confirm_state new_state);
  816. void crm_flag_clear(uint32_t flag);
  817. void crm_ertc_clock_select(crm_ertc_clock_type value);
  818. void crm_ertc_clock_enable(confirm_state new_state);
  819. void crm_ahb_div_set(crm_ahb_div_type value);
  820. void crm_apb1_div_set(crm_apb1_div_type value);
  821. void crm_apb2_div_set(crm_apb2_div_type value);
  822. void crm_adc_clock_div_set(crm_adc_div_type div_value);
  823. void crm_usb_clock_div_set(crm_usb_div_type div_value);
  824. void crm_clock_failure_detection_enable(confirm_state new_state);
  825. void crm_battery_powered_domain_reset(confirm_state new_state);
  826. void crm_pll_config(crm_pll_clock_source_type clock_source, crm_pll_mult_type mult_value);
  827. void crm_pll_config2(crm_pll_clock_source_type clock_source, uint16_t pll_ns, uint16_t pll_ms, crm_pll_fr_type pll_fr);
  828. void crm_sysclk_switch(crm_sclk_type value);
  829. crm_sclk_type crm_sysclk_switch_status_get(void);
  830. void crm_clocks_freq_get(crm_clocks_freq_type *clocks_struct);
  831. void crm_clock_out_set(crm_clkout_select_type clkout);
  832. void crm_interrupt_enable(uint32_t crm_int, confirm_state new_state);
  833. void crm_auto_step_mode_enable(confirm_state new_state);
  834. void crm_hick_divider_select(crm_hick_div_6_type value);
  835. void crm_hick_sclk_frequency_select(crm_hick_sclk_frequency_type value);
  836. void crm_usb_clock_source_select(crm_usb_clock_source_type value);
  837. void crm_clkout_div_set(crm_clkout_div_type clkout_div);
  838. void crm_otgfs_ep3_remap_enable(confirm_state new_state);
  839. void crm_usbdiv_reset(confirm_state new_state);
  840. /**
  841. * @}
  842. */
  843. /**
  844. * @}
  845. */
  846. /**
  847. * @}
  848. */
  849. #ifdef __cplusplus
  850. }
  851. #endif
  852. #endif