at32f413_crm.h 41 KB

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