System_ACM32F4.h 27 KB

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