System_ACM32F0x0.h 29 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717
  1. /*
  2. ******************************************************************************
  3. * @file System_ACM32F0x0.h
  4. * @version V1.0.0
  5. * @date 2020
  6. * @brief CMSIS CM0 Device Peripheral Access Layer System Headler File.
  7. ******************************************************************************
  8. */
  9. #ifndef __SYSTEM_ACM32F0x0_H__
  10. #define __SYSTEM_ACM32F0x0_H__
  11. #include "ACM32Fxx_HAL.h"
  12. /* ================================================================================ */
  13. /* ======================= Use Uart to Debug print ======================== */
  14. /* ================================================================================ */
  15. #define UART_DEBUG_ENABLE
  16. #ifdef UART_DEBUG_ENABLE
  17. #define printfS printf
  18. #else
  19. #define printfS(format, ...) ((void)0)
  20. #endif
  21. /* ================================================================================ */
  22. #define CLK_SRC_RC64M (0x00)
  23. #define CLK_SRC_XTH_PLL (0x01)
  24. #define XTH_8M_CRYSTAL
  25. //#define XTH_12M_CRYSTAL
  26. #define DEFAULT_SYSTEM_CLOCK (64000000) // 默认系统时钟为64MHz
  27. #define RD_WAIT_SET_DEFAULT 2
  28. /* CLK source Index */
  29. #define SYS_CLK_SRC_RCH (0x00) // CLK source from RC64M
  30. #define SYS_CLK_SRC_RC32K (0x01) // CLK source from RC32K
  31. #define SYS_CLK_SRC_XTH (0x02) // CLK source from XTH
  32. #define SYS_CLK_SRC_XTL (0x03) // CLK source from XTL
  33. #define SYS_CLK_SRC_PLLCLK (0x04) // CLK source from PLLCLK
  34. /* APB Frequencey Division */
  35. #define APB_CLK_DIV_0 (0 << 8)
  36. #define APB_CLK_DIV_2 (4 << 8)
  37. #define APB_CLK_DIV_4 (5 << 8)
  38. #define APB_CLK_DIV_8 (6 << 8)
  39. #define APB_CLK_DIV_16 (7 << 8)
  40. /* STOP WAKEUP Sorce */
  41. #define STOP_WAKEUP_GPIO_PIN0 BIT0
  42. #define STOP_WAKEUP_GPIO_PIN1 BIT1
  43. #define STOP_WAKEUP_GPIO_PIN2 BIT2
  44. #define STOP_WAKEUP_GPIO_PIN3 BIT3
  45. #define STOP_WAKEUP_GPIO_PIN4 BIT4
  46. #define STOP_WAKEUP_GPIO_PIN5 BIT5
  47. #define STOP_WAKEUP_GPIO_PIN6 BIT6
  48. #define STOP_WAKEUP_GPIO_PIN7 BIT7
  49. #define STOP_WAKEUP_GPIO_PIN8 BIT8
  50. #define STOP_WAKEUP_GPIO_PIN9 BIT9
  51. #define STOP_WAKEUP_GPIO_PIN10 BIT10
  52. #define STOP_WAKEUP_GPIO_PIN11 BIT11
  53. #define STOP_WAKEUP_GPIO_PIN12 BIT12
  54. #define STOP_WAKEUP_GPIO_PIN13 BIT13
  55. #define STOP_WAKEUP_GPIO_PIN14 BIT14
  56. #define STOP_WAKEUP_GPIO_PIN15 BIT15
  57. #define STOP_WAKEUP_PERIPHERAL_LVD BIT16
  58. #define STOP_WAKEUP_PERIPHERAL_RTC BIT17
  59. #define STOP_WAKEUP_PERIPHERAL_LPUART BIT18
  60. #define STOP_WAKEUP_PERIPHERAL_IWDT BIT19
  61. #define STOP_WAKEUP_PERIPHERAL_COMP1 BIT20
  62. #define STOP_WAKEUP_PERIPHERAL_COMP2 BIT21
  63. #define STOP_WAKEUP_RESERVE BIT22
  64. #define STOP_WAKEUP_PERIPHERAL_USB BIT23
  65. #define STOP_WAKEUP_ALL (0xFFFFFFU)
  66. #define STANDBY_WAKEUP_PINS 6
  67. #define STANDBY_WAKEUP_SOURCE_IO1 BIT0
  68. #define STANDBY_WAKEUP_SOURCE_IO2 BIT1
  69. #define STANDBY_WAKEUP_SOURCE_IO3 BIT2
  70. #define STANDBY_WAKEUP_SOURCE_IO4 BIT3
  71. #define STANDBY_WAKEUP_SOURCE_IO5 BIT4
  72. #define STANDBY_WAKEUP_SOURCE_IO6 BIT5
  73. #define STANDBY_WAKEUP_SOURCE_RTC BIT6
  74. #define STANDBY_WAKEUP_SOURCE_ALL 0x7FU
  75. // sleep/low power mode definition
  76. #define STOPENTRY_WFI 0
  77. #define STOPENTRY_WFE 1
  78. #define SLEEPENTRY_WFI 0
  79. #define SLEEPENTRY_WFE 1
  80. /*
  81. * @brief STOP WAKEUP EDGE structures definition
  82. */
  83. typedef enum
  84. {
  85. WAKEUP_RISING = 0,
  86. WAKEUP_FALLING = 1,
  87. WAKEUP_RISING_FALLING = 2, // 0:rising, 1:falling, 2: rising and falling
  88. }STOP_WAKEUP_EDGE;
  89. typedef enum
  90. {
  91. FUNC_DISABLE = 0x00U,
  92. FUNC_ENABLE = 0x01U,
  93. }FUNC_DISABLE_ENABLE;
  94. typedef enum
  95. {
  96. RESET_ENABLE_SOURCE_LVD = 0x00U,
  97. RESET_ENABLE_SOURCE_WDT = 0x01U,
  98. RESET_ENABLE_SOURCE_IWDT = 0x02U,
  99. RESET_ENABLE_SOURCE_LOCKUP = 0x03U,
  100. }RESET_ENABLE_SOURCE;
  101. /*
  102. * @brief Entry lowpower select interrupt mode or event mdoe
  103. */
  104. typedef enum
  105. {
  106. MODE_WFI = 0x01U,
  107. MODE_WFE = 0x00U,
  108. }enum_ENTRY_MODE_t;
  109. /*
  110. * @brief System reset source
  111. */
  112. typedef enum
  113. {
  114. RESET_SOURCE_LOCK = 0x08U,
  115. RESET_SOURCE_IWDT = 0x04U,
  116. RESET_SOURCE_WDT = 0x02U,
  117. RESET_SOURCE_LVD = 0x01U,
  118. }enum_SRST_t;
  119. typedef enum
  120. {
  121. RESET_SOURCE_EFC = 0x00U,
  122. RESET_SOURCE_NVIC_RESET = 0x01U,
  123. RESET_SOFT_RESET = 0x02U,
  124. }RESET_SOURCE;
  125. /*
  126. * @brief Peripheral Reset structures definition
  127. */
  128. typedef enum
  129. {
  130. RST_CAN1 = 31,
  131. /* RSV */
  132. RST_LCD = 29,
  133. RST_UAC = 28,
  134. RST_TIM17 = 27,
  135. RST_TIM16 = 26,
  136. RST_TIM15 = 25,
  137. RST_TIM14 = 24,
  138. /* RSV */
  139. RST_TIM6 = 22,
  140. RST_TIM3 = 21,
  141. RST_TIM1 = 20,
  142. RST_UART3 = 19,
  143. RST_EXTI = 18,
  144. RST_OPA = 17,
  145. RST_COMP = 16,
  146. RST_TKEY = 15,
  147. RST_ADC = 14,
  148. /* RSV */
  149. RST_DMA = 12,
  150. RST_CRC = 11,
  151. /* RSV */
  152. RST_WDT = 9,
  153. RST_LPUART = 8,
  154. RST_I2C2 = 7,
  155. RST_I2C1 = 6,
  156. RST_SPI2 = 5,
  157. RST_SPI1 = 4,
  158. RST_UART2 = 3,
  159. RST_UART1 = 2,
  160. RST_GPIOCD = 1,
  161. RST_GPIOAB = 0,
  162. }enum_RST_ID_t;
  163. /*
  164. * @brief Peripheral Enable structures definition
  165. */
  166. typedef enum
  167. {
  168. EN_CAN1 = 38,
  169. EN_ROM = 37,
  170. EN_HRNG = 36,
  171. EN_AES = 35,
  172. EN_TIM17 = 34,
  173. EN_TIM16 = 33,
  174. EN_TIM15 = 32,
  175. EN_TIM14 = 31,
  176. /* RSV */
  177. EN_TIM6 = 29,
  178. EN_TIM3 = 28,
  179. EN_TIM1 = 27,
  180. EN_UART3 = 26,
  181. /* RSV */
  182. EN_OPA = 24,
  183. EN_COMP = 23,
  184. EN_TKEY = 22,
  185. EN_ADC = 21,
  186. EN_RTC = 20,
  187. EN_DMA = 19,
  188. EN_CRC = 18,
  189. /* RSV */
  190. EN_LCD = 16,
  191. EN_LPUART = 15,
  192. EN_I2C2 = 14,
  193. EN_I2C1 = 13,
  194. EN_SPI2 = 12,
  195. EN_SPI1 = 11,
  196. EN_UART2 = 10,
  197. EN_UART1 = 9,
  198. EN_EFC = 6,
  199. EN_SRAM = 5,
  200. EN_EXTI = 4,
  201. /* RSV */
  202. EN_WDT = 2,
  203. EN_GPIOCD = 1,
  204. EN_GPIOAB = 0,
  205. }enum_Enable_ID_t;
  206. typedef enum
  207. {
  208. RESET_REASON_LOW_VOLTAGE = 0x00U, // low voltage detected, leads to reset
  209. RESET_REASON_WDT = 0x01U, // System WDT reset
  210. RESET_REASON_IWDT = 0x02U, // IWDT reset
  211. RESET_REASON_LOCKUP = 0x03U, // cortex-m0 lockup leads to reset
  212. RESET_REASON_SYSREQ = 0x04U, // system reset
  213. RESET_REASON_RSTN = 0x05U, // RSTN negative pulse leads to reset
  214. RESET_REASON_EFC = 0x06U, // efc reset leads to reset
  215. RESET_REASON_SOFT = 0x07U, // soft reset
  216. RESET_REASON_POR12 = 0x09U, // core power on reset, rtc not reset, eg:wakeup from standby
  217. RESET_REASON_POR = 0x0AU, // chip power on reset
  218. RESET_REASON_INVALID,
  219. }RESET_REASON;
  220. #define SYSTEM_TIMEOUT (1000000)
  221. /******************************************************************************/
  222. /* Peripheral Registers Bits Definition */
  223. /******************************************************************************/
  224. /******************************************************************************/
  225. /* (SCU) */
  226. /******************************************************************************/
  227. /**************** Bit definition for SCU RCR register ***********************/
  228. #define SCU_RCR_SRST_NOMAP BIT30
  229. #define SCU_RCR_EFC_RST BIT29
  230. #define SCU_RCR_REMAP_EN BIT16
  231. #define SCU_RCR_LOCKRST_EN BIT3
  232. #define SCU_RCR_IWDTRST_EN BIT2
  233. #define SCU_RCR_WDTRST_EN BIT1
  234. #define SCU_RCR_LVDRST_EN BIT0
  235. /**************** Bit definition for SCU RSR register ***********************/
  236. #define SCU_RSR_RSTFLAG_CLR BIT16
  237. #define SCU_RSR_PWRRST_F BIT10
  238. #define SCU_RSR_POR12RST_F BIT9
  239. #define SCU_RSR_SRST_F BIT8
  240. #define SCU_RSR_SRSTNM_F BIT7
  241. #define SCU_RSR_EFC_RST_F BIT6
  242. #define SCU_RSR_RSTN_F BIT5
  243. #define SCU_RSR_SYSREQRST_F BIT4
  244. #define SCU_RSR_LOCKRST_F BIT3
  245. #define SCU_RSR_IWDTRST_F BIT2
  246. #define SCU_RSR_WDTRST_F BIT1
  247. #define SCU_RSR_VDLRST_F BIT0
  248. /**************** Bit definition for SCU IPRST register **********************/
  249. #define SCU_IPRST_UACRST BIT28
  250. #define SCU_IPRST_TIM17RST BIT27
  251. #define SCU_IPRST_TIM16RST BIT26
  252. #define SCU_IPRST_TIM15RST BIT25
  253. #define SCU_IPRST_TIM14RST BIT24
  254. #define SCU_IPRST_TIM6RST BIT22
  255. #define SCU_IPRST_TIM3RST BIT21
  256. #define SCU_IPRST_TIM1RST BIT20
  257. #define SCU_IPRST_UART3RST BIT19
  258. #define SCU_IPRST_EXTIRST BIT18
  259. #define SCU_IPRST_OPARST BIT17
  260. #define SCU_IPRST_CMPRST BIT16
  261. #define SCU_IPRST_TKEYRST BIT15
  262. #define SCU_IPRST_ADCRST BIT14
  263. #define SCU_IPRST_DMACRST BIT12
  264. #define SCU_IPRST_CRCRST BIT11
  265. #define SCU_IPRST_IWDTRST BIT10
  266. #define SCU_IPRST_WDTRST BIT9
  267. #define SCU_IPRST_LPUART BIT8
  268. #define SCU_IPRST_I2C2RST BIT7
  269. #define SCU_IPRST_I2C1RST BIT6
  270. #define SCU_IPRST_SPI2RST BIT5
  271. #define SCU_IPRST_SPI1RST BIT4
  272. #define SCU_IPRST_UART2RST BIT3
  273. #define SCU_IPRST_UART1RST BIT2
  274. #define SCU_IPRST_GPIO2RST BIT1
  275. #define SCU_IPRST_GPIO1RST BIT0
  276. /**************** Bit definition for SCU CCR1 register ***********************/
  277. #define SCU_CCR1_SYS_CLK_SEL (BIT2|BIT1|BIT0)
  278. /**************** Bit definition for SCU CCR2 register ***********************/
  279. #define SCU_CCR2_DIVDONE BIT31
  280. #define SCU_CCR2_TKSCLK_SEL BIT16
  281. #define SCU_CCR2_FLTCLK_SEL BIT15
  282. #define SCU_CCR2_LPUCLK_SEL (BIT14|BIT13)
  283. #define SCU_CCR2_LPUARTDIV (BIT12|BIT11)
  284. #define SCU_CCR2_PCLKDIV (BIT10|BIT9|BIT8)
  285. #define SCU_CCR2_SYSDIV1 (BIT7|BIT6|BIT5|BIT4)
  286. #define SCU_CCR2_SYSDIV0 (BIT3|BIT2|BIT1|BIT0)
  287. /**************** Bit definition for SCU CIR register ***********************/
  288. #define SCU_CIR_RC4MRDYIC BIT21
  289. #define SCU_CIR_PLLLOCKIC BIT20
  290. #define SCU_CIR_XTHRDYIC BIT19
  291. #define SCU_CIR_RCHRDYIC BIT18
  292. #define SCU_CIR_XTLRDYIC BIT17
  293. #define SCU_CIR_RC32KRDYIC BIT16
  294. #define SCU_CIR_RC4MRDYIE BIT13
  295. #define SCU_CIR_PLLLOCKIE BIT12
  296. #define SCU_CIR_XTHRDYIE BIT11
  297. #define SCU_CIR_RCHRDYIE BIT10
  298. #define SCU_CIR_XTLRDYIE BIT9
  299. #define SCU_CIR_RC32KRDYIE BIT8
  300. #define SCU_CIR_RC4MRDYIF BIT5
  301. #define SCU_CIR_PLLLOCKIF BIT4
  302. #define SCU_CIR_XTHRDYIF BIT3
  303. #define SCU_CIR_RCHRDYIF BIT2
  304. #define SCU_CIR_XTLRDYIF BIT1
  305. #define SCU_CIR_RC32KRDYIF BIT0
  306. /**************** Bit definition for SCU IPCKENR register ********************/
  307. #define SCU_IPCKENR_ROMCLKEN BIT30
  308. #define SCU_IPCKENR_HRNGCLKEN BIT29
  309. #define SCU_IPCKENR_AESCLKEN BIT28
  310. #define SCU_IPCKENR_TIM17CLKEN BIT27
  311. #define SCU_IPCKENR_TIM16CLKEN BIT26
  312. #define SCU_IPCKENR_TIM15CLKEN BIT25
  313. #define SCU_IPCKENR_TIM14CLKEN BIT24
  314. #define SCU_IPCKENR_TIM6CLKEN BIT22
  315. #define SCU_IPCKENR_TIM3CLKEN BIT21
  316. #define SCU_IPCKENR_TIM1CLKEN BIT20
  317. #define SCU_IPCKENR_UART3CLKEN BIT19
  318. #define SCU_IPCKENR_OPACLKEN BIT17
  319. #define SCU_IPCKENR_CMPCLKEN BIT16
  320. #define SCU_IPCKENR_TKEYCLKEN BIT15
  321. #define SCU_IPCKENR_ADCCLKEN BIT14
  322. #define SCU_IPCKENR_RTCCLKEN BIT13
  323. #define SCU_IPCKENR_DMACCLKEN BIT12
  324. #define SCU_IPCKENR_CRCCLKEN BIT11
  325. #define SCU_IPCKENR_LPUARTCLKEN BIT8
  326. #define SCU_IPCKENR_I2C2CLKEN BIT7
  327. #define SCU_IPCKENR_I2C1CLKEN BIT6
  328. #define SCU_IPCKENR_SPI2CLKEN BIT5
  329. #define SCU_IPCKENR_SPI1CLKEN BIT4
  330. #define SCU_IPCKENR_UART2CLKEN BIT3
  331. #define SCU_IPCKENR_UART1CLKEN BIT2
  332. /**************** Bit definition for SCU IPCKENR2 register ********************/
  333. #define SCU_IPCKENR2_EFCCLKEN BIT6
  334. #define SCU_IPCKENR2_SRAMCLKEN BIT5
  335. #define SCU_IPCKENR2_EXTICLKEN BIT4
  336. #define SCU_IPCKENR2_IWDTCLKEN BIT3
  337. #define SCU_IPCKENR2_WDTCLKEN BIT2
  338. #define SCU_IPCKENR2_GPIO2CLKEN BIT1
  339. #define SCU_IPCKENR2_GPIO1CLKEN BIT0
  340. /**************** Bit definition for SCU RCHCR register **********************/
  341. #define SCU_RCHCR_RC4MRDY BIT22
  342. #define SCU_RCHCR_RC4M_TRIM (BIT21|BIT20|BIT19|BIT18|BIT17)
  343. #define SCU_RCHCR_RC4M_EN BIT16
  344. #define SCU_RCHCR_RCHRDY BIT9
  345. #define SCU_RCHCR_RCH_DIV BIT8
  346. #define SCU_RCHCR_RCH_TRIM (BIT7|BIT6|BIT5|BIT4|BIT3|BIT2|BIT1)
  347. #define SCU_RCHCR_RCH_EN BIT0
  348. /**************** Bit definition for SCU RCHCR register **********************/
  349. #define SCU_XTHCR_XTHRDY BIT4
  350. #define SCU_XTHCR_XTH_RDYTIME (BIT3|BIT2)
  351. #define SCU_XTHCR_XTH_BYP BIT1
  352. #define SCU_XTHCR_XTH_EN BIT0
  353. #define SCU_XTHCR_READYTIME_1024 0
  354. #define SCU_XTHCR_READYTIME_4096 BIT2
  355. #define SCU_XTHCR_READYTIME_16384 BIT3
  356. #define SCU_XTHCR_READYTIME_32768 (BIT3|BIT2)
  357. /**************** Bit definition for SCU PLLCR register **********************/
  358. #define SCU_PLLCR_PLL_LOCK_SEL BIT31
  359. #define SCU_PLLCR_PLL_FREE_RUN BIT30
  360. #define SCU_PLLCR_PLL_LOCK BIT29
  361. #define SCU_PLLCR_PLL_RUN_DLY (BIT28|BIT27|BIT26|BIT25|BIT24|BIT23)
  362. #define SCU_PLLCR_PLL_UPDATE_EN BIT22
  363. #define SCU_PLLCR_PLL_SLEEP BIT21
  364. #define SCU_PLLCR_PLL_OD (BIT19|BIT18)
  365. #define SCU_PLLCR_PLL_N (BIT15|BIT14)
  366. #define SCU_PLLCR_PLL_M (BIT6|BIT5|BIT4|BIT3)
  367. #define SCU_PLLCR_PLL_SRC_SEL (BIT2|BIT1)
  368. #define SCU_PLLCR_PLL_EN (BIT0)
  369. /**************** Bit definition for SCU LDOCR register **********************/
  370. #define SCU_LDOCR_LPLDO12_TRIM (BIT28|BIT27|BIT26)
  371. #define SCU_LDOCR_LPSTP_SFT BIT25
  372. #define SCU_LDOCR_LPLDO12_EN_SFT BIT24
  373. #define SCU_LDOCR_MLDO12_LOWP_SFT BIT22
  374. #define SCU_LDOCR_MLDO12_LV_SFT (BIT21|BIT20)
  375. #define SCU_LDOCR_LDO18A_EN BIT19
  376. #define SCU_LDOCR_ANATEST_SEL (BIT18|BIT17|BIT16)
  377. #define SCU_LDOCR_LDO18A_TRIM (BIT15|BIT14|BIT13)
  378. #define SCU_LDOCR_LDO18_TRIM (BIT12|BIT11|BIT10)
  379. #define SCU_LDOCR_LDO18_EN BIT9
  380. #define SCU_LDOCR_LDOCTL_SEL BIT8
  381. #define SCU_LDOCR_LDO12_TRIM (BIT7|BIT6|BIT5|BIT4)
  382. #define SCU_LDOCR_VREF_TRIM (BIT2|BIT1|BIT0)
  383. /**************** Bit definition for SCU WMR register ***********************/
  384. #define SCU_WMR_RTC_READY BIT6
  385. #define SCU_WMR_REMAP_FLAG BIT4
  386. #define SCU_WMR_BOOTPIN BIT3
  387. /**************** Bit definition for SCU CLKOCR register ********************/
  388. #define SCU_CLKOCR_BUZZER2_EN BIT31
  389. #define SCU_CLKOCR_BUZZER2_POL BIT30
  390. #define SCU_CLKOCR_BUZZER2_DIV (BIT29|BIT28|BIT27|BIT26|BIT25|BIT24)
  391. #define SCU_CLKOCR_BUZZER_EN BIT23
  392. #define SCU_CLKOCR_BUZZER_POL BIT22
  393. #define SCU_CLKOCR_BUZZER_DIV (0x3FFFE0)
  394. #define SCU_CLKOCR_CLKOUT_SEL BIT4
  395. #define SCU_CLKOCR_CLKTEST_SEL (BIT3|BIT2|BIT1|BIT0)
  396. /**************** Bit definition for SCU SYSCFG1 register ********************/
  397. #define SCU_SYSCFG1_TIM15_CH2_SEL (BIT25|BIT24)
  398. #define SCU_SYSCFG1_TIM15_CH1_SEL (BIT23|BIT22)
  399. #define SCU_SYSCFG1_TIM14_CH1_SEL BIT20
  400. #define SCU_SYSCFG1_IR_MODE (BIT18|BIT17)
  401. #define SCU_SYSCFG1_IR_POL BIT16
  402. #define SCU_SYSCFG1_SRAM_PEF BIT8
  403. #define SCU_SYSCFG1_LVD_LOCK BIT2
  404. #define SCU_SYSCFG1_SRAM_PARITY_LOCK BIT1
  405. #define SCU_SYSCFG1_LOCKUP_LOCK BIT0
  406. /**************** Bit definition for SCU LVDCFG register ********************/
  407. #define SCU_LVDCFG_LVD_VALUE BIT15
  408. #define SCU_LVDCFG_LVD_FILTER BIT14
  409. #define SCU_LVDCFG_FLT_TIME (BIT11|BIT10|BIT9)
  410. #define SCU_LVDCFG_LVD_FLTEN BIT8
  411. #define SCU_LVDCFG_LVD_TRIM (BIT4|BIT3|BIT2|BIT1)
  412. #define SCU_LVDCFG_LVDEN BIT0
  413. /**************** Bit definition for SCU STOPCFG register ********************/
  414. #define SCU_STOPCFG_LPLDO12_LV (BIT15|BIT14|BIT13)
  415. #define SCU_STOPCFG_TKPCLK_SEL BIT12
  416. #define SCU_STOPCFG_PDDS BIT11
  417. #define SCU_STOPCFG_TK_LPLDOLV BIT10
  418. #define SCU_STOPCFG_LPSTOP BIT9
  419. #define SCU_STOPCFG_RCH_DIV_EN BIT8
  420. #define SCU_STOPCFG_MLDO12_LOWP BIT6
  421. #define SCU_STOPCFG_MLDO12_LV (BIT5|BIT4)
  422. #define SCU_STOPCFG_RC64MPDEN BIT3
  423. #define SCU_STOPCFG_RTC_WE BIT0
  424. /************** Bit definition for SCU VECTOROFFSET register *****************/
  425. #define SCU_VECTOROFFSET_VOFFSETEN BIT0
  426. /**************** Bit definition for SCU PASEL1 register *********************/
  427. #define SCU_PASEL1_PA7_SEL (BIT31|BIT30|BIT29|BIT28)
  428. #define SCU_PASEL1_PA6_SEL (BIT27|BIT26|BIT25|BIT24)
  429. #define SCU_PASEL1_PA5_SEL (BIT23|BIT22|BIT21|BIT20)
  430. #define SCU_PASEL1_PA4_SEL (BIT19|BIT18|BIT17|BIT16)
  431. #define SCU_PASEL1_PA3_SEL (BIT15|BIT14|BIT13|BIT12)
  432. #define SCU_PASEL1_PA2_SEL (BIT11|BIT10|BIT9|BIT8)
  433. #define SCU_PASEL1_PA1_SEL (BIT7|BIT6|BIT5|BIT4)
  434. #define SCU_PASEL1_PA0_SEL (BIT3|BIT2|BIT1|BIT0)
  435. /**************** Bit definition for SCU PASEL2 register *********************/
  436. #define SCU_PASEL2_PA15_SEL (BIT31|BIT30|BIT29|BIT28)
  437. #define SCU_PASEL2_PA14_SEL (BIT27|BIT26|BIT25|BIT24)
  438. #define SCU_PASEL2_PA13_SEL (BIT23|BIT22|BIT21|BIT20)
  439. #define SCU_PASEL2_PA12_SEL (BIT19|BIT18|BIT17|BIT16)
  440. #define SCU_PASEL2_PA11_SEL (BIT15|BIT14|BIT13|BIT12)
  441. #define SCU_PASEL2_PA10_SEL (BIT11|BIT10|BIT9|BIT8)
  442. #define SCU_PASEL2_PA9_SEL (BIT7|BIT6|BIT5|BIT4)
  443. #define SCU_PASEL2_PA8_SEL (BIT3|BIT2|BIT1|BIT0)
  444. /**************** Bit definition for SCU PBSEL1 register *********************/
  445. #define SCU_PBSEL1_PB7_SEL (BIT31|BIT30|BIT29|BIT28)
  446. #define SCU_PBSEL1_PB6_SEL (BIT27|BIT26|BIT25|BIT24)
  447. #define SCU_PBSEL1_PB5_SEL (BIT23|BIT22|BIT21|BIT20)
  448. #define SCU_PBSEL1_PB4_SEL (BIT19|BIT18|BIT17|BIT16)
  449. #define SCU_PBSEL1_PB3_SEL (BIT15|BIT14|BIT13|BIT12)
  450. #define SCU_PBSEL1_PB2_SEL (BIT11|BIT10|BIT9|BIT8)
  451. #define SCU_PBSEL1_PB1_SEL (BIT7|BIT6|BIT5|BIT4)
  452. #define SCU_PBSEL1_PB0_SEL (BIT3|BIT2|BIT1|BIT0)
  453. /**************** Bit definition for SCU PBSEL2 register *********************/
  454. #define SCU_PBSEL2_PB15_SEL (BIT31|BIT30|BIT29|BIT28)
  455. #define SCU_PBSEL2_PB14_SEL (BIT27|BIT26|BIT25|BIT24)
  456. #define SCU_PBSEL2_PB13_SEL (BIT23|BIT22|BIT21|BIT20)
  457. #define SCU_PBSEL2_PB12_SEL (BIT19|BIT18|BIT17|BIT16)
  458. #define SCU_PBSEL2_PB11_SEL (BIT15|BIT14|BIT13|BIT12)
  459. #define SCU_PBSEL2_PB10_SEL (BIT11|BIT10|BIT9|BIT8)
  460. #define SCU_PBSEL2_PB9_SEL (BIT7|BIT6|BIT5|BIT4)
  461. #define SCU_PBSEL2_PB8_SEL (BIT3|BIT2|BIT1|BIT0)
  462. /**************** Bit definition for SCU PASTR register **********************/
  463. #define SCU_PASTR_PA15_STH (BIT31|BIT30)
  464. #define SCU_PASTR_PA14_STH (BIT29|BIT28)
  465. #define SCU_PASTR_PA13_STH (BIT27|BIT26)
  466. #define SCU_PASTR_PA12_STH (BIT25|BIT24)
  467. #define SCU_PASTR_PA11_STH (BIT23|BIT22)
  468. #define SCU_PASTR_PA10_STH (BIT21|BIT20)
  469. #define SCU_PASTR_PA9_STH (BIT19|BIT18)
  470. #define SCU_PASTR_PA8_STH (BIT17|BIT16)
  471. #define SCU_PASTR_PA7_STH (BIT15|BIT14)
  472. #define SCU_PASTR_PA6_STH (BIT13|BIT12)
  473. #define SCU_PASTR_PA5_STH (BIT11|BIT10)
  474. #define SCU_PASTR_PA4_STH (BIT9|BIT8)
  475. #define SCU_PASTR_PA3_STH (BIT7|BIT6)
  476. #define SCU_PASTR_PA2_STH (BIT5|BIT4)
  477. #define SCU_PASTR_PA1_STH (BIT3|BIT2)
  478. #define SCU_PASTR_PA0_STH (BIT1|BIT0)
  479. /**************** Bit definition for SCU PBSTR register **********************/
  480. #define SCU_PBSTR_PB15_STH (BIT31|BIT30)
  481. #define SCU_PBSTR_PB14_STH (BIT29|BIT28)
  482. #define SCU_PBSTR_PB13_STH (BIT27|BIT26)
  483. #define SCU_PBSTR_PB12_STH (BIT25|BIT24)
  484. #define SCU_PBSTR_PB11_STH (BIT23|BIT22)
  485. #define SCU_PBSTR_PB10_STH (BIT21|BIT20)
  486. #define SCU_PBSTR_PB9_STH (BIT19|BIT18)
  487. #define SCU_PBSTR_PB8_STH (BIT17|BIT16)
  488. #define SCU_PBSTR_PB7_STH (BIT15|BIT14)
  489. #define SCU_PBSTR_PB6_STH (BIT13|BIT12)
  490. #define SCU_PBSTR_PB5_STH (BIT11|BIT10)
  491. #define SCU_PBSTR_PB4_STH (BIT9|BIT8)
  492. #define SCU_PBSTR_PB3_STH (BIT7|BIT6)
  493. #define SCU_PBSTR_PB2_STH (BIT5|BIT4)
  494. #define SCU_PBSTR_PB1_STH (BIT3|BIT2)
  495. #define SCU_PBSTR_PB0_STH (BIT1|BIT0)
  496. /**************** Bit definition for SCU PCSEL1 register *********************/
  497. #define SCU_PCSEL1_PC7_SEL (BIT31|BIT30|BIT29|BIT28)
  498. #define SCU_PCSEL1_PC6_SEL (BIT27|BIT26|BIT25|BIT24)
  499. #define SCU_PCSEL1_PC5_SEL (BIT23|BIT22|BIT21|BIT20)
  500. #define SCU_PCSEL1_PC4_SEL (BIT19|BIT18|BIT17|BIT16)
  501. #define SCU_PCSEL1_PC3_SEL (BIT15|BIT14|BIT13|BIT12)
  502. #define SCU_PCSEL1_PC2_SEL (BIT11|BIT10|BIT9|BIT8)
  503. #define SCU_PCSEL1_PC1_SEL (BIT7|BIT6|BIT5|BIT4)
  504. #define SCU_PCSEL1_PC0_SEL (BIT3|BIT2|BIT1|BIT0)
  505. /**************** Bit definition for SCU PCSEL2 register *********************/
  506. #define SCU_PCSEL2_PC15_SEL (BIT31|BIT30|BIT29|BIT28)
  507. #define SCU_PCSEL2_PC14_SEL (BIT27|BIT26|BIT25|BIT24)
  508. #define SCU_PCSEL2_PC13_SEL (BIT23|BIT22|BIT21|BIT20)
  509. #define SCU_PCSEL2_PC12_SEL (BIT19|BIT18|BIT17|BIT16)
  510. #define SCU_PCSEL2_PC11_SEL (BIT15|BIT14|BIT13|BIT12)
  511. #define SCU_PCSEL2_PC10_SEL (BIT11|BIT10|BIT9|BIT8)
  512. #define SCU_PCSEL2_PC9_SEL (BIT7|BIT6|BIT5|BIT4)
  513. #define SCU_PCSEL2_PC8_SEL (BIT3|BIT2|BIT1|BIT0)
  514. /**************** Bit definition for SCU PDSEL1 register *********************/
  515. #define SCU_PDSEL1_PD7_SEL (BIT31|BIT30|BIT29|BIT28)
  516. #define SCU_PDSEL1_PD6_SEL (BIT27|BIT26|BIT25|BIT24)
  517. #define SCU_PDSEL1_PD5_SEL (BIT23|BIT22|BIT21|BIT20)
  518. #define SCU_PDSEL1_PD4_SEL (BIT19|BIT18|BIT17|BIT16)
  519. #define SCU_PDSEL1_PD3_SEL (BIT15|BIT14|BIT13|BIT12)
  520. #define SCU_PDSEL1_PD2_SEL (BIT11|BIT10|BIT9|BIT8)
  521. #define SCU_PDSEL1_PD1_SEL (BIT7|BIT6|BIT5|BIT4)
  522. #define SCU_PDSEL1_PD0_SEL (BIT3|BIT2|BIT1|BIT0)
  523. /**************** Bit definition for SCU PCSTR register **********************/
  524. #define SCU_PCSTR_PC12_STH (BIT25|BIT24)
  525. #define SCU_PCSTR_PC11_STH (BIT23|BIT22)
  526. #define SCU_PCSTR_PC10_STH (BIT21|BIT20)
  527. #define SCU_PCSTR_PC9_STH (BIT19|BIT18)
  528. #define SCU_PCSTR_PC8_STH (BIT17|BIT16)
  529. #define SCU_PCSTR_PC7_STH (BIT15|BIT14)
  530. #define SCU_PCSTR_PC6_STH (BIT13|BIT12)
  531. #define SCU_PCSTR_PC5_STH (BIT11|BIT10)
  532. #define SCU_PCSTR_PC4_STH (BIT9|BIT8)
  533. #define SCU_PCSTR_PC3_STH (BIT7|BIT6)
  534. #define SCU_PCSTR_PC2_STH (BIT5|BIT4)
  535. #define SCU_PCSTR_PC1_STH (BIT3|BIT2)
  536. #define SCU_PCSTR_PC0_STH (BIT1|BIT0)
  537. /**************** Bit definition for SCU PDSTR register **********************/
  538. #define SCU_PDSTR_PD7_STH (BIT15|BIT14)
  539. #define SCU_PDSTR_PD6_STH (BIT13|BIT12)
  540. #define SCU_PDSTR_PD5_STH (BIT11|BIT10)
  541. #define SCU_PDSTR_PD4_STH (BIT9|BIT8)
  542. #define SCU_PDSTR_PD3_STH (BIT7|BIT6)
  543. #define SCU_PDSTR_PD2_STH (BIT5|BIT4)
  544. #define SCU_PDSTR_PD1_STH (BIT3|BIT2)
  545. #define SCU_PDSTR_PD0_STH (BIT1|BIT0)
  546. /******************************************************************************/
  547. /* (PMU) */
  548. /******************************************************************************/
  549. /***************** Bit definition for RTC_PMU CR Register *******************/
  550. #define RPMU_CR_WU6FILEN BIT29
  551. #define RPMU_CR_WU5FILEN BIT28
  552. #define RPMU_CR_WU4FILEN BIT27
  553. #define RPMU_CR_WU3FILEN BIT26
  554. #define RPMU_CR_WU2FILEN BIT25
  555. #define RPMU_CR_WU1FILEN BIT24
  556. #define RPMU_CR_EWUP6 BIT21
  557. #define RPMU_CR_EWUP5 BIT20
  558. #define RPMU_CR_EWUP4 BIT19
  559. #define RPMU_CR_EWUP3 BIT18
  560. #define RPMU_CR_EWUP2 BIT17
  561. #define RPMU_CR_EWUP1 BIT16
  562. #define RPMU_CR_BORRST_EN BIT12
  563. #define RPMU_CR_WK_TIME (BIT9|BIT10|BIT11)
  564. #define RPMU_CR_STB_EN BIT8
  565. #define RPMU_CR_BDRST BIT6
  566. #define RPMU_CR_RTCEN BIT5
  567. #define RPMU_CR_RTCSEL (BIT2|BIT3)
  568. #define RPMU_CR_CWUF BIT1
  569. #define RPMU_CR_CSBF BIT0
  570. /***************** Bit definition for RTC_PMU ANACR Register *****************/
  571. #define RPMU_ANACR_BOR_CFG (BIT24|BIT25)
  572. #define RPMU_ANACR_BOR_EN BIT23
  573. #define RPMU_ANACR_LPBGR_TRIM (BIT20|BIT21|BIT22)
  574. #define RPMU_ANACR_RC32K_TRIM (BIT10|BIT11|BIT12|BIT13|BIT14|BIT15)
  575. #define RPMU_ANACR_RC32K_RDY BIT9
  576. #define RPMU_ANACR_RC32K_EN BIT8
  577. #define RPMU_ANACR_XTLDRV (BIT3|BIT4|BIT5)
  578. #define RPMU_ANACR_XTLBYP BIT2
  579. #define RPMU_ANACR_XTLRDY BIT1
  580. #define RPMU_ANACR_XTLEN BIT0
  581. /* System_Init */
  582. void System_Init(void);
  583. /* System_Core_Config */
  584. void System_Core_Config(void);
  585. /* System_Clock_Init */
  586. bool System_Clock_Init(uint32_t fu32_Clock);
  587. /* System_SysTick_Init */
  588. void System_SysTick_Init(void);
  589. /* System_Get_SystemClock */
  590. uint32_t System_Get_SystemClock(void);
  591. /* System_Get_APBClock */
  592. uint32_t System_Get_APBClock(void);
  593. /* System_Module_Reset */
  594. void System_Module_Reset(enum_RST_ID_t fe_ID_Index);
  595. /* System_Module_Enable */
  596. void System_Module_Enable(enum_Enable_ID_t fe_ID_Index);
  597. /* System_Module_Disable */
  598. void System_Module_Disable(enum_Enable_ID_t fe_ID_Index);
  599. /* System_Delay */
  600. void System_Delay(volatile uint32_t fu32_Delay);
  601. /* System_Delay_MS */
  602. void System_Delay_MS(volatile uint32_t fu32_Delay);
  603. /* System_Enable_RC32K */
  604. void System_Enable_RC32K(void);
  605. /* System_Disable_RC32K */
  606. void System_Disable_RC32K(void);
  607. /* System_Enable_XTAL */
  608. void System_Enable_XTAL(void);
  609. /* System_Disable_XTAL */
  610. void System_Disable_XTAL(void);
  611. /* System_Clear_Stop_Wakeup */
  612. void System_Clear_Stop_Wakeup(void);
  613. /* System_Enter_Standby_Mode */
  614. void System_Enter_Standby_Mode(void);
  615. /* System_Enter_Stop_Mode */
  616. void System_Enter_Stop_Mode(uint8_t STOPEntry);
  617. /* System_Enter_Sleep_Mode */
  618. void System_Enter_Sleep_Mode(uint8_t SleepEntry);
  619. /* System_Enable_Disable_Reset */
  620. void System_Enable_Disable_Reset(RESET_ENABLE_SOURCE source, FUNC_DISABLE_ENABLE enable_disable);
  621. /* System_Reset_MCU */
  622. void System_Reset_MCU(RESET_SOURCE source);
  623. /* System_Enable_Disable_RTC_Domain_Access */
  624. void System_Enable_Disable_RTC_Domain_Access(FUNC_DISABLE_ENABLE enable_disable);
  625. /* System_Return_Last_Reset_Reason */
  626. RESET_REASON System_Return_Last_Reset_Reason(void) ;
  627. /* System_Set_Buzzer_Divider */
  628. void System_Set_Buzzer_Divider(uint32_t div, FUNC_DISABLE_ENABLE enable);
  629. #endif