ACM32F0x0.h 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762
  1. /*
  2. ******************************************************************************
  3. * @file ACM32F0x0.h
  4. * @brief CMSIS ACM32F0x0 Device Peripheral Access Layer Header File.
  5. *
  6. * This file contains:
  7. * - Data structures and the address mapping for all peripherals
  8. * - Peripheral's registers declarations and bits definition
  9. * - Macros to access peripheral’s registers hardware
  10. *
  11. ******************************************************************************
  12. */
  13. #ifndef __ACM32F0x0_H__
  14. #define __ACM32F0x0_H__
  15. #ifdef __cplusplus
  16. extern "C"
  17. {
  18. #endif
  19. ///*------------------- Interrupt Number Definition ----------------------*/
  20. typedef enum IRQn
  21. {
  22. /* ---------------------- SC000 Processor Exceptions Numbers --------------------- */
  23. NonMaskableInt_IRQn = -14, /* 2 Non Maskable Interrupt */
  24. HardFault_IRQn = -13, /* 3 HardFault Interrupt */
  25. MemManage_IRQn = -12, /* 4 MemManage Interrupt */
  26. SVCall_IRQn = -5, /* 11 SV Call Interrupt */
  27. PendSV_IRQn = -2, /* 14 Pend SV Interrupt */
  28. SysTick_IRQn = -1, /* 15 System Tick Interrupt */
  29. /* ---------------------- ARMCM0 Specific Interrupt Numbers --------------------- */
  30. WDT_IRQn = 0, // 0: WDT_IRQHandler
  31. RTC_IRQn = 1, // 1: RTC_IRQHandler
  32. EFC_IRQn = 2, // 2: EFC_IRQHandler
  33. GPIOAB_IRQn = 3, // 3: GPIOAB_IRQHandler
  34. GPIOCD_IRQn = 4, // 4: GPIOCD_IRQHandler
  35. EXTI_IRQn = 5, // 5: EXTI_IRQHandler
  36. SRAM_PARITY_IRQn = 6, // 6: SRAM_PARITY_IRQHandler
  37. CLKRDY_IRQn = 7, // 7: CLKRDY_IRQHandler
  38. LCD_IRQn = 8, // 8: LCD_IRQHandler
  39. DMA_IRQn = 9, // 9: DMA_IRQHandler
  40. UART3_IRQn = 10, // 10: UART3_IRQHandler
  41. TKEY_IRQn = 11, // 11: TKEY_IRQHandler
  42. ADC_IRQn = 12, // 12: ADC_IRQHandler
  43. TIM1_BRK_UP_TRG_COM_IRQn = 13, // 13: TIM1_BRK_UP_TRG_COM_IRQHandler
  44. TIM1_CC_IRQn = 14, // 14: TIM1_CC_IRQHandler
  45. TIM3_IRQn = 16, // 16: TIM3_IRQHandler
  46. TIM6_IRQn = 17, // 17: TIM6_IRQHandler
  47. TIM14_IRQn = 19, // 19: TIM14_IRQHandler
  48. TIM15_IRQn = 20, // 20: TIM15_IRQHandler
  49. TIM16_IRQn = 21, // 21: TIM16_IRQHandler
  50. TIM17_IRQn = 22, // 22: TIM17_IRQHandler
  51. I2C1_IRQn = 23, // 23: I2C1_IRQHandler
  52. I2C2_IRQn = 24, // 24: I2C2_IRQHandler
  53. SPI1_IRQn = 25, // 25: SPI1_IRQHandler
  54. SPI2_IRQn = 26, // 26: SPI2_IRQHandler
  55. UART1_IRQn = 27, // 27: UART1_IRQHandler
  56. UART2_IRQn = 28, // 28: UART2_IRQHandler
  57. LPUART_IRQn = 29, // 29: LPUART_IRQHandler
  58. CAN1_IRQn = 30, // 30: CAN1_IRQHandler
  59. AES_IRQn = 31, // 31: AES_IRQhandler
  60. } IRQn_Type;
  61. /* ================================================================================ */
  62. /* ================ Processor and Core Peripheral Section ================ */
  63. /* ================================================================================ */
  64. /* Configuration of the SC000 Processor and Core Peripherals */
  65. #define __CM0_REV 0x0000U /* Core revision r0p0 */
  66. #define __NVIC_PRIO_BITS 2 /* Number of Bits used for Priority Levels */
  67. #define __Vendor_SysTickConfig 0 /* Set to 1 if different SysTick Config is used */
  68. #include "core_cm0.h" /* Processor and core peripherals */
  69. #include "stdio.h"
  70. #include "string.h"
  71. #include "stdint.h"
  72. #include "stdbool.h"
  73. ///*------------------- Bit Opertions ----------------------*/
  74. #define BIT0 (1U << 0)
  75. #define BIT1 (1U << 1)
  76. #define BIT2 (1U << 2)
  77. #define BIT3 (1U << 3)
  78. #define BIT4 (1U << 4)
  79. #define BIT5 (1U << 5)
  80. #define BIT6 (1U << 6)
  81. #define BIT7 (1U << 7)
  82. #define BIT8 (1U << 8)
  83. #define BIT9 (1U << 9)
  84. #define BIT10 (1U << 10)
  85. #define BIT11 (1U << 11)
  86. #define BIT12 (1U << 12)
  87. #define BIT13 (1U << 13)
  88. #define BIT14 (1U << 14)
  89. #define BIT15 (1U << 15)
  90. #define BIT16 (1U << 16)
  91. #define BIT17 (1U << 17)
  92. #define BIT18 (1U << 18)
  93. #define BIT19 (1U << 19)
  94. #define BIT20 (1U << 20)
  95. #define BIT21 (1U << 21)
  96. #define BIT22 (1U << 22)
  97. #define BIT23 (1U << 23)
  98. #define BIT24 (1U << 24)
  99. #define BIT25 (1U << 25)
  100. #define BIT26 (1U << 26)
  101. #define BIT27 (1U << 27)
  102. #define BIT28 (1U << 28)
  103. #define BIT29 (1U << 29)
  104. #define BIT30 (1U << 30)
  105. #define BIT31 (1U << 31)
  106. /** @Addtogroup Peripheral_Registers_Structures
  107. * @{
  108. */
  109. ///*------------------- FLASH Registers ----------------------*/
  110. typedef struct
  111. {
  112. __IO uint32_t CTRL; // 0x00
  113. __IO uint32_t SEC; // 0x04
  114. __IO uint32_t ADCT; // 0x08
  115. __IO uint32_t TERASE; // 0x0C
  116. __IO uint32_t TPROG; // 0x10
  117. __IO uint32_t STATUS; // 0x14
  118. __IO uint32_t INTSTATUS; // 0x18
  119. __IO uint32_t INTEN; // 0x1C
  120. __IO uint32_t RSV0[6]; // 0x20-0x34
  121. __IO uint32_t NVS; // 0x38
  122. }EFC_TypeDef;
  123. ///*------------------- Timer Registers ----------------------*/
  124. typedef struct
  125. {
  126. __IO uint32_t CR1; // 0x00
  127. __IO uint32_t CR2; // 0x04
  128. __IO uint32_t SMCR; // 0x08
  129. __IO uint32_t DIER; // 0x0C
  130. __IO uint32_t SR; // 0x10
  131. __IO uint32_t EGR; // 0x14
  132. __IO uint32_t CCMR1; // 0x18
  133. __IO uint32_t CCMR2; // 0x1C
  134. __IO uint32_t CCER; // 0x20
  135. __IO uint32_t CNT; // 0x24
  136. __IO uint32_t PSC; // 0x28
  137. __IO uint32_t ARR; // 0x2C
  138. __IO uint32_t RCR; // 0x30
  139. __IO uint32_t CCR1; // 0x34
  140. __IO uint32_t CCR2; // 0x38
  141. __IO uint32_t CCR3; // 0x3C
  142. __IO uint32_t CCR4; // 0x40
  143. __IO uint32_t BDTR; // 0x44
  144. __IO uint32_t DCR; // 0x48
  145. __IO uint32_t DMAR; // 0x4C
  146. __IO uint32_t RSV0[4]; // 0x50-0x5C
  147. __IO uint32_t AF1; // 0x60
  148. __IO uint32_t RSV1; // 0x64
  149. __IO uint32_t TISEL; // 0x68
  150. __IO uint32_t DBER; // 0x6C
  151. }TIM_TypeDef;
  152. ///*------------------- RTC、PMU Registers ----------------------*/
  153. typedef struct
  154. {
  155. __IO uint32_t WP; // 0x00
  156. __IO uint32_t IE; // 0x04
  157. __IO uint32_t SR; // 0x08
  158. __IO uint32_t SEC; // 0x0C
  159. __IO uint32_t MIN; // 0x10
  160. __IO uint32_t HOUR; // 0x14
  161. __IO uint32_t DATE; // 0x18
  162. __IO uint32_t WEEK; // 0x1C
  163. __IO uint32_t MONTH; // 0x20
  164. __IO uint32_t YEAR; // 0x24
  165. __IO uint32_t ALM; // 0x28
  166. __IO uint32_t CR; // 0x2C
  167. __IO uint32_t ADJUST; // 0x30
  168. __IO uint32_t RSV0[4]; // 0x34 ~ 0x40
  169. __IO uint32_t CLKSTAMP1_TIME; // 0x44
  170. __IO uint32_t CALSTAMP1_DATE; // 0x48
  171. __IO uint32_t CLKSTAMP2_TIME; // 0x4C
  172. __IO uint32_t CALSTAMP2_DATE; // 0x50
  173. __IO uint32_t RSV1[7]; // 0x54-0x6C
  174. __IO uint32_t BACKUP[5]; // 0x70 ~ 0x80
  175. }RTC_TypeDef;
  176. typedef struct
  177. {
  178. __IO uint32_t CR1; // 0x00
  179. __IO uint32_t SR; // 0x04
  180. __IO uint32_t IOSEL; // 0x08
  181. __IO uint32_t IOCR; // 0x0C
  182. __IO uint32_t ANACR; // 0x10
  183. __IO uint32_t CR2; // 0x14
  184. }PMU_TypeDef;
  185. ///*------------------- WDT Registers ----------------------*/
  186. typedef struct
  187. {
  188. __IO uint32_t LOAD;
  189. __IO uint32_t COUNT;
  190. __IO uint32_t CTRL;
  191. __IO uint32_t FEED;
  192. __IO uint32_t INTCLRTIME;
  193. __IO uint32_t RIS;
  194. }WDT_TypeDef;
  195. ///*------------------- IWDT Registers ----------------------*/
  196. typedef struct
  197. {
  198. __IO uint32_t CMDR; // 0x00
  199. __IO uint32_t PR; // 0x04
  200. __IO uint32_t RLR; // 0x08
  201. __IO uint32_t SR; // 0x0C
  202. __IO uint32_t WINR; // 0x10
  203. __IO uint32_t WUTR; // 0x14
  204. }IWDT_TypeDef;
  205. ///*------------------- LCD Registers ----------------------*/
  206. typedef struct
  207. {
  208. __IO uint32_t CR0; // 0x00
  209. __IO uint32_t CR1; // 0x04
  210. __IO uint32_t INTCLR; // 0x08
  211. __IO uint32_t LCD_POEN0; // 0x0C
  212. __IO uint32_t LCD_POEN1; // 0x10
  213. __IO uint32_t RSV[11];
  214. __IO uint32_t LCD_RAM[16]; /*!< LCD display memory, Address offset: 0x40-0x7c */
  215. }LCD_TypeDef;
  216. ///*------------------- UART Registers ----------------------*/
  217. typedef struct
  218. {
  219. __IO uint32_t DR; // 0x00
  220. __IO uint32_t RSR; // 0x04
  221. __IO uint32_t RSV0[4]; // 0x08-0x14
  222. __IO uint32_t FR; // 0x18
  223. __IO uint32_t RSV1; // 0x1C
  224. __IO uint32_t ILPR; // 0x20
  225. __IO uint32_t IBRD; // 0x24
  226. __IO uint32_t FBRD; // 0x28
  227. __IO uint32_t LCRH; // 0x2C
  228. __IO uint32_t CR; // 0x30
  229. __IO uint32_t IFLS; // 0x34
  230. __IO uint32_t IE; // 0x38
  231. __IO uint32_t RIS; // 0x3C
  232. __IO uint32_t MIS; // 0x40
  233. __IO uint32_t ICR; // 0x44
  234. __IO uint32_t DMACR; // 0x48
  235. __IO uint32_t RSV2[2]; // 0x4C-0x50
  236. __IO uint32_t CR2; // 0x54
  237. __IO uint32_t BCNT; // 0x58
  238. }UART_TypeDef;
  239. ///*------------------- CAN Registers ----------------------*/
  240. typedef struct
  241. {
  242. __IO uint32_t ACR[4];
  243. __IO uint32_t AMR[4];
  244. __IO uint32_t RSV[5];
  245. }Filter_typedef;
  246. typedef union
  247. {
  248. __IO uint32_t DATABUF[13];
  249. Filter_typedef FILTER;
  250. }DF_typedef;
  251. typedef struct
  252. {
  253. __IO uint32_t MOD;
  254. __IO uint32_t CMR;
  255. __IO uint32_t SR;
  256. __IO uint32_t IR;
  257. __IO uint32_t IER;
  258. __IO uint32_t RSV0;
  259. __IO uint32_t BTR0;
  260. __IO uint32_t BTR1;
  261. __IO uint32_t OCR;
  262. __IO uint32_t RSV1;
  263. __IO uint32_t RSV2;
  264. __IO uint32_t ALC;
  265. __IO uint32_t ECC;
  266. __IO uint32_t EWLR;
  267. __IO uint32_t RXERR;
  268. __IO uint32_t TXERR;
  269. __IO DF_typedef DF;
  270. __IO uint32_t RMC;
  271. __IO uint32_t RBSA;
  272. __IO uint32_t CDR;
  273. __IO uint32_t RXFIFO[64];
  274. __IO uint32_t TXFIFO[13];
  275. }CAN_TypeDef;
  276. ///*------------------- I2C Registers ----------------------*/
  277. typedef struct
  278. {
  279. __IO uint32_t SLAVE_ADDR1; // 0x00
  280. __IO uint32_t CLK_DIV; // 0x04
  281. __IO uint32_t CR; // 0x08
  282. __IO uint32_t SR; // 0x0C
  283. __IO uint32_t DR; // 0x10
  284. __IO uint32_t SLAVE_ADDR23; // 0x14
  285. __IO uint32_t RSV0[3]; // 0x18-0x20
  286. __IO uint32_t TIMEOUT; // 0x24
  287. }I2C_TypeDef;
  288. ///*------------------- LPUART Registers ----------------------*/
  289. typedef struct
  290. {
  291. __IO uint32_t RXDR; // 0x00
  292. __IO uint32_t TXDR; // 0x04
  293. __IO uint32_t LCR; // 0x08
  294. __IO uint32_t CR; // 0x0C
  295. __IO uint32_t IBAUD; // 0x10
  296. __IO uint32_t FBAUD; // 0x14
  297. __IO uint32_t IE; // 0x18
  298. __IO uint32_t SR; // 0x1C
  299. __IO uint32_t ADDR; // 0x20
  300. }LPUART_TypeDef;
  301. ///*------------------- COMP Registers ----------------------*/
  302. typedef struct
  303. {
  304. __IO uint32_t CR1; // 0x00
  305. __IO uint32_t CR2; // 0x04
  306. __IO uint32_t SR; // 0x08
  307. }COMP_TypeDef;
  308. ///*------------------- OPA Registers ----------------------*/
  309. typedef struct
  310. {
  311. __IO uint32_t OPA1_CSR; // 0x00
  312. __IO uint32_t OPA2_CSR; // 0x04
  313. __IO uint32_t OPA3_CSR; // 0x08
  314. }OPA_TypeDef;
  315. ///*------------------- EXTI Registers ----------------------*/
  316. typedef struct
  317. {
  318. __IO uint32_t IENR; // 0x00
  319. __IO uint32_t EENR; // 0x04
  320. __IO uint32_t RTENR; // 0x08
  321. __IO uint32_t FTENR; // 0x0C
  322. __IO uint32_t SWIER; // 0x10
  323. __IO uint32_t PDR; // 0x14
  324. __IO uint32_t EXTICR1; // 0x18
  325. __IO uint32_t EXTICR2; // 0x1C
  326. }EXTI_TypeDef;
  327. ///*------------------- SCU Registers ----------------------*/
  328. typedef struct
  329. {
  330. __IO uint32_t RCR; // 0x00
  331. __IO uint32_t RSR; // 0x04
  332. __IO uint32_t RSV0; // 0x08
  333. __IO uint32_t IPRST; // 0x0C
  334. __IO uint32_t CCR1; // 0x10
  335. __IO uint32_t CCR2; // 0x14
  336. __IO uint32_t CIR; // 0x18
  337. __IO uint32_t IPCKENR1; // 0x1C
  338. __IO uint32_t IPCKENR2; // 0x20
  339. __IO uint32_t RCHCR; // 0x24
  340. __IO uint32_t XTHCR; // 0x28
  341. __IO uint32_t PLLCR; // 0x2C
  342. __IO uint32_t LDOCR; // 0x30
  343. __IO uint32_t RSV1; // 0x34
  344. __IO uint32_t WMR; // 0x38
  345. __IO uint32_t CLKOCR; // 0x3C
  346. __IO uint32_t VER; // 0x40
  347. __IO uint32_t SYSCFG1; // 0x44
  348. __IO uint32_t LVDCFG; // 0x48
  349. __IO uint32_t STOPCFG; // 0x4C
  350. __IO uint32_t VECTOROFFSET; // 0x50
  351. __IO uint32_t RSV2; // 0x54
  352. __IO uint32_t MEMCFG; // 0x58
  353. __IO uint32_t RSV3; // 0x5C
  354. __IO uint32_t PASEL1; // 0x60
  355. __IO uint32_t PASEL2; // 0x64
  356. __IO uint32_t PBSEL1; // 0x68
  357. __IO uint32_t PBSEL2; // 0x6C
  358. __IO uint32_t PABPUR; // 0x70
  359. __IO uint32_t PABPDR; // 0x74
  360. __IO uint32_t PASTR; // 0x78
  361. __IO uint32_t PBSTR; // 0x7C
  362. __IO uint32_t PABSMTR; // 0x80
  363. __IO uint32_t PABODR; // 0x84
  364. __IO uint32_t PABADS; // 0x88
  365. __IO uint32_t RSV4; // 0x8C
  366. __IO uint32_t PCSEL1; // 0x90
  367. __IO uint32_t PCSEL2; // 0x94
  368. __IO uint32_t PDSEL1; // 0x98
  369. __IO uint32_t RSV5; // 0x9C
  370. __IO uint32_t PCDPUR; // 0xA0
  371. __IO uint32_t PCDPDR; // 0xA4
  372. __IO uint32_t PCSTR; // 0xA8
  373. __IO uint32_t PDSTR; // 0xAC
  374. __IO uint32_t PCDSMTR; // 0xB0
  375. __IO uint32_t PCDODR; // 0xB4
  376. __IO uint32_t PCDADS; // 0xB8
  377. }SCU_TypeDef;
  378. ///*------------------- CRC Registers ----------------------*/
  379. typedef struct
  380. {
  381. __IO uint32_t DATA; // 0x00
  382. __IO uint32_t CTRL; // 0x04
  383. __IO uint32_t INIT; // 0x08
  384. __IO uint32_t RSV0; // 0x0C
  385. __IO uint32_t OUTXOR; // 0x10
  386. __IO uint32_t POLY; // 0x14
  387. __IO uint32_t FDATA; // 0x18
  388. }CRC_TypeDef;
  389. ///*------------------- ADC Registers ----------------------*/
  390. typedef struct
  391. {
  392. __IO uint32_t SR; // 0x00
  393. __IO uint32_t IE; // 0x04
  394. __IO uint32_t CR1; // 0x08
  395. __IO uint32_t CR2; // 0x0C
  396. __IO uint32_t SMPR1; // 0x10
  397. __IO uint32_t SMPR2; // 0x14
  398. __IO uint32_t HTR; // 0x18
  399. __IO uint32_t LTR; // 0x1C
  400. __IO uint32_t SQR1; // 0x20
  401. __IO uint32_t SQR2; // 0x24
  402. __IO uint32_t SQR3; // 0x28
  403. __IO uint32_t JSQR; // 0x2C
  404. __IO uint32_t JDR; // 0x30
  405. __IO uint32_t DR; // 0x34
  406. __IO uint32_t DIFF; // 0x38
  407. __IO uint32_t SIGN; // 0x3C
  408. __IO uint32_t TSREF; // 0x40
  409. __IO uint32_t SMPR3; // 0x44
  410. }ADC_TypeDef;
  411. ///*-----------------------TKEY------------------------*/
  412. typedef struct
  413. {
  414. __IO uint32_t ISR; // 0x00
  415. __IO uint32_t IER; // 0x04
  416. __IO uint32_t CR; // 0x08
  417. __IO uint32_t SMPR; // 0x0C
  418. __IO uint32_t SOFR; // 0x10
  419. __IO uint32_t CXSELR; // 0x14
  420. __IO uint32_t CRSELR; // 0x18
  421. __IO uint32_t DR; // 0x1C
  422. __IO uint32_t TH0; // 0x20
  423. __IO uint32_t TH1; // 0x24
  424. __IO uint32_t TH2; // 0x28
  425. __IO uint32_t TH3; // 0x2C
  426. __IO uint32_t TH4; // 0x30
  427. __IO uint32_t TH5; // 0x34
  428. __IO uint32_t TH6; // 0x38
  429. __IO uint32_t TH7; // 0x3C
  430. __IO uint32_t TH8; // 0x40
  431. __IO uint32_t TH9; // 0x44
  432. __IO uint32_t TH10; // 0x48
  433. __IO uint32_t TH11; // 0x4C
  434. __IO uint32_t TH12; // 0x50
  435. __IO uint32_t TH13; // 0x54
  436. __IO uint32_t TH14; // 0x58
  437. __IO uint32_t TH15; // 0x5C
  438. __IO uint32_t CH0; // 0x60
  439. __IO uint32_t CH1; // 0x64
  440. __IO uint32_t CH2; // 0x68
  441. __IO uint32_t CH3; // 0x6C
  442. __IO uint32_t CH4; // 0x70
  443. __IO uint32_t CH5; // 0x74
  444. __IO uint32_t CH6; // 0x78
  445. __IO uint32_t CH7; // 0x7C
  446. __IO uint32_t CH8; // 0x80
  447. __IO uint32_t CH9; // 0x84
  448. __IO uint32_t CH10; // 0x88
  449. __IO uint32_t CH11; // 0x8C
  450. __IO uint32_t CH12; // 0x90
  451. __IO uint32_t CH13; // 0x94
  452. __IO uint32_t CH14; // 0x98
  453. __IO uint32_t CH15; // 0x9C
  454. }TKEY_TypeDef;
  455. ///*------------------- GPIO Registers ----------------------*/
  456. typedef struct
  457. {
  458. __IO uint32_t DIR; // 0x00
  459. __IO uint32_t RSV0; // 0x04
  460. __IO uint32_t SET; // 0x08
  461. __IO uint32_t CLR; // 0x0C
  462. __IO uint32_t ODATA; // 0x10
  463. __IO uint32_t IDATA; // 0x14
  464. __IO uint32_t IEN; // 0x18
  465. __IO uint32_t IS; // 0x1C
  466. __IO uint32_t IBE; // 0x20
  467. __IO uint32_t IEV; // 0x24
  468. __IO uint32_t IC; // 0x28
  469. __IO uint32_t RIS; // 0x2C
  470. __IO uint32_t MIS; // 0x30
  471. }GPIO_TypeDef;
  472. ///*------------------- SPI Registers ----------------------*/
  473. typedef struct
  474. {
  475. __IO uint32_t DAT; // 0x00
  476. __IO uint32_t BAUD; // 0x04
  477. __IO uint32_t CTL; // 0x08
  478. __IO uint32_t TX_CTL; // 0x0C
  479. __IO uint32_t RX_CTL; // 0x10
  480. __IO uint32_t IE; // 0x14
  481. __IO uint32_t STATUS; // 0x18
  482. __IO uint32_t TXDELAY; // 0x1C
  483. __IO uint32_t BATCH; // 0x20
  484. __IO uint32_t CS; // 0x24
  485. __IO uint32_t OUT_EN; // 0x28
  486. }SPI_TypeDef;
  487. ///*------------------- DMA Registers ----------------------*/
  488. typedef struct
  489. {
  490. __IO uint32_t INT_STATUS; // 0x00
  491. __IO uint32_t INT_TC_STATUS; // 0x04
  492. __IO uint32_t INT_TC_CLR; // 0x08
  493. __IO uint32_t INT_ERR_STATUS; // 0x0C
  494. __IO uint32_t INT_ERR_CLR; // 0x10
  495. __IO uint32_t RAW_INT_TC_STATUS; // 0x14
  496. __IO uint32_t RAW_INT_ERR_STATUS; // 0x18
  497. __IO uint32_t EN_CH_STATUS; // 0x1C
  498. __IO uint32_t RSV0[4]; // 0x20-0x2C
  499. __IO uint32_t CONFIG; // 0x30
  500. __IO uint32_t SYNC; // 0x34
  501. }DMA_TypeDef;
  502. typedef struct
  503. {
  504. __IO uint32_t SRC_ADDR;
  505. __IO uint32_t DEST_ADDR;
  506. __IO uint32_t LLI;
  507. __IO uint32_t CTRL;
  508. __IO uint32_t CONFIG;
  509. }DMA_Channel_TypeDef;
  510. typedef struct
  511. {
  512. __IO uint32_t REG_AESDATAIN; //0x00
  513. __IO uint32_t REG_AESKEYIN; //0x04
  514. __IO uint32_t REG_AESIVIN; //0x08
  515. __IO uint32_t REG_AESCTRL; //0x0C
  516. __IO uint32_t REG_AESSTATE; //0x10
  517. __IO uint32_t REG_AESDATAOUT; //0x14
  518. }AES_TypeDef;
  519. typedef struct
  520. {
  521. __IO uint32_t CTRL; //0x00
  522. __IO uint32_t LFSR; //0x04
  523. }HRNG_TypeDef;
  524. typedef struct
  525. {
  526. __IO uint32_t DIVIDENED; //0x00
  527. __IO uint32_t DIVISOR; //0x04
  528. __IO uint32_t REMAIN; //0x08
  529. __IO uint32_t QUOTIENT; //0x0c
  530. __IO uint32_t STATUS; //0x10
  531. }DIV_TypeDef;
  532. /**
  533. * @}
  534. */
  535. /** @addtogroup Peripheral_memory_map
  536. * @{
  537. */
  538. #define EFLASH_BASE (0x00000000UL)
  539. #define EFC_BASE (0x00100000UL)
  540. #define SRAM_BASE (0x20000000UL)
  541. #define PERIPH_BASE (0x40000000UL)
  542. #define APB1PERIPH_BASE (PERIPH_BASE)
  543. #define APB2PERIPH_BASE (PERIPH_BASE + 0x10000UL)
  544. #define AHB1PERIPH_BASE (PERIPH_BASE + 0x20000UL)
  545. #define AHB2PERIPH_BASE (PERIPH_BASE + 0x30000UL)
  546. ///*----------------------APB1 peripherals------------------------*/
  547. #define TIM3_BASE (APB1PERIPH_BASE + 0x00000400UL)
  548. #define TIM6_BASE (APB1PERIPH_BASE + 0x00001000UL)
  549. #define TIM14_BASE (APB1PERIPH_BASE + 0x00002000UL)
  550. #define PMU_BASE (APB1PERIPH_BASE + 0x00002400UL)
  551. #define RTC_BASE (APB1PERIPH_BASE + 0x00002800UL)
  552. #define WDT_BASE (APB1PERIPH_BASE + 0x00002C00UL)
  553. #define IWDT_BASE (APB1PERIPH_BASE + 0x00003000UL)
  554. #define UART2_BASE (APB1PERIPH_BASE + 0x00004400UL)
  555. #define UART3_BASE (APB1PERIPH_BASE + 0x00004800UL)
  556. #define I2C1_BASE (APB1PERIPH_BASE + 0x00005400UL)
  557. #define I2C2_BASE (APB1PERIPH_BASE + 0x00005800UL)
  558. #define CAN1_BASE (APB1PERIPH_BASE + 0x00006400UL)
  559. #define LPUART_BASE (APB1PERIPH_BASE + 0x00008000UL)
  560. #define LCD_BASE (APB1PERIPH_BASE + 0x0000F000UL)
  561. ///*----------------------APB2 peripherals------------------------*/
  562. #define COMP_BASE (APB2PERIPH_BASE + 0x00000200UL)
  563. #define OPA_BASE (APB2PERIPH_BASE + 0x00000300UL)
  564. #define EXTI_BASE (APB2PERIPH_BASE + 0x00000400UL)
  565. #define SCU_BASE (APB2PERIPH_BASE + 0x00000800UL)
  566. #define CRC_BASE (APB2PERIPH_BASE + 0x00000C00UL)
  567. #define ADC_BASE (APB2PERIPH_BASE + 0x00002400UL)
  568. #define TIM1_BASE (APB2PERIPH_BASE + 0x00002C00UL)
  569. #define UART1_BASE (APB2PERIPH_BASE + 0x00003800UL)
  570. #define TIM15_BASE (APB2PERIPH_BASE + 0x00004000UL)
  571. #define TIM16_BASE (APB2PERIPH_BASE + 0x00004400UL)
  572. #define TIM17_BASE (APB2PERIPH_BASE + 0x00004800UL)
  573. #define TKEY_BASE (APB2PERIPH_BASE + 0x00006400UL)
  574. #define GPIOAB_BASE (APB2PERIPH_BASE + 0x0000F000UL)
  575. #define GPIOCD_BASE (APB2PERIPH_BASE + 0x0000F400UL)
  576. //#define ACM32F0X0_VER_0
  577. #ifdef ACM32F0X0_VER_0
  578. #undef GPIOAB_BASE
  579. #undef GPIOCD_BASE
  580. #undef UART3_BASE
  581. #undef PMU_BASE
  582. #undef RTC_BASE
  583. #undef COMP_BASE
  584. #undef OPA_BASE
  585. #define GPIOAB_BASE 0x40006800
  586. #define GPIOCD_BASE 0x40016800
  587. #define UART3_BASE 0x40004800
  588. #define PMU_BASE 0x40002400
  589. #define RTC_BASE 0x40002800
  590. #define COMP_BASE 0x40010200
  591. #define OPA_BASE 0x40010300
  592. #endif
  593. ///*----------------------AHB1 peripherals------------------------*/
  594. #define SPI1_BASE (AHB1PERIPH_BASE)
  595. #define SPI2_BASE (AHB1PERIPH_BASE + 0x00000400UL)
  596. #define DMAC_BASE (AHB1PERIPH_BASE + 0x00001000UL)
  597. #define DMA_Channel0_BASE (AHB1PERIPH_BASE + 0x00001100UL)
  598. #define DMA_Channel1_BASE (AHB1PERIPH_BASE + 0x00001120UL)
  599. #define DMA_Channel2_BASE (AHB1PERIPH_BASE + 0x00001140UL)
  600. #define DMA_Channel3_BASE (AHB1PERIPH_BASE + 0x00001160UL)
  601. #define DMA_Channel4_BASE (AHB1PERIPH_BASE + 0x00001180UL)
  602. ///*----------------------AHB2 peripherals------------------------*/
  603. #define AES_BASE (AHB2PERIPH_BASE)
  604. #define DIV_BASE (AHB2PERIPH_BASE + 0x00000400UL)
  605. #define HRNG_BASE (AHB2PERIPH_BASE + 0x00000800UL)
  606. /**
  607. * @}
  608. */
  609. /** @addtogroup Peripheral_declaration
  610. * @{
  611. */
  612. #define EFC ((EFC_TypeDef *)EFC_BASE)
  613. #define TIM3 ((TIM_TypeDef *)TIM3_BASE)
  614. #define TIM6 ((TIM_TypeDef *)TIM6_BASE)
  615. #define TIM14 ((TIM_TypeDef *)TIM14_BASE)
  616. #define PMU ((PMU_TypeDef *)PMU_BASE)
  617. #define RTC ((RTC_TypeDef *)RTC_BASE)
  618. #define WDT ((WDT_TypeDef *)WDT_BASE)
  619. #define IWDT ((IWDT_TypeDef *)IWDT_BASE)
  620. #define LCD ((LCD_TypeDef *)LCD_BASE)
  621. #define UART2 ((UART_TypeDef *)UART2_BASE)
  622. #define UART3 ((UART_TypeDef *)UART3_BASE)
  623. #define I2C1 ((I2C_TypeDef *)I2C1_BASE)
  624. #define I2C2 ((I2C_TypeDef *)I2C2_BASE)
  625. #define CAN1 ((CAN_TypeDef *)CAN1_BASE)
  626. #define LPUART ((LPUART_TypeDef *)LPUART_BASE)
  627. #define GPIOAB ((GPIO_TypeDef *)GPIOAB_BASE)
  628. #define EXTI ((EXTI_TypeDef *)EXTI_BASE)
  629. #define SCU ((SCU_TypeDef *)SCU_BASE)
  630. #define CRC ((CRC_TypeDef *)CRC_BASE)
  631. #define COMP ((COMP_TypeDef *)COMP_BASE)
  632. #define OPA ((OPA_TypeDef *)OPA_BASE)
  633. #define ADC ((ADC_TypeDef *)ADC_BASE)
  634. #define TIM1 ((TIM_TypeDef *)TIM1_BASE)
  635. #define UART1 ((UART_TypeDef *)UART1_BASE)
  636. #define TIM15 ((TIM_TypeDef *)TIM15_BASE)
  637. #define TIM16 ((TIM_TypeDef *)TIM16_BASE)
  638. #define TIM17 ((TIM_TypeDef *)TIM17_BASE)
  639. #define TKEY ((TKEY_TypeDef *)TKEY_BASE)
  640. #define GPIOCD ((GPIO_TypeDef *)GPIOCD_BASE)
  641. #define SPI1 ((SPI_TypeDef *)SPI1_BASE)
  642. #define SPI2 ((SPI_TypeDef *)SPI2_BASE)
  643. #define DMA ((DMA_TypeDef *)DMAC_BASE)
  644. #define DMA_Channel0 ((DMA_Channel_TypeDef *)DMA_Channel0_BASE)
  645. #define DMA_Channel1 ((DMA_Channel_TypeDef *)DMA_Channel1_BASE)
  646. #define DMA_Channel2 ((DMA_Channel_TypeDef *)DMA_Channel2_BASE)
  647. #define DMA_Channel3 ((DMA_Channel_TypeDef *)DMA_Channel3_BASE)
  648. #define DMA_Channel4 ((DMA_Channel_TypeDef *)DMA_Channel4_BASE)
  649. #define HRNG ((HRNG_TypeDef *)HRNG_BASE)
  650. #define AES ((AES_TypeDef *)AES_BASE)
  651. #define DIV ((DIV_TypeDef *)DIV_BASE)
  652. /**
  653. * @}
  654. */
  655. /** @addtogroup Exported_macros
  656. * @{
  657. */
  658. #define SET_BIT(REG, BIT) ((REG) |= (BIT))
  659. #define CLEAR_BIT(REG, BIT) ((REG) &= ~(BIT))
  660. #define READ_BIT(REG, BIT) ((REG) & (BIT))
  661. #define CLEAR_REG(REG) ((REG) = (0x0))
  662. #define WRITE_REG(REG, VAL) ((REG) = (VAL))
  663. #define READ_REG(REG) ((REG))
  664. #define MODIFY_REG(REG,MASK,BITS) ((REG) = (((REG)&(~(MASK)))|((BITS)&(MASK))))
  665. /**
  666. * @}
  667. */
  668. /* Compatible with old code */
  669. typedef signed char INT8;
  670. typedef signed short int INT16;
  671. typedef signed int INT32;
  672. typedef unsigned char UINT8;
  673. typedef unsigned short int UINT16;
  674. typedef unsigned int UINT32;
  675. #ifdef __cplusplus
  676. }
  677. #endif
  678. #endif /* ACM32F0x0_H */