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