cst92f2x.h 33 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890
  1. #ifndef __CST92F2X_H
  2. #define __CST92F2X_H
  3. #ifdef __cplusplus
  4. extern "C" {
  5. #endif
  6. #include "mcu.h"
  7. enum{
  8. RSTC_COLD_UP = 0,
  9. RSTC_WARM_UP = 1,
  10. RSTC_OFF_MODE = 2,
  11. RSTC_WAKE_IO = 3,
  12. RSTC_WAKE_RTC = 4,
  13. RSTC_WARM_NDWC = 5 //user mode, no dwc
  14. };
  15. typedef enum{
  16. VERSION_0100 = 1,
  17. VERSION_0200 = 2,
  18. } ic_version_t;
  19. /* ------------------------- Interrupt Number Definition ------------------------ */
  20. typedef enum IRQn
  21. {
  22. /* ------------------- Cortex-M0 Processor Exceptions Numbers ------------------- */
  23. NonMaskableInt_IRQn = -14, /* 2 Non Maskable Interrupt */
  24. HardFault_IRQn = -13, /* 3 HardFault Interrupt */
  25. SVCall_IRQn = -5, /* 11 SV Call Interrupt */
  26. PendSV_IRQn = -2, /* 14 Pend SV Interrupt */
  27. SysTick_IRQn = -1, /* 15 System Tick Interrupt */
  28. /* ---------------------- BUMBEE M0 Interrupt Numbers --------------------- */
  29. BB_IRQn = 4, /* Base band Interrupt */
  30. KSCAN_IRQn = 5, /* Key scan Interrupt */
  31. RTC_IRQn = 6, /* RTC Timer Interrupt */
  32. WDT_IRQn = 10, /* Watchdog Timer Interrupt */
  33. UART0_IRQn = 11, /* UART0 Interrupt */
  34. I2C0_IRQn = 12, /* I2C0 Interrupt */
  35. I2C1_IRQn = 13, /* I2C1 Interrupt */
  36. SPI0_IRQn = 14, /* SPI0 Interrupt */
  37. SPI1_IRQn = 15, /* SPI1 Interrupt */
  38. GPIO_IRQn = 16, /* GPIO Interrupt */
  39. UART1_IRQn = 17, /* UART1 Interrupt */
  40. SPIF_IRQn = 18, /* SPIF Interrupt */
  41. DMAC_IRQn = 19, /* DMAC Interrupt */
  42. TIM1_IRQn = 20, /* Timer1 Interrupt */
  43. TIM2_IRQn = 21, /* Timer2 Interrupt */
  44. TIM3_IRQn = 22, /* Timer3 Interrupt */
  45. TIM4_IRQn = 23, /* Timer4 Interrupt */
  46. TIM5_IRQn = 24, /* Timer5 Interrupt */
  47. TIM6_IRQn = 25, /* Timer6 Interrupt */
  48. AES_IRQn = 28, /* AES Interrupt */
  49. ADCC_IRQn = 29, /* ADC Interrupt */
  50. QDEC_IRQn = 30 /* QDEC Interrupt */
  51. } IRQn_Type;
  52. /* -------- Configuration of the Cortex-M0 Processor and Core Peripherals ------- */
  53. //#define __CM0_REV 0x0000U /* Core revision r0p0 */
  54. //#define __MPU_PRESENT 0U /* MPU present or not */
  55. //#define __VTOR_PRESENT 0U /* no VTOR present*/
  56. #define __NVIC_PRIO_BITS 2U /* Number of Bits used for Priority Levels */
  57. //#define __Vendor_SysTickConfig 0U /* Set to 1 if different SysTick Config is used */
  58. #include "core_cm0.h" /* Processor and core peripherals */
  59. #include "system_ARMCM0.h" /* System Header */
  60. #include "types.h"
  61. typedef enum{
  62. MOD_NONE = 0, MOD_CK802_CPU = 0,
  63. MOD_DMA = 3,
  64. MOD_AES = 4,
  65. MOD_IOMUX = 7,
  66. MOD_UART0 = 8,
  67. MOD_I2C0 = 9,
  68. MOD_I2C1 = 10,
  69. MOD_SPI0 = 11,
  70. MOD_SPI1 = 12,
  71. MOD_GPIO = 13,
  72. MOD_QDEC = 15,
  73. MOD_ADCC = 17,
  74. MOD_PWM = 18,
  75. MOD_SPIF = 19,
  76. MOD_VOC = 20,
  77. MOD_TIMER5 = 21,
  78. MOD_TIMER6 = 22,
  79. MOD_UART1 = 25,
  80. MOD_RTC = 26,
  81. MOD_CP_CPU = 0+32,
  82. MOD_BB = MOD_CP_CPU+3,
  83. MOD_TIMER = MOD_CP_CPU+4,
  84. MOD_WDT = MOD_CP_CPU+5,
  85. MOD_COM = MOD_CP_CPU+6,
  86. MOD_KSCAN = MOD_CP_CPU+7,
  87. MOD_BBREG = MOD_CP_CPU+9,
  88. BBLL_RST = MOD_CP_CPU+10,//can reset,but not gate in here
  89. BBTX_RST = MOD_CP_CPU+11,//can reset,but not gate in here
  90. BBRX_RST = MOD_CP_CPU+12,//can reset,but not gate in here
  91. BBMIX_RST = MOD_CP_CPU+13,//can reset,but not gate in here
  92. MOD_TIMER1 = MOD_CP_CPU+21,
  93. MOD_TIMER2 = MOD_CP_CPU+22,
  94. MOD_TIMER3 = MOD_CP_CPU+23,
  95. MOD_TIMER4 = MOD_CP_CPU+24,
  96. MOD_PCLK_CACHE = 0+64,
  97. MOD_HCLK_CACHE = MOD_PCLK_CACHE+1,
  98. MOD_USR0 = 0+96,
  99. MOD_USR1 = MOD_USR0+1,
  100. MOD_USR2 = MOD_USR0+2,
  101. MOD_USR3 = MOD_USR0+3,
  102. MOD_USR4 = MOD_USR0+4,
  103. MOD_USR5 = MOD_USR0+5,
  104. MOD_USR6 = MOD_USR0+6,
  105. MOD_USR7 = MOD_USR0+7,
  106. MOD_USR8 = MOD_USR0+8,
  107. MOD_SYSTEM = 0xFF,
  108. }MODULE_e;
  109. //SW_CLK -->0x4000f008
  110. #define _CLK_NONE (BIT(0))
  111. #define _CLK_CK802_CPU (BIT(0))
  112. #define _CLK_DMA (BIT(3))
  113. #define _CLK_AES (BIT(4))
  114. #define _CLK_IOMUX (BIT(7))
  115. #define _CLK_UART0 (BIT(8))
  116. #define _CLK_I2C0 (BIT(9))
  117. #define _CLK_I2C1 (BIT(10))
  118. #define _CLK_SPI0 (BIT(11))
  119. #define _CLK_SPI1 (BIT(12))
  120. #define _CLK_GPIO (BIT(13))
  121. #define _CLK_QDEC (BIT(15))
  122. #define _CLK_ADCC (BIT(17))
  123. #define _CLK_PWM (BIT(18))
  124. #define _CLK_SPIF (BIT(19))
  125. #define _CLK_VOC (BIT(20))
  126. #define _CLK_TIMER5 (BIT(21))
  127. #define _CLK_TIMER6 (BIT(22))
  128. #define _CLK_UART1 (BIT(25))
  129. //SW_CLK1 -->0x4000f014
  130. #define _CLK_M0_CPU (BIT(0))
  131. #define _CLK_BB (BIT(3))
  132. #define _CLK_TIMER (BIT(4))
  133. #define _CLK_WDT (BIT(5))
  134. #define _CLK_COM (BIT(6))
  135. #define _CLK_KSCAN (BIT(7))
  136. #define _CLK_BBREG (BIT(9))
  137. #define _CLK_TIMER1 (BIT(21))
  138. #define _CLK_TIMER2 (BIT(22))
  139. #define _CLK_TIMER3 (BIT(23))
  140. #define _CLK_TIMER4 (BIT(24))
  141. #define BB_IRQ_HANDLER V4_IRQ_HANDLER
  142. #define KSCAN_IRQ_HANDLER V5_IRQ_HANDLER
  143. #define RTC_IRQ_HANDLER V6_IRQ_HANDLER
  144. #define CP_COM_IRQ_HANDLER V7_IRQ_HANDLER
  145. #define AP_COM_IRQ_HANDLER V8_IRQ_HANDLER
  146. #define WDT_IRQ_HANDLER V10_IRQ_HANDLER
  147. #define UART0_IRQ_HANDLER V11_IRQ_HANDLER
  148. #define I2C0_IRQ_HANDLER V12_IRQ_HANDLER
  149. #define I2C1_IRQ_HANDLER V13_IRQ_HANDLER
  150. #define SPI0_IRQ_HANDLER V14_IRQ_HANDLER
  151. #define SPI1_IRQ_HANDLER V15_IRQ_HANDLER
  152. #define GPIO_IRQ_HANDLER V16_IRQ_HANDLER
  153. #define UART1_IRQ_HANDLER V17_IRQ_HANDLER
  154. #define SPIF_IRQ_HANDLER V18_IRQ_HANDLER
  155. #define DMAC_IRQ_HANDLER V19_IRQ_HANDLER
  156. #define TIM1_IRQ_HANDLER V20_IRQ_HANDLER
  157. #define TIM2_IRQ_HANDLER V21_IRQ_HANDLER
  158. #define TIM3_IRQ_HANDLER V22_IRQ_HANDLER
  159. #define TIM4_IRQ_HANDLER V23_IRQ_HANDLER
  160. #define TIM5_IRQ_HANDLER V24_IRQ_HANDLER
  161. #define TIM6_IRQ_HANDLER V25_IRQ_HANDLER
  162. #define AES_IRQ_HANDLER V28_IRQ_HANDLER
  163. #define ADCC_IRQ_HANDLER V29_IRQ_HANDLER
  164. #define QDEC_IRQ_HANDLER V30_IRQ_HANDLER
  165. /*******************************************************************************
  166. * TYPEDEFS
  167. */
  168. /******************************************************************************/
  169. /* Device Specific Peripheral registers structures */
  170. /******************************************************************************/
  171. typedef struct{
  172. __IO uint32_t CH0_AP_MBOX; //0x00
  173. __IO uint32_t CH0_CP_MBOX; //0x04
  174. __IO uint32_t CH1_AP_MBOX; //0x08
  175. __IO uint32_t CH1_CP_MBOX; //0x0c
  176. __IO uint32_t AP_STATUS; //0x10
  177. __IO uint32_t CP_STATUS; //0x14
  178. __IO uint32_t AP_INTEN; //0x18
  179. __IO uint32_t CP_INTEN; //0x1c
  180. __IO uint32_t remap; //0x20
  181. __IO uint32_t RXEV_EN; //0x24
  182. __IO uint32_t STCALIB; //0x28
  183. __IO uint32_t PERI_MASTER_SELECT; //0x2c
  184. }AP_COM_TypeDef;
  185. typedef struct{
  186. __IO uint32_t CTRL0;//0x40
  187. __IO uint32_t CTRL1;//0x44
  188. uint32_t reserverd[13];
  189. __IO uint32_t REMAP_TABLE;//0x7c
  190. __IO uint32_t REMAP_CTRL[32];//0x80
  191. }AP_CACHE_TypeDef;
  192. typedef struct
  193. {
  194. __IO uint8_t CR; //0x0
  195. uint8_t RESERVED0[3];
  196. __IO uint32_t TORR; //0x4
  197. __O uint32_t CCVR; //0x8
  198. __IO uint32_t CRR; //0xc
  199. uint8_t STAT; //0x10
  200. uint8_t reserverd1[3];
  201. __IO uint8_t EOI; //0x14
  202. uint8_t reserverd2[3];
  203. } AP_WDT_TypeDef;
  204. typedef struct
  205. {
  206. __IO uint32_t SW_RESET0; //0x0
  207. __IO uint32_t SW_RESET1; //0x4
  208. __IO uint32_t SW_CLK; //0x8
  209. __IO uint32_t SW_RESET2; //0xc
  210. __IO uint32_t SW_RESET3; //0x10
  211. __IO uint32_t SW_CLK1; //0x14
  212. __IO uint32_t APB_CLK; //0x18
  213. __IO uint32_t APB_CLK_UPDATE; //0x1c
  214. __IO uint32_t CACHE_CLOCK_GATE;//0x20
  215. __IO uint32_t CACHE_RST;//0x24
  216. __IO uint32_t CACHE_BYPASS;//0x28
  217. } AP_PCR_TypeDef;
  218. typedef struct
  219. {
  220. __IO uint32_t LoadCount; //0x0
  221. __IO uint32_t CurrentCount; //0x4
  222. __IO uint32_t ControlReg; //0x8
  223. __IO uint32_t EOI; //0xc
  224. __IO uint32_t status; //0x10
  225. } AP_TIM_TypeDef;
  226. typedef struct
  227. {
  228. __IO uint32_t IntStatus;
  229. __IO uint32_t EOI;
  230. __IO uint32_t unMaskIntStatus;
  231. __IO uint32_t version;
  232. } AP_TIM_SYS_TypeDef;
  233. #if defined ( __CC_ARM )
  234. #pragma anon_unions
  235. #endif
  236. /*------------- Universal Asynchronous Receiver Transmitter (UARTx) -----------*/
  237. typedef struct
  238. {
  239. union
  240. {
  241. __I uint8_t RBR;
  242. __IO uint8_t THR;
  243. __IO uint8_t DLL;
  244. uint32_t RESERVED0; //0x0
  245. };
  246. union
  247. {
  248. __IO uint8_t DLM;
  249. __IO uint32_t IER; //0x4
  250. };
  251. union
  252. {
  253. __I uint32_t IIR; //0x8
  254. __IO uint8_t FCR;
  255. };
  256. __IO uint8_t LCR; //0xc
  257. uint8_t RESERVED1[3];//Reserved
  258. __IO uint32_t MCR; //0x10
  259. __I uint8_t LSR; //0x14
  260. uint8_t RESERVED2[3];//Reserved
  261. __IO uint32_t MSR; //0x18
  262. __IO uint8_t SCR; //0x1c
  263. uint8_t RESERVED3[3];//Reserved
  264. __IO uint32_t LPDLL; //0x20
  265. __IO uint32_t LPDLH; //0x24
  266. __IO uint32_t recerved[2];
  267. union
  268. {
  269. __IO uint32_t SRBR[16]; // 0x30~60xc
  270. __IO uint32_t STHR[16];
  271. };
  272. __IO uint32_t FAR; //0x70
  273. __IO uint32_t TFR; //0x74
  274. __IO uint32_t RFW; // 0x78
  275. __IO uint32_t USR; // 0x7c
  276. __IO uint32_t TFL;
  277. __IO uint32_t RFL;
  278. __IO uint32_t SRR;
  279. __IO uint32_t SRTS;
  280. __IO uint32_t SBCR;
  281. __IO uint32_t SDMAM;
  282. __IO uint32_t SFE;
  283. __IO uint32_t SRT;
  284. __IO uint32_t STET; //0xa0
  285. __IO uint32_t HTX;
  286. __IO uint32_t DMASA; //0xa8
  287. __IO uint32_t reserved[18];
  288. __IO uint32_t CPR; //0xf4
  289. __IO uint32_t UCV;
  290. __IO uint32_t CTR;
  291. }AP_UART_TypeDef;
  292. /*------------- Inter-Integrated Circuit (I2C) setup by zjp-------------------------------*/
  293. typedef struct
  294. {
  295. __IO uint32_t IC_CON;
  296. __IO uint32_t IC_TAR;
  297. __IO uint32_t IC_SAR;
  298. __IO uint32_t IC_HS_MADDR;
  299. __IO uint32_t IC_DATA_CMD; //0x10
  300. __IO uint32_t IC_SS_SCL_HCNT;
  301. __IO uint32_t IC_SS_SCL_LCNT;
  302. __IO uint32_t IC_FS_SCL_HCNT;
  303. __IO uint32_t IC_FS_SCL_LCNT; //0x20
  304. __IO uint32_t IC_HS_SCL_HCNT;
  305. __IO uint32_t IC_HS_SCL_LCNT;
  306. __IO uint32_t IC_INTR_STAT;
  307. __IO uint32_t IC_INTR_MASK; //0x30
  308. __IO uint32_t IC_RAW_INTR_STAT;
  309. __IO uint32_t IC_RX_TL;
  310. __IO uint32_t IC_TX_TL;
  311. __IO uint32_t IC_CLR_INTR; //0x40
  312. __IO uint32_t IC_CLR_UNDER;
  313. __IO uint32_t IC_CLR_RX_OVER;
  314. __IO uint32_t IC_CLR_TX_OVER;
  315. __IO uint32_t IC_CLR_RD_REG; //0x50
  316. __IO uint32_t IC_CLR_TX_ABRT;
  317. __IO uint32_t IC_CLR_RX_DONE;
  318. __IO uint32_t IC_CLR_ACTIVITY;
  319. __IO uint32_t IC_CLR_STOP_DET; //0x60
  320. __IO uint32_t IC_CLR_START_DET;
  321. __IO uint32_t IC_CLR_GEN_CALL;
  322. __IO uint32_t IC_ENABLE;
  323. __IO uint32_t IC_STATUS; //0x70
  324. __IO uint32_t IC_TXFLR;
  325. __IO uint32_t IC_RXFLR;
  326. __IO uint32_t IC_SDA_HOLD;
  327. __IO uint32_t IC_TX_ABRT_SOURCE; //0x80
  328. __IO uint32_t IC_SLV_DATA_NACK_ONLY;
  329. __IO uint32_t IC_DMA_CR;
  330. __IO uint32_t IC_DMA_TDLR;
  331. __IO uint32_t IC_DMA_RDLR; //0x90
  332. __IO uint32_t IC_SDA_SETUP;
  333. __IO uint32_t IC_ACK_GENERAL_CALL;
  334. __IO uint32_t IC_ENABLE_STATUS;
  335. __IO uint32_t IC_FS_SPKLEN; //0xa0
  336. __IO uint32_t IC_HS_SPKLEN;
  337. } AP_I2C_TypeDef;
  338. /*------------- Inter IC Sound (I2S) -----------------------------------------*/
  339. typedef struct
  340. {
  341. __IO uint32_t IER;
  342. __IO uint32_t IRER;
  343. __IO uint32_t ITER;
  344. __IO uint32_t CER;
  345. __IO uint32_t CCR;
  346. __IO uint32_t RXFFR;
  347. __IO uint32_t TXFFR;
  348. }AP_I2S_BLOCK_TypeDef;
  349. typedef struct
  350. {
  351. union{
  352. __IO uint32_t LRBR; //0x20
  353. __IO uint32_t LTHR; //0x20
  354. };
  355. union{
  356. __IO uint32_t RRBR; // 0x24
  357. __IO uint32_t RTHR; //0x24
  358. };
  359. __IO uint32_t RER; //0x28
  360. __IO uint32_t TER; //0x2c
  361. __IO uint32_t RCR; //0x30
  362. __IO uint32_t TCR; //0x34
  363. __IO uint32_t ISR; //0x38
  364. __IO uint32_t IMR; //0x3c
  365. __IO uint32_t ROR; //0x40
  366. __IO uint32_t TOR; //0x44
  367. __IO uint32_t RFCR; //0x48
  368. __IO uint32_t TFCR; //0x4c
  369. __IO uint32_t RFF; //0x50
  370. __IO uint32_t TFF; //0x54
  371. } AP_I2S_TypeDef;
  372. /*------------- General Purpose Input/Output (GPIO) --------------------------*/
  373. typedef struct
  374. {
  375. __IO uint32_t swporta_dr; //0x00
  376. __IO uint32_t swporta_ddr; //0x04
  377. __IO uint32_t swporta_ctl; //0x08
  378. uint32_t reserved8[9]; //0x18-0x2c portC&D
  379. __IO uint32_t inten; //0x30
  380. __IO uint32_t intmask; //0x34
  381. __IO uint32_t inttype_level; //0x38
  382. __IO uint32_t int_polarity; //0x3c
  383. __I uint32_t int_status; //0x40
  384. __IO uint32_t raw_instatus; //0x44
  385. __IO uint32_t debounce; //0x48
  386. __O uint32_t porta_eoi; //0x4c
  387. __I uint32_t ext_porta; //0x50
  388. uint32_t reserved9[3]; //0x58 0x5c
  389. __IO uint32_t ls_sync; //0x60
  390. __I uint32_t id_code; //0x64
  391. uint32_t reserved10[1]; //0x68
  392. __I uint32_t ver_id_code; //0x6c
  393. __I uint32_t config_reg2; //0x70
  394. __I uint32_t config_reg1; //0x74
  395. } AP_GPIO_TypeDef;
  396. /*-------------------- (SPI) --------------------------------*/
  397. typedef struct
  398. {
  399. __IO uint16_t CR0; //0x0 /*!< Offset: 0x000 Control Register 0 (R/W) */
  400. uint16_t reserved1;
  401. __IO uint16_t CR1; //0x04 /*!< Offset: 0x004 Control Register 1 (R/W) */
  402. uint16_t reserved2;
  403. __IO uint8_t SSIEN; //0x08
  404. uint8_t reserved3[3];
  405. __IO uint8_t MWCR; // 0x0c
  406. uint8_t reserved4[3];
  407. __IO uint8_t SER; //0x10
  408. uint8_t reserved5[3];
  409. __IO uint32_t BAUDR; //0x14
  410. __IO uint32_t TXFTLR; //0x18
  411. __IO uint32_t RXFTLR; //0x1c
  412. __O uint32_t TXFLR; //0x20
  413. __O uint32_t RXFLR; //0x24
  414. __IO uint8_t SR; //0x28
  415. uint8_t reserved7[3];
  416. __IO uint32_t IMR; //0x2c
  417. __IO uint32_t ISR; //0x30
  418. __IO uint32_t RISR; //0x34
  419. __IO uint32_t TXOICR; //0x38
  420. __IO uint32_t RXOICR; //0x3c
  421. __IO uint32_t RXUICR; //0x40
  422. __IO uint32_t MSTICR; //0x44
  423. __IO uint32_t ICR; //0x48
  424. __IO uint32_t DMACR; //0x4c
  425. __IO uint32_t DMATDLR; //0x50
  426. __IO uint32_t DMARDLR; //0x54
  427. __IO uint32_t IDR; //0x5c
  428. __IO uint32_t SSI_COM_VER; //0x5c
  429. __IO uint16_t DataReg;
  430. } AP_SSI_TypeDef;
  431. typedef struct{
  432. __IO uint32_t Analog_IO_en;//0x00
  433. __IO uint32_t SPI_debug_en;//0x04
  434. __IO uint32_t debug_mux_en;//0x08
  435. __IO uint32_t full_mux0_en;//0x0c
  436. __IO uint32_t full_mux1_en;//0x10 reserved in some soc
  437. __IO uint32_t gpio_pad_en; //0x14
  438. __IO uint32_t gpio_sel[9]; //0x18
  439. __IO uint32_t pad_pe0;//0x3c
  440. __IO uint32_t pad_pe1;//0x40
  441. __IO uint32_t pad_ps0;//0x44
  442. __IO uint32_t pad_ps1;//0x48
  443. __IO uint32_t keyscan_in_en;//0x4c
  444. __IO uint32_t keyscan_out_en;//0x50
  445. }IOMUX_TypeDef;
  446. typedef struct{
  447. __IO uint32_t PWROFF; //0x00
  448. __IO uint32_t PWRSLP; //0x04
  449. __IO uint32_t IOCTL[3]; //0x08 0x0c 0x10
  450. __IO uint32_t PMCTL0; //0x14
  451. __IO uint32_t PMCTL1; //0x18
  452. __IO uint32_t PMCTL2_0; //0x1c
  453. __IO uint32_t PMCTL2_1; //0x20
  454. __IO uint32_t RTCCTL; //0x24
  455. __IO uint32_t RTCCNT; //0x28
  456. __IO uint32_t RTCCC0; //0x2c
  457. __IO uint32_t RTCCC1; //0x30
  458. __IO uint32_t RTCCC2; //0x34
  459. __IO uint32_t RTCFLAG; //0x38
  460. __IO uint32_t reserved[25];
  461. __IO uint32_t REG_S9; //0xa0
  462. __IO uint32_t REG_S10; //0xa4
  463. __IO uint32_t REG_S11; //0xa8
  464. __IO uint32_t IDLE_REG; //0xac
  465. __IO uint32_t GPIO_WAKEUP_SRC[2]; //0xb0 b4
  466. __IO uint32_t PCLK_CLK_GATE; //0xb8
  467. __IO uint32_t XTAL_16M_CTRL; //0xbc
  468. __IO uint32_t SLEEP_R[4]; //0xc0 c4 c8 cc
  469. }AP_AON_TypeDef;
  470. typedef struct{
  471. __IO uint32_t RTCCTL; //0x24
  472. __IO uint32_t RTCCNT; //0x28
  473. __IO uint32_t RTCCC0; //0x2c
  474. __IO uint32_t RTCCC1; //0x30
  475. __IO uint32_t RTCCC2; //0x34
  476. __IO uint32_t RTCFLAG; //0x38
  477. }AP_RTC_TypeDef;
  478. typedef struct{
  479. __IO uint32_t io_wu_mask_31_0; //0xa0
  480. __IO uint32_t io_wu_mask_34_32; //0xa4
  481. }AP_Wakeup_TypeDef;
  482. typedef struct{
  483. __IO uint32_t CLKSEL; //0x3c
  484. __IO uint32_t CLKHF_CTL0; //0x40
  485. __IO uint32_t CLKHF_CTL1; //0x44
  486. __IO uint32_t ANA_CTL; //0x48
  487. __IO uint32_t mem_0_1_dvs; //0x4c
  488. __IO uint32_t mem_2_3_4_dvs; //0x50
  489. __IO uint32_t efuse_cfg; //0x54
  490. __IO uint32_t chip_state; //0x58
  491. __IO uint32_t cal_rw; //0x5c
  492. __IO uint32_t cal_ro0; //0x60
  493. __IO uint32_t cal_ro1; //0x64
  494. __IO uint32_t cal_ro2; //0x68
  495. __IO uint32_t ADC_CTL0; //0x6c
  496. __IO uint32_t ADC_CTL1; //0x70
  497. __IO uint32_t ADC_CTL2; //0x74
  498. __IO uint32_t ADC_CTL3; //0x78
  499. __IO uint32_t ADC_CTL4; //0x7c
  500. uint32_t reserved1[48];
  501. __IO uint32_t EFUSE_PROG[2];//0x140
  502. uint32_t reserved2[6];
  503. __IO uint32_t EFUSE0[2];//0x160
  504. __IO uint32_t EFUSE1[2];//0x168
  505. __IO uint32_t EFUSE2[2];//0x170
  506. __IO uint32_t EFUSE3[2];//0x178
  507. __IO uint32_t SECURTY_STATE;//0x180
  508. }AP_PCRM_TypeDef;
  509. typedef struct{
  510. __IO uint32_t enable; //0x00
  511. __IO uint32_t reserve0[2]; //0x04~0x08
  512. __IO uint32_t control_1; //0x0c
  513. __IO uint32_t control_2; //0x10
  514. __IO uint32_t control_3; //0x14
  515. __IO uint32_t control_4; //0x18
  516. __IO uint32_t compare_reset; //0x1c
  517. __IO uint32_t int_pointer_ch0_ch3; //0x20
  518. __IO uint32_t int_pointer_ch4_ch7; //0x24
  519. __IO uint32_t reserve1[3]; //0x28~0x30
  520. __IO uint32_t intr_mask; //0x34
  521. __IO uint32_t intr_clear; //0x38
  522. __IO uint32_t intr_status; //0x3c
  523. __IO uint32_t compare_cfg[8]; //0x40~5c
  524. }AP_ADCC_TypeDef;
  525. typedef struct{
  526. __IO uint32_t config; //0x0,QSPI Configuration Register,R/W
  527. __IO uint32_t read_instr; //0x4,Device Read Instruction Register,R/W
  528. __IO uint32_t write_instr; //0x8,Device Write Instruction Register,R/W
  529. __IO uint32_t delay; //0xC,QSPI Device Delay Register,R/W
  530. __IO uint32_t rddata_capture; //0x10,Read Data Capture Register,R/W
  531. __IO uint32_t dev_size; //0x14,Device Size Register,R/W
  532. __IO uint32_t sram_part; //0x18,SRAM Partition Register,R/W
  533. __IO uint32_t indirect_ahb_addr_trig; //0x1C,Indirect AHB Address Trigger Register,R/W
  534. __IO uint32_t dma_peripheral; //0x20,DMA Peripheral Register,R/W
  535. __IO uint32_t remap; //0x24,Remap Address Register,R/W
  536. __IO uint32_t mode_bit; //0x28,Mode Bit Register,R/W
  537. __IO uint32_t sram_fill_level; //0x2C,SRAM Fill Level Register,RO
  538. __IO uint32_t tx_threshold; //0x30,TX Threshold Register,R/W
  539. __IO uint32_t rx_threshold; //0x34,RX Threshold Register,R/W
  540. __IO uint32_t wr_completion_ctrl; //0x38,Write Completion Control Register,R/W
  541. __IO uint32_t poll_expire; //0x3C,Polling Expiration Register,R/W
  542. __IO uint32_t int_status; //0x40,Interrupt Status Register,R/W
  543. __IO uint32_t int_mask; //0x44,Interrupt Mask,R/W
  544. __I uint32_t n1[2]; //0x48~0x4c,Empty
  545. __IO uint32_t low_wr_protection; //0x50,Lower Write Protection Register,R/W
  546. __IO uint32_t up_wr_protection; //0x54,Upper Write Protection Register,R/W
  547. __IO uint32_t wr_protection; //0x58,Write Protection Register,R/W
  548. __I uint32_t n2; //0x5c,Empty
  549. __IO uint32_t indirect_rd; //0x60,Indirect Read Transfer Register,R/W
  550. __IO uint32_t indirect_rd_watermark; //0x64,Indirect Read Transfer Watermark Register,R/W
  551. __IO uint32_t indirect_rd_start_addr; //0x68,Indirect Read Transfer Start Address Register,R/W
  552. __IO uint32_t indirect_rd_num; //0x6C,Indirect Read Transfer Number Bytes Register,R/W
  553. __IO uint32_t indirect_wr; //0x70,Indirect Write Transfer Register,R/W
  554. __IO uint32_t indirect_wr_watermark; //0x74,Indirect Write Transfer Watermark Register,R/W
  555. __IO uint32_t indirect_wr_start_addr; //0x78,Indirect Write Transfer Start Address Register,R/W
  556. __IO uint32_t indirect_wr_cnt; //0x7C,Indirect Write Transfer Count Register,R/W
  557. __IO uint32_t indirect_ahb_trig_addr_range; //0x80,Indirect AHB Trigger Address Range Register,R/W
  558. __I uint32_t n3[3]; //0x84~0x8c,Empty
  559. __IO uint32_t fcmd; //0x90,Flash Command Register,R/W
  560. __IO uint32_t fcmd_addr; //0x94,Flash Command Address Registers,R/W
  561. __I uint32_t n4[2]; //0x98~0x9c,Empty
  562. __IO uint32_t fcmd_rddata[2]; //0xA0,Flash Command Read Data Register (low-a0, up-a4),RO
  563. __IO uint32_t fcmd_wrdata[2]; //0xA8,Flash Command Write Data Register (low-a8, up-ac),R/W
  564. __IO uint32_t poll_fstatus; //0xB0,Polling Flash Status Register,RO
  565. //__IO uint32_t ; //0xFC,Module ID Register,RO
  566. }AP_SPIF_TypeDef;
  567. typedef struct{
  568. __IO uint32_t ctrl0; //0xc0
  569. __IO uint32_t ctrl1; //0xc4
  570. __IO uint32_t mk_in_en; //0xc8
  571. __IO uint32_t mkc[6]; //0xcc~0xe0
  572. }AP_KSCAN_TypeDef;
  573. typedef struct{
  574. __IO uint32_t pwmen;
  575. }AP_PWM_TypeDef;
  576. typedef struct{
  577. __IO uint32_t ctrl0;
  578. __IO uint32_t ctrl1;
  579. }AP_PWMCTRL_TypeDef;
  580. typedef struct{
  581. __IO uint32_t SAR;
  582. __IO uint32_t SAR_H;
  583. __IO uint32_t DAR;
  584. __IO uint32_t DAR_H;
  585. __IO uint32_t LLP;
  586. __IO uint32_t LLP_H;
  587. __IO uint32_t CTL;
  588. __IO uint32_t CTL_H;
  589. __IO uint32_t SSTAT;
  590. __IO uint32_t SSTAT_H;
  591. __IO uint32_t DSTAT;
  592. __IO uint32_t DSTAT_L;
  593. __IO uint32_t SSTATAR;
  594. __IO uint32_t SSTATAR_H;
  595. __IO uint32_t DSTATAR;
  596. __IO uint32_t DSTATAR_H;
  597. __IO uint32_t CFG;
  598. __IO uint32_t CFG_H;
  599. __IO uint32_t rsv[4];
  600. }AP_DMA_CH_TypeDef;
  601. typedef struct{
  602. __IO uint32_t RawTfr; //0x2c0
  603. __IO uint32_t RawTfr_H; //0x2c4
  604. __IO uint32_t RawBlock; //0x2c8
  605. __IO uint32_t RawBlock_H; //0x2cc
  606. __IO uint32_t RawSrcTran; //0x2d0
  607. __IO uint32_t RawSrcTran_H; //0x2d4
  608. __IO uint32_t RawDstTran; //0x2d8
  609. __IO uint32_t RawDstTran_H; //0x2dc
  610. __IO uint32_t RawErr; //0x2e0
  611. __IO uint32_t RawErr_H; //0x2e4
  612. __IO uint32_t StatusTfr; //0x2e8
  613. __IO uint32_t StatusTfr_H; //0x2ec
  614. __IO uint32_t StatusBlock; //0x2f0
  615. __IO uint32_t StatusBlock_H; //0x2f4
  616. __IO uint32_t StatusSrcTran; //0x2f8
  617. __IO uint32_t StatusSrcTran_H; //0x2fc
  618. __IO uint32_t StatusDstTran; //0x300
  619. __IO uint32_t StatusDstTran_H; //0x304
  620. __IO uint32_t StatusErr; //0x308
  621. __IO uint32_t StatusErr_H; //0x30c
  622. __IO uint32_t MaskTfr; //0x310
  623. __IO uint32_t MaskTfr_H; //0x314
  624. __IO uint32_t MaskBlock; //0x318
  625. __IO uint32_t MaskBlock_H; //0x31c
  626. __IO uint32_t MaskSrcTran; //0x320
  627. __IO uint32_t MaskSrcTran_H; //0x324
  628. __IO uint32_t MaskDstTran; //0x328
  629. __IO uint32_t MaskDstTran_H; //0x32c
  630. __IO uint32_t MaskErr; //0x330
  631. __IO uint32_t MaskErr_H; //0x334
  632. __IO uint32_t ClearTfr; //0x338
  633. __IO uint32_t ClearTfr_H; //0x33c
  634. __IO uint32_t ClearBlock; //0x340
  635. __IO uint32_t ClearBlock_H; //0x344
  636. __IO uint32_t ClearSrcTran; //0x348
  637. __IO uint32_t ClearSrcTran_H; //0x34c
  638. __IO uint32_t ClearDstTran; //0x350
  639. __IO uint32_t ClearDstTran_H; //0x354
  640. __IO uint32_t ClearErr; //0x358
  641. __IO uint32_t ClearErr_H; //0x35c
  642. __IO uint32_t StatusInt; //0x360
  643. __IO uint32_t StatusInt_H; //0x364
  644. }AP_DMA_INT_TypeDef;
  645. typedef struct{
  646. __IO uint32_t ReqSrcReg; //0x368
  647. __IO uint32_t ReqSrcReg_H; //0x36c
  648. __IO uint32_t ReqDstReg; //0x370
  649. __IO uint32_t ReqDstReg_H; //0x374
  650. __IO uint32_t SglReqSrcReg; //0x378
  651. __IO uint32_t SglReqSrcReg_H; //0x37c
  652. __IO uint32_t SglReqDstReg; //0x380
  653. __IO uint32_t SglReqDstReg_H; //0x384
  654. __IO uint32_t LstSrcReg; //0x388
  655. __IO uint32_t LstSrcReg_H; //0x38c
  656. __IO uint32_t LstDstReg; //0x390
  657. __IO uint32_t LstDstReg_H; //0x394
  658. }AP_DMA_SW_HANDSHAKE_TypeDef;
  659. typedef struct{
  660. __IO uint32_t DmaCfgReg; //0x398
  661. __IO uint32_t DmaCfgReg_H; //0x39c
  662. __IO uint32_t ChEnReg; //0x3a0
  663. __IO uint32_t ChEnReg_H; //0x3a4
  664. __IO uint32_t DmaIdReg; //0x3a8
  665. __IO uint32_t DmaIdReg_H; //0x3ac
  666. __IO uint32_t DmaTestReg; //0x3b0
  667. __IO uint32_t DmaTestReg_H; //0x3b4
  668. __IO uint32_t rsv1[4];
  669. __IO uint32_t DMA_COMP_PARAMS_6; //0x3c8
  670. __IO uint32_t DMA_COMP_PARAMS_6_H; //0x3cc
  671. __IO uint32_t DMA_COMP_PARAMS_5; //0x3d0
  672. __IO uint32_t DMA_COMP_PARAMS_5_H; //0x3d4
  673. __IO uint32_t DMA_COMP_PARAMS_4; //0x3d8
  674. __IO uint32_t DMA_COMP_PARAMS_4_H; //0x3dc
  675. __IO uint32_t DMA_COMP_PARAMS_3; //0x3e0
  676. __IO uint32_t DMA_COMP_PARAMS_3_H; //0x3e4
  677. __IO uint32_t DMA_COMP_PARAMS_2; //0x3e8
  678. __IO uint32_t DMA_COMP_PARAMS_2_H; //0x3ec
  679. __IO uint32_t DMA_COMP_PARAMS_1; //0x3f0
  680. __IO uint32_t DMA_COMP_PARAMS_1_H; //0x3f4
  681. __IO uint32_t DMA_ID; //0x3f8
  682. __IO uint32_t DMA_ID_H; //0x3fc
  683. }AP_DMA_MISC_TypeDef;
  684. #if defined ( __CC_ARM )
  685. #pragma no_anon_unions
  686. #endif
  687. /******************************************************************************/
  688. /* Peripheral memory map(AP) */
  689. /******************************************************************************/
  690. /* Base addresses */
  691. #define AP_APB0_BASE (0x40000000UL)
  692. #define SPIF_BASE_ADDR (0x11000000) /*spif*/
  693. #define AP_PCR_BASE (AP_APB0_BASE + 0x0000)/*pcr*//* APB0 peripherals */
  694. #define AP_TIM1_BASE (AP_APB0_BASE + 0x1000)
  695. #define AP_TIM2_BASE (AP_APB0_BASE + 0x1014)
  696. #define AP_TIM3_BASE (AP_APB0_BASE + 0x1028)
  697. #define AP_TIM4_BASE (AP_APB0_BASE + 0x103c)
  698. #define AP_TIM5_BASE (AP_APB0_BASE + 0x1050)
  699. #define AP_TIM6_BASE (AP_APB0_BASE + 0x1064)
  700. #define AP_TIM_SYS_BASE (AP_APB0_BASE + 0x10a0)
  701. #define AP_WDT_BASE (AP_APB0_BASE + 0x2000)
  702. #define AP_COM_BASE (AP_APB0_BASE + 0x3000)/*com*/
  703. #define AP_IOMUX_BASE (AP_APB0_BASE + 0x3800)/*iomux*/
  704. #define AP_UART0_BASE (AP_APB0_BASE + 0x4000)/*uart0*/
  705. #define AP_I2C0_BASE (AP_APB0_BASE + 0x5000)/*i2c0*/
  706. #define AP_I2C1_BASE (AP_APB0_BASE + 0x5800)/*i2c1*/
  707. #define AP_SPI0_BASE (AP_APB0_BASE + 0x6000)/*spi0*/
  708. #define AP_SPI1_BASE (AP_APB0_BASE + 0x7000)/*spi1*/
  709. #define AP_GPIOA_BASE (AP_APB0_BASE + 0x8000)/*gpio*/
  710. #define AP_UART1_BASE (AP_APB0_BASE + 0x9000)/*uart1*/
  711. #define AP_DMIC_BASE (AP_APB0_BASE + 0xA000)
  712. #define AP_QDEC_BASE (AP_APB0_BASE + 0xB000)/*qdec*/
  713. #define AP_CACHE_BASE (AP_APB0_BASE + 0xC000)
  714. #define AP_SPIF_BASE (AP_APB0_BASE + 0xC800)/*spif*/
  715. #define AP_KSCAN_BASE (AP_APB0_BASE + 0xD0C0)/*kscan*/
  716. #define AP_PWM_BASE (AP_APB0_BASE + 0xE000)/*pwm*/
  717. #define AP_AON_BASE (AP_APB0_BASE + 0xF000)/*aon*/
  718. #define AP_RTC_BASE (AP_APB0_BASE + 0xF024)/*rtc*/
  719. #define AP_PCRM_BASE (AP_APB0_BASE + 0xF03c)/*pcrm*/
  720. #define AP_WAKEUP_BASE (AP_APB0_BASE + 0xF0a0)/*wakeup*/
  721. #define AP_DMAC_BASE (AP_APB0_BASE + 0x10000)/*dmac*/
  722. #define ADCC_BASE_ADDR (AP_APB0_BASE + 0x50000)/*adcc*/
  723. /*bb_top*/
  724. /*linklayer*/
  725. #define SRAM0_BASE_ADDRESS 0x1FFF0000
  726. #define SRAM1_BASE_ADDRESS 0x1FFF4000
  727. #define SRAM2_BASE_ADDRESS 0x1FFF8000
  728. /////////////////////////////////////////////////////////////
  729. #define AP_PCR ((AP_PCR_TypeDef *) AP_PCR_BASE)
  730. #define AP_TIM1 ((AP_TIM_TypeDef *) AP_TIM1_BASE)
  731. #define AP_TIM2 ((AP_TIM_TypeDef *) AP_TIM2_BASE)
  732. #define AP_TIM3 ((AP_TIM_TypeDef *) AP_TIM3_BASE)
  733. #define AP_TIM4 ((AP_TIM_TypeDef *) AP_TIM4_BASE)
  734. #define AP_TIM5 ((AP_TIM_TypeDef *) AP_TIM5_BASE)
  735. #define AP_TIM6 ((AP_TIM_TypeDef *) AP_TIM6_BASE)
  736. #define AP_TIMS ((AP_TIM_SYS_TypeDef *) AP_TIM_SYS_BASE)
  737. #define AP_WDT ((AP_WDT_TypeDef *) AP_WDT_BASE)
  738. #define AP_COM ((AP_COM_TypeDef *) AP_COM_BASE)
  739. #define AP_IOMUX ((IOMUX_TypeDef *) AP_IOMUX_BASE)
  740. #define AP_UART0 ((AP_UART_TypeDef *) AP_UART0_BASE)
  741. #define AP_I2C0 ((AP_I2C_TypeDef *) AP_I2C0_BASE)
  742. #define AP_I2C1 ((AP_I2C_TypeDef *) AP_I2C1_BASE)
  743. #define AP_SPI0 ((AP_SSI_TypeDef *) AP_SPI0_BASE)
  744. #define AP_SPI1 ((AP_SSI_TypeDef *) AP_SPI1_BASE)
  745. #define AP_GPIO ((AP_GPIO_TypeDef *) AP_GPIOA_BASE)
  746. #define AP_UART1 ((AP_UART_TypeDef *) AP_UART1_BASE)
  747. #define AP_CACHE ((AP_CACHE_TypeDef *) AP_CACHE_BASE)
  748. #define AP_SPIF ((AP_SPIF_TypeDef *) AP_SPIF_BASE)
  749. #define AP_KSCAN ((AP_KSCAN_TypeDef *) AP_KSCAN_BASE)
  750. #define AP_PWM ((AP_PWM_TypeDef *) AP_PWM_BASE)
  751. #define AP_PWM_CTRL(n) ((AP_PWMCTRL_TypeDef *) (AP_PWM_BASE + 4 + n*12))
  752. #define AP_AON ((AP_AON_TypeDef *) AP_AON_BASE)
  753. #define AP_RTC ((AP_RTC_TypeDef *) AP_RTC_BASE)
  754. #define AP_PCRM ((AP_PCRM_TypeDef *) AP_PCRM_BASE)
  755. #define AP_WAKEUP ((AP_Wakeup_TypeDef*) AP_WAKEUP_BASE)
  756. #define AP_ADCC ((AP_ADCC_TypeDef *) ADCC_BASE_ADDR)
  757. #define AP_DMA_CH_CFG(n) ((AP_DMA_CH_TypeDef *) (AP_DMAC_BASE+0x58*n))
  758. #define AP_DMA_INT ((AP_DMA_INT_TypeDef *) (AP_DMAC_BASE+0x2c0))
  759. #define AP_DMA_SW_HANDSHAKE ((AP_DMA_SW_HANDSHAKE_TypeDef *) (AP_DMAC_BASE+0x368))
  760. #define AP_DMA_MISC ((AP_DMA_MISC_TypeDef *) (AP_DMAC_BASE+0x398))
  761. /******************************************************************************/
  762. /* Peripheral memory map(CP) */
  763. /******************************************************************************/
  764. /* Base addresses */
  765. #define IRQ_PRIO_REALTIME 0
  766. #define IRQ_PRIO_HIGH 1
  767. #define IRQ_PRIO_HAL 2
  768. #define IRQ_PRIO_THREAD 3
  769. #define IRQ_PRIO_APP 3
  770. #endif