1
0

ACM32F4.h 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848
  1. /*
  2. ******************************************************************************
  3. * @file ACM32F4.h
  4. * @brief CMSIS ACM32F4 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 __ACM32F4_H__
  14. #define __ACM32F4_H__
  15. #ifdef __cplusplus
  16. extern "C"
  17. {
  18. #endif
  19. ///*------------------- Interrupt Number Definition ----------------------*/
  20. typedef enum IRQn
  21. {
  22. /* ---------------------------------- Cortex-M33 Processor Exceptions Numbers ----------------------------------- */
  23. Reset_IRQn = -15, /* -15 Reset Vector, invoked on Power up and warm reset */
  24. NonMaskableInt_IRQn = -14, /* -14 Non maskable Interrupt, cannot be stopped or preempted */
  25. HardFault_IRQn = -13, /* -13 Hard Fault, all classes of Fault */
  26. MemoryManagement_IRQn = -12, /* -12 Memory Management, MPU mismatch, including Access Violation
  27. and No Match */
  28. BusFault_IRQn = -11, /* -11 Bus Fault, Pre-Fetch-, Memory Access Fault, other address/memory
  29. related Fault */
  30. UsageFault_IRQn = -10, /* -10 Usage Fault, i.e. Undef Instruction, Illegal State Transition */
  31. SVCall_IRQn = -5, /* -5 System Service Call via SVC instruction */
  32. DebugMonitor_IRQn = -4, /* -4 Debug Monitor */
  33. PendSV_IRQn = -2, /* -2 Pendable request for system service */
  34. SysTick_IRQn = -1, /* -1 System Tick Timer */
  35. /* ------------------------------------- ARMCM0 Specific Interrupt Numbers -------------------------------------- */
  36. WDT_IRQn = 0, /* 0: WDT_IRQHandler */
  37. RTC_IRQn = 1, /* 1: RTC_IRQHandler */
  38. EFC_IRQn = 2, /* 2: EFC_IRQHandler */
  39. GPIOAB_IRQn = 3, /* 3: GPIOAB_IRQHandler */
  40. GPIOCD_IRQn = 4, /* 4: GPIOCD_IRQHandler */
  41. EXTI_IRQn = 5, /* 5: EXTI_IRQHandler */
  42. SRAM_PARITY_IRQn = 6, /* 6: SRAM_PARITY_IRQHandler */
  43. CLKRDY_IRQn = 7, /* 7: CLKRDY_IRQHandler */
  44. UART4_IRQn = 8, /* 8: UART4_IRQHandler */
  45. DMA_IRQn = 9, /* 9: DMA_IRQHandler */
  46. UART3_IRQn = 10, /* 10: UART3_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. TIM2_IRQn = 15, /* 15: TIM2_IRQHandler */
  51. TIM3_IRQn = 16, /* 16: TIM3_IRQHandler */
  52. TIM6_IRQn = 17, /* 17: TIM6_IRQHandler */
  53. TIM7_IRQn = 18, /* 18: TIM7_IRQHandler */
  54. TIM14_IRQn = 19, /* 19: TIM14_IRQHandler */
  55. TIM15_IRQn = 20, /* 20: TIM15_IRQHandler */
  56. TIM16_IRQn = 21, /* 21: TIM16_IRQHandler */
  57. TIM17_IRQn = 22, /* 22: TIM17_IRQHandler */
  58. I2C1_IRQn = 23, /* 23: I2C1_IRQHandler */
  59. I2C2_IRQn = 24, /* 24: I2C2_IRQHandler */
  60. SPI1_IRQn = 25, /* 25: SPI1_IRQHandler */
  61. SPI2_IRQn = 26, /* 26: SPI2_IRQHandler */
  62. UART1_IRQn = 27, /* 27: UART1_IRQHandler */
  63. UART2_IRQn = 28, /* 28: UART2_IRQHandler */
  64. LPUART_IRQn = 29, /* 29: LPUART_IRQHandler */
  65. SPI3_IRQn = 30, /* 30: SPI3_IRQHandler */
  66. AES_IRQn = 31, /* 31: AES_IRQHandler */
  67. USB_IRQn = 32, /* 32: USB_IRQHandler */
  68. DAC_IRQn = 33, /* 33: DAC_IRQHandler */
  69. I2S_IRQn = 34, /* 34: I2S_IRQHandler */
  70. GPIOEF_IRQ = 35, /* 35: GPIOEF_IRQHandler */
  71. CAN1_IRQn = 36, /* 36: CAN1_IRQHandler */
  72. CAN2_IRQn = 37, /* 37: CAN2_IRQHandler */
  73. FPU_IRQn = 38, /* 38: FPU_IRQHandler */
  74. TIM4_IRQn = 39, /* 39: TIM4_IRQHandler */
  75. SPI4_IRQn = 40, /* 40: SPI4_IRQHandler */
  76. } IRQn_Type;
  77. /* ================================================================================ */
  78. /* ================ Processor and Core Peripheral Section ================ */
  79. /* ================================================================================ */
  80. /* Configuration of the Cortex-M33 Processor and Core Peripherals */
  81. #define __MPU_PRESENT 1 /*!< mcu does not provide a MPU present or not */
  82. #define __NVIC_PRIO_BITS 3 /*!< mcu Supports 3 Bits for the Priority Levels */
  83. #define __Vendor_SysTickConfig 0 /*!< Set to 1 if different SysTick Config is used */
  84. #define ARM_MATH_CM4 1
  85. #define __TARGET_FPU_VFP 1
  86. #define __FPU_PRESENT 1
  87. #define __DSP_PRESENT 1
  88. #define __ARM_COMPAT_H 1
  89. #define __ACCELERATE_PRESENT 1
  90. #define __ACCELERATE_EH_PRESENT 0
  91. #include "core_cm33.h" /* Processor and core peripherals */
  92. #include "stdio.h"
  93. #include "stdint.h"
  94. #include "stdbool.h"
  95. #include "string.h"
  96. ///*------------------- Bit Opertions ----------------------*/
  97. #define BIT0 (1U << 0)
  98. #define BIT1 (1U << 1)
  99. #define BIT2 (1U << 2)
  100. #define BIT3 (1U << 3)
  101. #define BIT4 (1U << 4)
  102. #define BIT5 (1U << 5)
  103. #define BIT6 (1U << 6)
  104. #define BIT7 (1U << 7)
  105. #define BIT8 (1U << 8)
  106. #define BIT9 (1U << 9)
  107. #define BIT10 (1U << 10)
  108. #define BIT11 (1U << 11)
  109. #define BIT12 (1U << 12)
  110. #define BIT13 (1U << 13)
  111. #define BIT14 (1U << 14)
  112. #define BIT15 (1U << 15)
  113. #define BIT16 (1U << 16)
  114. #define BIT17 (1U << 17)
  115. #define BIT18 (1U << 18)
  116. #define BIT19 (1U << 19)
  117. #define BIT20 (1U << 20)
  118. #define BIT21 (1U << 21)
  119. #define BIT22 (1U << 22)
  120. #define BIT23 (1U << 23)
  121. #define BIT24 (1U << 24)
  122. #define BIT25 (1U << 25)
  123. #define BIT26 (1U << 26)
  124. #define BIT27 (1U << 27)
  125. #define BIT28 (1U << 28)
  126. #define BIT29 (1U << 29)
  127. #define BIT30 (1U << 30)
  128. #define BIT31 (1U << 31)
  129. /** @Addtogroup Peripheral_Registers_Structures
  130. * @{
  131. */
  132. ///*------------------- FLASH Registers ----------------------*/
  133. typedef struct
  134. {
  135. __IO uint32_t CTRL;
  136. __IO uint32_t SEC;
  137. __IO uint32_t ADCT;
  138. __IO uint32_t TERASE;
  139. __IO uint32_t TPROG;
  140. __IO uint32_t STATUS;
  141. __IO uint32_t INTSTATUS;
  142. __IO uint32_t INTEN;
  143. __IO uint32_t CONFIG;
  144. __IO uint32_t EDCTRL;
  145. __IO uint32_t RDN0;
  146. __IO uint32_t RDN1;
  147. __IO uint32_t RDN2;
  148. __IO uint32_t RDN3;
  149. __IO uint32_t TNVS;
  150. __IO uint32_t TMODE_SEC;
  151. __IO uint32_t TDOUT;
  152. __IO uint32_t TDIN;
  153. __IO uint32_t TCTRL;
  154. }EFC_TypeDef;
  155. ///*------------------- Timer Registers ----------------------*/
  156. typedef struct
  157. {
  158. __IO uint32_t CR1;
  159. __IO uint32_t CR2;
  160. __IO uint32_t SMCR;
  161. __IO uint32_t DIER;
  162. __IO uint32_t SR;
  163. __IO uint32_t EGR;
  164. __IO uint32_t CCMR1;
  165. __IO uint32_t CCMR2;
  166. __IO uint32_t CCER;
  167. __IO uint32_t CNT;
  168. __IO uint32_t PSC;
  169. __IO uint32_t ARR;
  170. __IO uint32_t RCR;
  171. __IO uint32_t CCR1;
  172. __IO uint32_t CCR2;
  173. __IO uint32_t CCR3;
  174. __IO uint32_t CCR4;
  175. __IO uint32_t BDTR;
  176. __IO uint32_t DCR;
  177. __IO uint32_t DMAR;
  178. __IO uint32_t RSV0[4];
  179. __IO uint32_t AF1;
  180. __IO uint32_t RSV1;
  181. __IO uint32_t TISEL;
  182. __IO uint32_t DBER;
  183. }TIM_TypeDef;
  184. ///*------------------- RTC¡¢PMU Registers ----------------------*/
  185. typedef struct
  186. {
  187. __IO uint32_t WP;
  188. __IO uint32_t IE;
  189. __IO uint32_t SR;
  190. __IO uint32_t SEC;
  191. __IO uint32_t MIN;
  192. __IO uint32_t HOUR;
  193. __IO uint32_t DATE;
  194. __IO uint32_t WEEK;
  195. __IO uint32_t MONTH;
  196. __IO uint32_t YEAR;
  197. __IO uint32_t ALM;
  198. __IO uint32_t CR;
  199. __IO uint32_t ADJUST;
  200. __IO uint32_t RSV0[4];
  201. __IO uint32_t CLKSTAMP1_TIME;
  202. __IO uint32_t CALSTAMP1_DATE;
  203. __IO uint32_t CLKSTAMP2_TIME;
  204. __IO uint32_t CALSTAMP2_DATE;
  205. __IO uint32_t RSV2[7];
  206. __IO uint32_t BAKUP[5];
  207. }RTC_TypeDef;
  208. typedef struct
  209. {
  210. __IO uint32_t CR1;
  211. __IO uint32_t SR;
  212. __IO uint32_t IOSEL;
  213. __IO uint32_t IOCR;
  214. __IO uint32_t ANACR;
  215. __IO uint32_t CR2;
  216. }PMU_TypeDef;
  217. ///*------------------- WDT Registers ----------------------*/
  218. typedef struct
  219. {
  220. __IO uint32_t LOAD;
  221. __IO uint32_t COUNT;
  222. __IO uint32_t CTRL;
  223. __IO uint32_t FEED;
  224. __IO uint32_t INTCLRTIME;
  225. __IO uint32_t RIS;
  226. }WDT_TypeDef;
  227. ///*------------------- IWDT Registers ----------------------*/
  228. typedef struct
  229. {
  230. __IO uint32_t CMDR;
  231. __IO uint32_t PR;
  232. __IO uint32_t RLR;
  233. __IO uint32_t SR;
  234. __IO uint32_t WINR;
  235. __IO uint32_t WUTR;
  236. }IWDT_TypeDef;
  237. ///*------------------- UART Registers ----------------------*/
  238. typedef struct
  239. {
  240. __IO uint32_t DR;
  241. __IO uint32_t RSR;
  242. __IO uint32_t RSV0[4];
  243. __IO uint32_t FR;
  244. __IO uint32_t RSV1;
  245. __IO uint32_t ILPR;
  246. __IO uint32_t IBRD;
  247. __IO uint32_t FBRD;
  248. __IO uint32_t LCRH;
  249. __IO uint32_t CR;
  250. __IO uint32_t IFLS;
  251. __IO uint32_t IE;
  252. __IO uint32_t RIS;
  253. __IO uint32_t MIS;
  254. __IO uint32_t ICR;
  255. __IO uint32_t DMACR;
  256. __IO uint32_t RSV2[2];
  257. __IO uint32_t CR2;
  258. __IO uint32_t BCNT;
  259. }UART_TypeDef;
  260. ///*------------------- I2C Registers ----------------------*/
  261. typedef struct
  262. {
  263. __IO uint32_t SLAVE_ADDR1;
  264. __IO uint32_t CLK_DIV;
  265. __IO uint32_t CR;
  266. __IO uint32_t SR;
  267. __IO uint32_t DR;
  268. __IO uint32_t SLAVE_ADDR2_3;
  269. __IO uint32_t RSV[3];
  270. __IO uint32_t TIMEOUT;
  271. }I2C_TypeDef;
  272. ///*------------------- CAN Registers ----------------------*/
  273. typedef struct
  274. {
  275. __IO uint32_t ACR[4];
  276. __IO uint32_t AMR[4];
  277. __IO uint32_t RSV[5];
  278. }Filter_typedef;
  279. typedef union
  280. {
  281. __IO uint32_t DATABUF[13];
  282. Filter_typedef FILTER;
  283. }DF_typedef;
  284. typedef struct
  285. {
  286. __IO uint32_t MOD;
  287. __IO uint32_t CMR;
  288. __IO uint32_t SR;
  289. __IO uint32_t IR;
  290. __IO uint32_t IER;
  291. __IO uint32_t RSV0;
  292. __IO uint32_t BTR0;
  293. __IO uint32_t BTR1;
  294. __IO uint32_t OCR;
  295. __IO uint32_t RSV1;
  296. __IO uint32_t RSV2;
  297. __IO uint32_t ALC;
  298. __IO uint32_t ECC;
  299. __IO uint32_t EWLR;
  300. __IO uint32_t RXERR;
  301. __IO uint32_t TXERR;
  302. __IO DF_typedef DF;
  303. __IO uint32_t RMC;
  304. __IO uint32_t RBSA;
  305. __IO uint32_t CDR;
  306. __IO uint32_t RXFIFO[64];
  307. __IO uint32_t TXFIFO[13];
  308. }CAN_TypeDef;
  309. ///*------------------- DAC Registers ----------------------*/
  310. typedef struct
  311. {
  312. __IO uint32_t CR;
  313. __IO uint32_t SWTRIGR;
  314. __IO uint32_t DHR12R1;
  315. __IO uint32_t DHR12L1;
  316. __IO uint32_t DHR8R1;
  317. __IO uint32_t DHR12R2;
  318. __IO uint32_t DHR12L2;
  319. __IO uint32_t DHR8R2;
  320. __IO uint32_t DHR12RD;
  321. __IO uint32_t DHR12LD;
  322. __IO uint32_t DHR8RD;
  323. __IO uint32_t DOR1;
  324. __IO uint32_t DOR2;
  325. __IO uint32_t SR;
  326. __IO uint32_t CCR;
  327. __IO uint32_t MCR;
  328. __IO uint32_t SHSR1;
  329. __IO uint32_t SHSR2;
  330. __IO uint32_t SHHR;
  331. __IO uint32_t SHRR;
  332. }DAC_TypeDef;
  333. ///*------------------- LPUART Registers ----------------------*/
  334. typedef struct
  335. {
  336. __IO uint32_t RXDR;
  337. __IO uint32_t TXDR;
  338. __IO uint32_t LCR;
  339. __IO uint32_t CR;
  340. __IO uint32_t IBAUD;
  341. __IO uint32_t FBAUD;
  342. __IO uint32_t IE;
  343. __IO uint32_t SR;
  344. __IO uint32_t ADDR;
  345. }LPUART_TypeDef;
  346. ///*------------------- COMP Registers ----------------------*/
  347. typedef struct
  348. {
  349. __IO uint32_t CR1;
  350. __IO uint32_t CR2;
  351. __IO uint32_t SR;
  352. }COMP_TypeDef;
  353. ///*------------------- OPA Registers ----------------------*/
  354. typedef struct
  355. {
  356. __IO uint32_t OPA1_CSR;
  357. __IO uint32_t OPA2_CSR;
  358. __IO uint32_t OPA3_CSR;
  359. }OPA_TypeDef;
  360. ///*------------------- EXTI Registers ----------------------*/
  361. typedef struct
  362. {
  363. __IO uint32_t IENR;
  364. __IO uint32_t EENR;
  365. __IO uint32_t RTENR;
  366. __IO uint32_t FTENR;
  367. __IO uint32_t SWIER;
  368. __IO uint32_t PDR;
  369. __IO uint32_t EXTICR1;
  370. __IO uint32_t EXTICR2;
  371. }EXTI_TypeDef;
  372. ///*------------------- SCU Registers ----------------------*/
  373. typedef struct
  374. {
  375. __IO uint32_t RCR;
  376. __IO uint32_t RSR;
  377. __IO uint32_t IPRST2;
  378. __IO uint32_t IPRST1;
  379. __IO uint32_t CCR1;
  380. __IO uint32_t CCR2;
  381. __IO uint32_t CIR;
  382. __IO uint32_t IPCKENR1;
  383. __IO uint32_t IPCKENR2;
  384. __IO uint32_t RCHCR;
  385. __IO uint32_t XTHCR;
  386. __IO uint32_t PLLCR;
  387. __IO uint32_t LDOCR;
  388. __IO uint32_t RSV0;
  389. __IO uint32_t WMR;
  390. __IO uint32_t CLKOCR;
  391. __IO uint32_t VER;
  392. __IO uint32_t SYSCFG1;
  393. __IO uint32_t LVDCFG;
  394. __IO uint32_t STOPCFG;
  395. __IO uint32_t RSV1;
  396. __IO uint32_t PHYCR;
  397. __IO uint32_t MEMCFG;
  398. __IO uint32_t DUMMY;
  399. __IO uint32_t PASEL1;
  400. __IO uint32_t PASEL2;
  401. __IO uint32_t PBSEL1;
  402. __IO uint32_t PBSEL2;
  403. __IO uint32_t PABPUR;
  404. __IO uint32_t PABPDR;
  405. __IO uint32_t PASTR;
  406. __IO uint32_t PBSTR;
  407. __IO uint32_t PABSMTR;
  408. __IO uint32_t PABODR;
  409. __IO uint32_t PABADS;
  410. __IO uint32_t RSV2;
  411. __IO uint32_t PCSEL1;
  412. __IO uint32_t PCSEL2;
  413. __IO uint32_t PDSEL1;
  414. __IO uint32_t PDSEL2;
  415. __IO uint32_t PCDPUR;
  416. __IO uint32_t PCDPDR;
  417. __IO uint32_t PCSTR;
  418. __IO uint32_t PDSTR;
  419. __IO uint32_t PCDSMTR;
  420. __IO uint32_t PCDODR;
  421. __IO uint32_t PCDADS;
  422. __IO uint32_t RSV3;
  423. __IO uint32_t PESEL1;
  424. __IO uint32_t PESEL2;
  425. __IO uint32_t PFSEL1;
  426. __IO uint32_t RSV4;
  427. __IO uint32_t PEFPUR;
  428. __IO uint32_t PEFPDR;
  429. __IO uint32_t PESTR;
  430. __IO uint32_t PFSTR;
  431. __IO uint32_t PEFSMTR;
  432. __IO uint32_t PEFODR;
  433. __IO uint32_t PEFADS;
  434. }SCU_TypeDef;
  435. ///*------------------- CRC Registers ----------------------*/
  436. typedef struct
  437. {
  438. __IO uint32_t DATA;
  439. __IO uint32_t CTRL;
  440. __IO uint32_t INIT;
  441. __IO uint32_t RSV0;
  442. __IO uint32_t OUTXOR;
  443. __IO uint32_t POLY;
  444. __IO uint32_t FDATA;
  445. }CRC_TypeDef;
  446. ///*------------------- ADC Registers ----------------------*/
  447. typedef struct
  448. {
  449. __IO uint32_t SR;
  450. __IO uint32_t IE;
  451. __IO uint32_t CR1;
  452. __IO uint32_t CR2;
  453. __IO uint32_t SMPR1;
  454. __IO uint32_t SMPR2;
  455. __IO uint32_t HTR;
  456. __IO uint32_t LTR;
  457. __IO uint32_t SQR1;
  458. __IO uint32_t SQR2;
  459. __IO uint32_t SQR3;
  460. __IO uint32_t JSQR;
  461. __IO uint32_t JDR;
  462. __IO uint32_t DR;
  463. __IO uint32_t DIFF;
  464. __IO uint32_t SIGN;
  465. __IO uint32_t TSREF;
  466. __IO uint32_t SMPR3;
  467. }ADC_TypeDef;
  468. ///*------------------- I2S Registers ----------------------*/
  469. typedef struct
  470. {
  471. __IO uint32_t DAT;
  472. __IO uint32_t CTL;
  473. __IO uint32_t PSC;
  474. __IO uint32_t IE;
  475. __IO uint32_t STATUS;
  476. }I2S_TypeDef;
  477. ///*------------------- GPIO Registers ----------------------*/
  478. typedef struct
  479. {
  480. __IO uint32_t DIR;
  481. __IO uint32_t RSV0;
  482. __IO uint32_t SET;
  483. __IO uint32_t CLR;
  484. __IO uint32_t ODATA;
  485. __IO uint32_t IDATA;
  486. __IO uint32_t IEN;
  487. __IO uint32_t IS;
  488. __IO uint32_t IBE;
  489. __IO uint32_t IEV;
  490. __IO uint32_t IC;
  491. __IO uint32_t RIS;
  492. __IO uint32_t MIS;
  493. }GPIO_TypeDef;
  494. ///*------------------- SPI Registers ----------------------*/
  495. typedef struct
  496. {
  497. __IO uint32_t DAT;
  498. __IO uint32_t BAUD;
  499. __IO uint32_t CTL;
  500. __IO uint32_t TX_CTL;
  501. __IO uint32_t RX_CTL;
  502. __IO uint32_t IE;
  503. __IO uint32_t STATUS;
  504. __IO uint32_t TX_DELAY;
  505. __IO uint32_t BATCH;
  506. __IO uint32_t CS;
  507. __IO uint32_t OUT_EN;
  508. __IO uint32_t MEMO_ACC;
  509. __IO uint32_t CMD;
  510. __IO uint32_t PARA;
  511. }SPI_TypeDef;
  512. ///*------------------- DMA Registers ----------------------*/
  513. typedef struct
  514. {
  515. __IO uint32_t INT_STATUS;
  516. __IO uint32_t INT_TC_STATUS;
  517. __IO uint32_t INT_TC_CLR;
  518. __IO uint32_t INT_ERR_STATUS;
  519. __IO uint32_t INT_ERR_CLR;
  520. __IO uint32_t RAW_INT_TC_STATUS;
  521. __IO uint32_t RAW_INT_ERR_STATUS;
  522. __IO uint32_t EN_CH_STATUS;
  523. __IO uint32_t RSV0[4];
  524. __IO uint32_t CONFIG;
  525. __IO uint32_t SYNCLO;
  526. __IO uint32_t SYNCHI;
  527. }DMA_TypeDef;
  528. typedef struct
  529. {
  530. __IO uint32_t SRC_ADDR;
  531. __IO uint32_t DEST_ADDR;
  532. __IO uint32_t LLI;
  533. __IO uint32_t CTRL;
  534. __IO uint32_t CONFIG;
  535. }DMA_Channel_TypeDef;
  536. ///*------------------- AES Registers ----------------------*/
  537. typedef struct
  538. {
  539. __IO uint32_t DATAIN;
  540. __IO uint32_t KEYIN;
  541. __IO uint32_t RSV0;
  542. __IO uint32_t CONTROL;
  543. __IO uint32_t STATE;
  544. __IO uint32_t DATAOUT;
  545. }AES_TypeDef;
  546. ///*------------------- FAU Registers ----------------------*/
  547. typedef struct
  548. {
  549. __IO uint32_t CTRL1; //0x00
  550. __IO uint32_t STAUTS; //0x04
  551. __IO uint32_t CORDIC_X_DATAIN; //0x08
  552. __IO uint32_t CORDIC_Y_DATAIN; //0x0c
  553. __IO uint32_t RESULT1; //0x10
  554. __IO uint32_t RESULT2; //0x14
  555. }FAU_TypeDef;
  556. ///*------------------- HRNG Registers ----------------------*/
  557. typedef struct
  558. {
  559. __IO uint32_t CTRL;
  560. __IO uint32_t LFSR;
  561. }HRNG_TypeDef;
  562. ///*------------------- HASH Registers ----------------------*/
  563. typedef struct
  564. {
  565. __IO uint32_t DATAIN;
  566. __IO uint32_t MIDDATA;
  567. __IO uint32_t CTRL;
  568. __IO uint32_t DATAOUT;
  569. }HASH_TypeDef;
  570. ///*------------------- USB Registers ----------------------*/
  571. typedef struct
  572. {
  573. __IO uint32_t WORKING_MODE;
  574. __IO uint32_t EPxCSR[5];
  575. __IO uint32_t USB_ADDR;
  576. __IO uint32_t SETIP_0_3_DATA;
  577. __IO uint32_t SETIP_4_7_DATA;
  578. __IO uint32_t EPADDR_CFG;
  579. __IO uint32_t CURRENT_PID;
  580. __IO uint32_t CURRENT_FRAME_NUMBER;
  581. __IO uint32_t CRC_ERROR_CNT;
  582. __IO uint32_t USB_STATUS_DETECT_CNT;
  583. __IO uint32_t RSV0;
  584. __IO uint32_t RSV1;
  585. __IO uint32_t EPxSENDBN[5];
  586. }USB_CTRLTypeDef;
  587. ///*------------------- USB interrupt access Registers ----------------------*/
  588. typedef struct
  589. {
  590. __IO uint32_t INT_STAT_RAW;
  591. __IO uint32_t INT_EN;
  592. __IO uint32_t RSV;
  593. __IO uint32_t INT_CLR;
  594. }USB_INTTypeDef;
  595. /**
  596. * @}
  597. */
  598. /** @addtogroup Peripheral_memory_map
  599. * @{
  600. */
  601. ///*------------------- Peripheral memory map ----------------------*/
  602. #define EFLASH_BASE (0x00000000UL)
  603. #define SRAM_BASE (0x20000000UL)
  604. #define PERIPH_BASE (0x40000000UL)
  605. #define QSPI_BASE (0x90000000UL)
  606. #define APB1PERIPH_BASE (PERIPH_BASE)
  607. #define APB2PERIPH_BASE (PERIPH_BASE + 0x00010000UL)
  608. #define AHBPERIPH_BASE (PERIPH_BASE + 0x00020000UL)
  609. ///*---------------------- EFC peripherals ------------------------*/
  610. #define EFLASH_REG_BASE (EFLASH_BASE + 0x00100000)
  611. ///*---------------------- APB1 peripherals ------------------------*/
  612. #define TIM2_BASE (APB1PERIPH_BASE + 0x00000000UL)
  613. #define TIM3_BASE (APB1PERIPH_BASE + 0x00000400UL)
  614. #define TIM4_BASE (APB1PERIPH_BASE + 0x00000800UL)
  615. #define TIM6_BASE (APB1PERIPH_BASE + 0x00001000UL)
  616. #define TIM7_BASE (APB1PERIPH_BASE + 0x00001400UL)
  617. #define TIM14_BASE (APB1PERIPH_BASE + 0x00002000UL)
  618. #define PMU_BASE (APB1PERIPH_BASE + 0x00002400UL)
  619. #define RTC_BASE (APB1PERIPH_BASE + 0x00002800UL)
  620. #define WDT_BASE (APB1PERIPH_BASE + 0x00002C00UL)
  621. #define IWDT_BASE (APB1PERIPH_BASE + 0x00003000UL)
  622. #define UART2_BASE (APB1PERIPH_BASE + 0x00004400UL)
  623. #define UART3_BASE (APB1PERIPH_BASE + 0x00004800UL)
  624. #define UART4_BASE (APB1PERIPH_BASE + 0x00004C00UL)
  625. #define I2C1_BASE (APB1PERIPH_BASE + 0x00005400UL)
  626. #define I2C2_BASE (APB1PERIPH_BASE + 0x00005800UL)
  627. #define CAN1_BASE (APB1PERIPH_BASE + 0x00006400UL)
  628. #define CAN2_BASE (APB1PERIPH_BASE + 0x00006800UL)
  629. #define DAC_BASE (APB1PERIPH_BASE + 0x00007400UL)
  630. #define LPUART_BASE (APB1PERIPH_BASE + 0x00008000UL)
  631. ///*---------------------- APB2 peripherals ------------------------*/
  632. #define COMP_BASE (APB2PERIPH_BASE + 0x00000200UL)
  633. #define OPA_BASE (APB2PERIPH_BASE + 0x00000300UL)
  634. #define EXTI_BASE (APB2PERIPH_BASE + 0x00000400UL)
  635. #define SCU_BASE (APB2PERIPH_BASE + 0x00000800UL)
  636. #define CRC_BASE (APB2PERIPH_BASE + 0x00000C00UL)
  637. #define ADC_BASE (APB2PERIPH_BASE + 0x00002400UL)
  638. #define TIM1_BASE (APB2PERIPH_BASE + 0x00002C00UL)
  639. #define I2S1_BASE (APB2PERIPH_BASE + 0x00003000UL)
  640. #define UART1_BASE (APB2PERIPH_BASE + 0x00003800UL)
  641. #define TIM15_BASE (APB2PERIPH_BASE + 0x00004000UL)
  642. #define TIM16_BASE (APB2PERIPH_BASE + 0x00004400UL)
  643. #define TIM17_BASE (APB2PERIPH_BASE + 0x00004800UL)
  644. #define GPIOAB_BASE (APB2PERIPH_BASE + 0x0000F000UL)
  645. #define GPIOCD_BASE (APB2PERIPH_BASE + 0x0000F400UL)
  646. #define GPIOEF_BASE (APB2PERIPH_BASE + 0x0000F800UL)
  647. ///*---------------------- AHB peripherals ------------------------*/
  648. #define SPI1_BASE (AHBPERIPH_BASE)
  649. #define SPI2_BASE (AHBPERIPH_BASE + 0x00000400UL)
  650. #define SPI3_BASE (AHBPERIPH_BASE + 0x00000800UL)
  651. #define SPI4_BASE (AHBPERIPH_BASE + 0x00000C00UL)
  652. #define DMA_BASE (AHBPERIPH_BASE + 0x00001000UL)
  653. #define DMA_Channel0_BASE (AHBPERIPH_BASE + 0x00001100UL)
  654. #define DMA_Channel1_BASE (AHBPERIPH_BASE + 0x00001120UL)
  655. #define DMA_Channel2_BASE (AHBPERIPH_BASE + 0x00001140UL)
  656. #define DMA_Channel3_BASE (AHBPERIPH_BASE + 0x00001160UL)
  657. #define DMA_Channel4_BASE (AHBPERIPH_BASE + 0x00001180UL)
  658. #define DMA_Channel5_BASE (AHBPERIPH_BASE + 0x000011A0UL)
  659. #define DMA_Channel6_BASE (AHBPERIPH_BASE + 0x000011C0UL)
  660. #define DMA_Channel7_BASE (AHBPERIPH_BASE + 0x000011E0UL)
  661. #define AES_BASE (AHBPERIPH_BASE + 0x00010000UL)
  662. #define FAU_BASE (AHBPERIPH_BASE + 0x00010400UL)
  663. #define HRNG_BASE (AHBPERIPH_BASE + 0x00010800UL)
  664. #define HASH_BASE (AHBPERIPH_BASE + 0x00010C00UL)
  665. #define USB_BASE (AHBPERIPH_BASE + 0x00020000UL)
  666. ///*---------------------- QSPI Memory ------------------------*/
  667. #define QSPI3_BASE (QSPI_BASE)
  668. /**
  669. * @}
  670. */
  671. /** @addtogroup Peripheral_declaration
  672. * @{
  673. */
  674. #define EFC ((EFC_TypeDef *)EFLASH_REG_BASE)
  675. #define TIM2 ((TIM_TypeDef *)TIM2_BASE)
  676. #define TIM3 ((TIM_TypeDef *)TIM3_BASE)
  677. #define TIM4 ((TIM_TypeDef *)TIM4_BASE)
  678. #define TIM6 ((TIM_TypeDef *)TIM6_BASE)
  679. #define TIM7 ((TIM_TypeDef *)TIM7_BASE)
  680. #define TIM14 ((TIM_TypeDef *)TIM14_BASE)
  681. #define PMU ((PMU_TypeDef *)PMU_BASE)
  682. #define RTC ((RTC_TypeDef *)RTC_BASE)
  683. #define WDT ((WDT_TypeDef *)WDT_BASE)
  684. #define IWDT ((IWDT_TypeDef *)IWDT_BASE)
  685. #define UART2 ((UART_TypeDef *)UART2_BASE)
  686. #define UART3 ((UART_TypeDef *)UART3_BASE)
  687. #define UART4 ((UART_TypeDef *)UART4_BASE)
  688. #define I2C1 ((I2C_TypeDef *)I2C1_BASE)
  689. #define I2C2 ((I2C_TypeDef *)I2C2_BASE)
  690. #define CAN1 ((CAN_TypeDef *)CAN1_BASE)
  691. #define CAN2 ((CAN_TypeDef *)CAN2_BASE)
  692. #define DAC ((DAC_TypeDef *)DAC_BASE)
  693. #define LPUART ((LPUART_TypeDef *)LPUART_BASE)
  694. #define COMP ((COMP_TypeDef *)COMP_BASE)
  695. #define OPA ((OPA_TypeDef *)OPA_BASE)
  696. #define EXTI ((EXTI_TypeDef *)EXTI_BASE)
  697. #define SCU ((SCU_TypeDef *)SCU_BASE)
  698. #define CRC ((CRC_TypeDef *)CRC_BASE)
  699. #define ADC ((ADC_TypeDef *)ADC_BASE)
  700. #define TIM1 ((TIM_TypeDef *)TIM1_BASE)
  701. #define I2S1 ((I2S_TypeDef *)I2S1_BASE)
  702. #define UART1 ((UART_TypeDef *)UART1_BASE)
  703. #define TIM15 ((TIM_TypeDef *)TIM15_BASE)
  704. #define TIM16 ((TIM_TypeDef *)TIM16_BASE)
  705. #define TIM17 ((TIM_TypeDef *)TIM17_BASE)
  706. #define GPIOAB ((GPIO_TypeDef *)GPIOAB_BASE)
  707. #define GPIOCD ((GPIO_TypeDef *)GPIOCD_BASE)
  708. #define GPIOEF ((GPIO_TypeDef *)GPIOEF_BASE)
  709. #define SPI1 ((SPI_TypeDef *)SPI1_BASE)
  710. #define SPI2 ((SPI_TypeDef *)SPI2_BASE)
  711. #define SPI3 ((SPI_TypeDef *)SPI3_BASE)
  712. #define SPI4 ((SPI_TypeDef *)SPI4_BASE)
  713. #define DMA ((DMA_TypeDef *)DMA_BASE)
  714. #define DMA_Channel0 ((DMA_Channel_TypeDef *)DMA_Channel0_BASE)
  715. #define DMA_Channel1 ((DMA_Channel_TypeDef *)DMA_Channel1_BASE)
  716. #define DMA_Channel2 ((DMA_Channel_TypeDef *)DMA_Channel2_BASE)
  717. #define DMA_Channel3 ((DMA_Channel_TypeDef *)DMA_Channel3_BASE)
  718. #define DMA_Channel4 ((DMA_Channel_TypeDef *)DMA_Channel4_BASE)
  719. #define DMA_Channel5 ((DMA_Channel_TypeDef *)DMA_Channel5_BASE)
  720. #define DMA_Channel6 ((DMA_Channel_TypeDef *)DMA_Channel6_BASE)
  721. #define DMA_Channel7 ((DMA_Channel_TypeDef *)DMA_Channel7_BASE)
  722. #define AES ((AES_TypeDef *)AES_BASE)
  723. #define FAU ((FAU_TypeDef *)FAU_BASE)
  724. #define HRNG ((HRNG_TypeDef *)HRNG_BASE)
  725. #define HASH ((HASH_TypeDef *)HASH_BASE)
  726. #define USBCTRL ((USB_CTRLTypeDef *)USB_BASE)
  727. #define USBINT ((USB_INTTypeDef *)(USB_BASE+0xFFE4))
  728. /**
  729. * @}
  730. */
  731. /** @addtogroup Exported_macros
  732. * @{
  733. */
  734. #define SET_BIT(REG, BIT) ((REG) |= (BIT))
  735. #define CLEAR_BIT(REG, BIT) ((REG) &= ~(BIT))
  736. #define READ_BIT(REG, BIT) ((REG) & (BIT))
  737. #define CLEAR_REG(REG) ((REG) = (0x0))
  738. #define WRITE_REG(REG, VAL) ((REG) = (VAL))
  739. #define READ_REG(REG) ((REG))
  740. #define MODIFY_REG(REG,MASK,BITS) ((REG) = (((REG)&(~(MASK)))|((BITS)&(MASK))))
  741. typedef signed char INT8;
  742. typedef signed short int INT16;
  743. typedef signed int INT32;
  744. /* exact-width unsigned integer types */
  745. typedef unsigned char UINT8;
  746. typedef unsigned short int UINT16;
  747. typedef unsigned int UINT32;
  748. /**
  749. * @}
  750. */
  751. #ifdef __cplusplus
  752. }
  753. #endif
  754. #endif /* ACM32F4_H */