LPC8xx.h 32 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772
  1. // Attention please!
  2. // This is the header file for the LPC80x product family only.
  3. /****************************************************************************
  4. * $Id:: LPC8xx.h 6437 2012-10-31 11:06:06Z dep00694 $
  5. * Project: NXP LPC8xx software example
  6. *
  7. * Description:
  8. * CMSIS Cortex-M0+ Core Peripheral Access Layer Header File for
  9. * NXP LPC800 Device Series
  10. *
  11. ****************************************************************************
  12. * Software that is described herein is for illustrative purposes only
  13. * which provides customers with programming information regarding the
  14. * products. This software is supplied "AS IS" without any warranties.
  15. * NXP Semiconductors assumes no responsibility or liability for the
  16. * use of the software, conveys no license or title under any patent,
  17. * copyright, or mask work right to the product. NXP Semiconductors
  18. * reserves the right to make changes in the software without
  19. * notification. NXP Semiconductors also make no representation or
  20. * warranty that such application will be suitable for the specified
  21. * use without further testing or modification.
  22. * Permission to use, copy, modify, and distribute this software and its
  23. * documentation is hereby granted, under NXP Semiconductors'
  24. * relevant copyright in the software, without fee, provided that it
  25. * is used in conjunction with NXP Semiconductors microcontrollers. This
  26. * copyright, permission, and disclaimer notice must appear in all copies of
  27. * this code.
  28. ****************************************************************************/
  29. #ifndef __LPC8xx_H__
  30. #define __LPC8xx_H__
  31. #ifdef __cplusplus
  32. extern "C" {
  33. #endif
  34. /** @addtogroup LPC8xx_Definitions LPC8xx Definitions
  35. This file defines all structures and symbols for LPC8xx:
  36. - Registers and bitfields
  37. - peripheral base address
  38. - PIO definitions
  39. @{
  40. */
  41. /******************************************************************************/
  42. /* Processor and Core Peripherals */
  43. /******************************************************************************/
  44. /** @addtogroup LPC8xx_CMSIS LPC8xx CMSIS Definitions
  45. Configuration of the Cortex-M0+ Processor and Core Peripherals
  46. @{
  47. */
  48. /*
  49. * ==========================================================================
  50. * ---------- Interrupt Number Definition -----------------------------------
  51. * ==========================================================================
  52. */
  53. typedef enum IRQn
  54. {
  55. /****** Cortex-M0 Processor Exceptions Numbers ***************************************************/
  56. Reset_IRQn = -15, /*!< 1 Reset Vector, invoked on Power up and warm reset*/
  57. NonMaskableInt_IRQn = -14, /*!< 2 Non Maskable Interrupt */
  58. HardFault_IRQn = -13, /*!< 3 Cortex-M0 Hard Fault Interrupt */
  59. SVCall_IRQn = -5, /*!< 11 Cortex-M0 SV Call Interrupt */
  60. DebugMonitor_IRQn = -4, /*!< 12 Debug Monitor */
  61. PendSV_IRQn = -2, /*!< 14 Cortex-M0 Pend SV Interrupt */
  62. SysTick_IRQn = -1, /*!< 15 Cortex-M0 System Tick Interrupt */
  63. /****** LPC80x Specific Interrupt Numbers ********************************************************/
  64. SPI0_IRQn = 0, /*!< SPI0 */
  65. DAC0_IRQn = 2, /*!< DAC0 Interrupt */
  66. UART0_IRQn = 3, /*!< USART0 */
  67. UART1_IRQn = 4, /*!< USART1 */
  68. I2C1_IRQn = 7, /*!< I2C1 */
  69. I2C0_IRQn = 8, /*!< I2C0 */
  70. MRT_IRQn = 10, /*!< MRT */
  71. CMP_IRQn = 11, /*!< Analog Comparator /CapTouch */
  72. WDT_IRQn = 12, /*!< WDT */
  73. BOD_IRQn = 13, /*!< BOD */
  74. FLASH_IRQn = 14, /*!< FLASH */
  75. WKT_IRQn = 15, /*!< WKT Interrupt */
  76. ADC_SEQA_IRQn = 16, /*!< ADC Seq. A */
  77. ADC_SEQB_IRQn = 17, /*!< ADC Seq. B */
  78. ADC_THCMP_IRQn = 18, /*!< ADC Thresh Comp */
  79. ADC_OVR_IRQn = 19, /*!< ADC overrun */
  80. CTIMER0_IRQn = 23, /*!< Timer 0 Interrupt */
  81. PININT0_IRQn = 24, /*!< External Interrupt 0 */
  82. PININT1_IRQn = 25, /*!< External Interrupt 1 */
  83. PININT2_IRQn = 26, /*!< External Interrupt 2 */
  84. PININT3_IRQn = 27, /*!< External Interrupt 3 */
  85. PININT4_IRQn = 28, /*!< External Interrupt 4 */
  86. PININT5_IRQn = 29, /*!< External Interrupt 5 */
  87. PININT6_IRQn = 30, /*!< External Interrupt 6 */
  88. PININT7_IRQn = 31, /*!< External Interrupt 7 */
  89. } IRQn_Type;
  90. #define CAPT_IRQn CMP_IRQn
  91. /*
  92. * ==========================================================================
  93. * ----------- Processor and Core Peripheral Section ------------------------
  94. * ==========================================================================
  95. */
  96. /* Configuration of the Cortex-M0+ Processor and Core Peripherals */
  97. #define __CM0PLUS_REV 0x0001
  98. #define __MPU_PRESENT 0 /*!< MPU present or not */
  99. #define __NVIC_PRIO_BITS 2 /*!< Number of Bits used for Priority Levels */
  100. #define __Vendor_SysTickConfig 0 /*!< Set to 1 if different SysTick Config is used */
  101. /*@}*/ /* end of group LPC8xx_CMSIS */
  102. #include "core_cm0plus.h" /* Cortex-M0+ processor and core peripherals */
  103. #include "system.h" /* System Header */
  104. #if defined ( __CC_ARM )
  105. #pragma anon_unions // This is needed by the Keil compiler
  106. #endif
  107. /******************************************************************************/
  108. /* Device Specific Peripheral Registers structures */
  109. /******************************************************************************/
  110. //------------- System Control (SYSCON) --------------------------------------
  111. typedef struct
  112. {
  113. __IO uint32_t SYSMEMREMAP ; ///< (0x000) System memory remap
  114. __IO uint32_t RESERVED0[8] ; ///< (0x004 - 0x020)
  115. __IO uint32_t LPOSCCTRL ; ///< (0x024) Low power oscillator control
  116. __IO uint32_t FROOSCCTRL ; ///< (0x028) FRO oscillator control
  117. __IO uint32_t RESERVED2[3] ; ///< (0x02C - 0x034)
  118. __IO uint32_t SYSRSTSTAT ; ///< (0x038) System reset status 0
  119. __IO uint32_t RESERVED3[5] ; ///< (0x03C - 0x04C)
  120. __IO uint32_t MAINCLKSEL ; ///< (0x050) Main clock source select
  121. __IO uint32_t MAINCLKUEN ; ///< (0x054) Main clock source update enable
  122. __IO uint32_t SYSAHBCLKDIV ; ///< (0x058) System clock divider
  123. __IO uint32_t RESERVED4[1] ; ///< (0x05C)
  124. __IO uint32_t CAPTCLKSEL ; ///< (0x060) /* Added by Andrew Su 2018-01-18. */
  125. __IO uint32_t ADCCLKSEL ; ///< (0x064) ADC clock source select
  126. __IO uint32_t ADCCLKDIV ; ///< (0x068) ADC clock divider
  127. __IO uint32_t RESERVED5[4] ; ///< (0x06C - 0x078)
  128. __IO uint32_t LPOSCCLKEN ; ///< (0x07C)
  129. union {
  130. __IO uint32_t SYSAHBCLKCTRL[2] ;
  131. struct {
  132. __IO uint32_t SYSAHBCLKCTRL0 ; ///< (0x080) System clock group 0 control
  133. __IO uint32_t SYSAHBCLKCTRL1 ; ///< (0x084) System clock group 1 control
  134. };
  135. };
  136. union {
  137. __IO uint32_t PRESETCTRL[2] ;
  138. struct {
  139. __IO uint32_t PRESETCTRL0 ; ///< (0x088) Peripheral reset group 0 control
  140. __IO uint32_t PRESETCTRL1 ; ///< (0x08C) Peripheral reset group 1 control
  141. };
  142. };
  143. union {
  144. __IO uint32_t FCLKSEL[11] ;
  145. struct {
  146. __IO uint32_t UART0CLKSEL ; ///< (0x090) FCLK0 clock source select
  147. __IO uint32_t UART1CLKSEL ; ///< (0x094) FCLK1 clock source select
  148. __IO uint32_t unimp2CLKSEL ; ///< (0x098) FCLK2 clock source select
  149. __IO uint32_t unimp3CLKSEL ; ///< (0x09C) FCLK3 clock source select
  150. __IO uint32_t unimp4CLKSEL ; ///< (0x0A0) FCLK4 clock source select
  151. __IO uint32_t I2C0CLKSEL ; ///< (0x0A4) FCLK5 clock source select
  152. __IO uint32_t I2C1CLKSEL ; ///< (0x0A8) FCLK6 clock source select
  153. __IO uint32_t unimp7CLKSEL ; ///< (0x0AC) FCLK7 clock source select
  154. __IO uint32_t unimp8CLKSEL ; ///< (0x0B0) FCLK8 clock source select
  155. __IO uint32_t SPI0CLKSEL ; ///< (0x0B4) FCLK9 clock source select
  156. __IO uint32_t unimp10CLKSEL ; ///< (0x0B8) FCLK10 clock source select
  157. };
  158. };
  159. __IO uint32_t RESERVED6[5] ; ///< (0x0BC - 0x0CC)
  160. __IO uint32_t FRG0DIV ; ///< (0x0D0) Fractional generator divider value
  161. __IO uint32_t FRG0MULT ; ///< (0x0D4) Fractional generator multiplier value
  162. __IO uint32_t FRG0CLKSEL ; ///< (0x0D8) FRG0 clock source select
  163. __IO uint32_t RESERVED8[5] ; ///< (0x0DC - 0x0EC)
  164. __IO uint32_t CLKOUTSEL ; ///< (0x0F0) CLKOUT clock source select
  165. __IO uint32_t CLKOUTDIV ; ///< (0x0F4) CLKOUT clock divider
  166. __IO uint32_t RESERVED10[2] ; ///< (0x0F8 - 0x0FC)
  167. __I uint32_t PIOPORCAP0 ; ///< (0x100) POR captured PIO0 status 0
  168. __I uint32_t RESERVED11[19] ; ///< (0x104 - 0x14C)
  169. __IO uint32_t BODCTRL ; ///< (0x150) Brown-Out Detect
  170. __IO uint32_t SYSTCKCAL ; ///< (0x154) System tick counter calibration
  171. __IO uint32_t RESERVED12[6] ; ///< (0x158 - 0x16C)
  172. __IO uint32_t IRQLATENCY ; ///< (0x170) IRQ delay. Allows trade-off between interrupt latency and determinism.
  173. __IO uint32_t NMISRC ; ///< (0x174) NMI Source Control
  174. union {
  175. __IO uint32_t PINTSEL[8] ;
  176. struct {
  177. __IO uint32_t PINTSEL0 ; ///< (0x178) GPIO Pin Interrupt Select 0
  178. __IO uint32_t PINTSEL1 ; ///< (0x17C) GPIO Pin Interrupt Select 1
  179. __IO uint32_t PINTSEL2 ; ///< (0x180) GPIO Pin Interrupt Select 2
  180. __IO uint32_t PINTSEL3 ; ///< (0x184) GPIO Pin Interrupt Select 3
  181. __IO uint32_t PINTSEL4 ; ///< (0x188) GPIO Pin Interrupt Select 4
  182. __IO uint32_t PINTSEL5 ; ///< (0x18C) GPIO Pin Interrupt Select 5
  183. __IO uint32_t PINTSEL6 ; ///< (0x190) GPIO Pin Interrupt Select 6
  184. __IO uint32_t PINTSEL7 ; ///< (0x194) GPIO Pin Interrupt Select 7
  185. };
  186. };
  187. __IO uint32_t RESERVED13[27] ; ///< (0x198 - 0x200)
  188. __IO uint32_t STARTERP0 ; ///< (0x204) Start logic 0 pin wake-up enable
  189. __IO uint32_t RESERVED14[3] ; ///< (0x208 - 0x210)
  190. __IO uint32_t STARTERP1 ; ///< (0x214) Start logic 1 interrupt wake-up enable
  191. __IO uint32_t RESERVED15[6] ; ///< (0x218 - 0x22C)
  192. __IO uint32_t PDSLEEPCFG ; ///< (0x230) Power-down states in deep-sleep mode
  193. __IO uint32_t PDAWAKECFG ; ///< (0x234) Power-down states for wake-up from deep-sleep
  194. __IO uint32_t PDRUNCFG ; ///< (0x238) Power configuration
  195. __IO uint32_t RESERVED16[111] ; ///< (0x23C - 0x3F4)
  196. __I uint32_t DEVICE_ID ; ///< (0x3F8) Device ID
  197. } LPC_SYSCON_TypeDef;
  198. // ---------------- IOCON ----------------
  199. typedef struct {
  200. __IO uint32_t PIO0_17; // 0x00
  201. __IO uint32_t PIO0_13; // 0x04
  202. __IO uint32_t PIO0_12; // 0x08
  203. __IO uint32_t PIO0_5; // 0x0C
  204. __IO uint32_t PIO0_4; // 0x10
  205. __IO uint32_t PIO0_3; // 0x14
  206. __IO uint32_t PIO0_2; // 0x18
  207. __IO uint32_t PIO0_11; // 0x1C
  208. __IO uint32_t PIO0_10; // 0x20
  209. __IO uint32_t PIO0_16; // 0x24
  210. __IO uint32_t PIO0_15; // 0x28
  211. __IO uint32_t PIO0_1; // 0x2C
  212. __IO uint32_t PIO0_21; // 0x30
  213. __IO uint32_t PIO0_9; // 0x34
  214. __IO uint32_t PIO0_8; // 0x38
  215. __IO uint32_t PIO0_7; // 0x3C
  216. __IO uint32_t PIO0_29; // 0x40
  217. __IO uint32_t PIO0_0; // 0x44
  218. __IO uint32_t PIO0_14; // 0x48
  219. __IO uint32_t PIO0_28; // 0x4C
  220. __IO uint32_t PIO0_27; // 0x50
  221. __IO uint32_t PIO0_26; // 0x54
  222. __IO uint32_t PIO0_20; // 0x58
  223. __IO uint32_t PIO0_30; // 0x5C
  224. __IO uint32_t PIO0_19; // 0x60
  225. __IO uint32_t PIO0_25; // 0x64
  226. __IO uint32_t PIO0_24; // 0x68
  227. __IO uint32_t PIO0_23; // 0x6C
  228. __IO uint32_t PIO0_22; // 0x70
  229. __IO uint32_t PIO0_18; // 0x74
  230. } LPC_IOCON_TypeDef;
  231. //------------- Power Management Unit (PMU) --------------------------
  232. typedef struct
  233. {
  234. __IO uint32_t PCON; //!< Offset: 0x000 Power control Register (R/W)
  235. __IO uint32_t GPREG0; //!< Offset: 0x004 General purpose Register 0 (R/W)
  236. __IO uint32_t GPREG1; //!< Offset: 0x008 General purpose Register 1 (R/W)
  237. __IO uint32_t GPREG2; //!< Offset: 0x00C General purpose Register 2 (R/W)
  238. __IO uint32_t GPREG3; //!< Offset: 0x010 General purpose Register 3 (R/W)
  239. __IO uint32_t GPREG4; //!< Offset: 0x014 General purpose Register 4 (R/W)
  240. __I uint32_t RESERVED[2]; // 0x18 - 0x1C
  241. __IO uint32_t WUSRCREG; // 0x20
  242. __IO uint32_t WUENAREG; // 0x24
  243. } LPC_PMU_TypeDef;
  244. //------------- Switch Matrix (SWM) --------------------------
  245. typedef struct
  246. {
  247. union {
  248. __IO uint32_t PINASSIGN[10];
  249. struct {
  250. __IO uint32_t PINASSIGN0; // 0x000
  251. __IO uint32_t PINASSIGN1; // 0x004
  252. __IO uint32_t PINASSIGN2; // 0x008
  253. __IO uint32_t PINASSIGN3; // 0x00C
  254. __IO uint32_t PINASSIGN4; // 0x010
  255. __IO uint32_t PINASSIGN5; // 0x014
  256. __IO uint32_t PINASSIGN6; // 0x018
  257. __IO uint32_t PINASSIGN7; // 0x01C
  258. __IO uint32_t PINASSIGN8; // 0x020
  259. __IO uint32_t PINASSIGN9; // 0x024
  260. };
  261. };
  262. __I uint32_t Reserved0[86]; // 0x028 - 0x17C
  263. __IO uint32_t PINASSIGN_4PIN; // 0x180
  264. __I uint32_t Reserved1[15]; // 0x184 - 0x1BC
  265. __IO uint32_t PINENABLE0; // 0x1C0
  266. __IO uint32_t PINENABLE1; // 0x1C4
  267. } LPC_SWM_TypeDef;
  268. // ------------------------------------------------------------------------------------------------
  269. // ----- General Purpose I/O (GPIO) -----
  270. // ------------------------------------------------------------------------------------------------
  271. typedef struct {
  272. __IO uint8_t B0[32]; // 0x00 - 0x1F Byte pin registers P0.0 - P0.31
  273. __IO uint8_t B1[32]; // 0x20 - 0x3F Byte pin registers P1.0 - P1.31
  274. __I uint8_t Reserved0[4032]; // 0x40 - 0xFFF
  275. __IO uint32_t W0[32]; // 0x1000 - 0x107C Word pin registers P0.0 - P0.31
  276. __IO uint32_t W1[32]; // 0x1080 - 0x10FC Word pin registers P1.0 - P1.31
  277. __I uint32_t Reserved1[960]; // 0x1100 - 0x1FFC (960d = 0x3c0)
  278. union {
  279. __IO uint32_t DIR[2]; // 0x2000 - 0x2004
  280. struct {
  281. __IO uint32_t DIR0; // 0x2000
  282. __IO uint32_t DIR1; // 0x2004
  283. };
  284. };
  285. __I uint32_t Reserved2[30]; // 0x2008 - 0x207C
  286. union {
  287. __IO uint32_t MASK[2]; // 0x2080 - 0x2084
  288. struct {
  289. __IO uint32_t MASK0; // 0x2080
  290. __IO uint32_t MASK1; // 0x2084
  291. };
  292. };
  293. __I uint32_t Reserved3[30]; // 0x2088 - 0x20FC
  294. union {
  295. __IO uint32_t PIN[2]; // 0x2100 - 0x2104
  296. struct {
  297. __IO uint32_t PIN0; // 0x2100
  298. __IO uint32_t PIN1; // 0x2104
  299. };
  300. };
  301. __I uint32_t Reserved4[30]; // 0x2108 - 0x217C
  302. union {
  303. __IO uint32_t MPIN[2]; // 0x22180 - 0x2184
  304. struct {
  305. __IO uint32_t MPIN0; // 0x2180
  306. __IO uint32_t MPIN1; // 0x2184
  307. };
  308. };
  309. __I uint32_t Reserved5[30]; // 0x2188 - 0x21FC
  310. union {
  311. __IO uint32_t SET[2]; // 0x2200 -0x2204
  312. struct {
  313. __IO uint32_t SET0; // 0x2200
  314. __IO uint32_t SET1; // 0x2204
  315. };
  316. };
  317. __I uint32_t Reserved6[30]; // 0x2208 - 0x227C
  318. union {
  319. __O uint32_t CLR[2]; // 0x2280 - 0x2284
  320. struct {
  321. __O uint32_t CLR0; // 0x2280
  322. __O uint32_t CLR1; // 0x2284
  323. };
  324. };
  325. __I uint32_t Reserved7[30]; // 0x2288 - 0x22FC
  326. union {
  327. __O uint32_t NOT[2]; // 0x2300 - 0x2304
  328. struct {
  329. __O uint32_t NOT0; // 0x2300
  330. __O uint32_t NOT1; // 0x2304
  331. };
  332. };
  333. __I uint32_t Reserved8[30]; // 0x2308 - 0x237C
  334. union {
  335. __O uint32_t DIRSET[2]; // 0x2380 - 0x2384
  336. struct {
  337. __O uint32_t DIRSET0; // 0x2380
  338. __O uint32_t DIRSET1; // 0x2384
  339. };
  340. };
  341. __I uint32_t Reserved9[30]; // 0x2388 - 0x23FC
  342. union {
  343. __O uint32_t DIRCLR[2]; // 0x2400 - 0x2404
  344. struct {
  345. __O uint32_t DIRCLR0; // 0x2400
  346. __O uint32_t DIRCLR1; // 0x2404
  347. };
  348. };
  349. __I uint32_t Reserved10[30]; // 0x2408 - 0x247C
  350. union {
  351. __O uint32_t DIRNOT[2]; // 0x2480 - 0x2484
  352. struct {
  353. __O uint32_t DIRNOT0; // 0x2480
  354. __O uint32_t DIRNOT1; // 0x2484
  355. };
  356. };
  357. } LPC_GPIO_PORT_TypeDef;
  358. // ------------------------------------------------------------------------------------------------
  359. // ----- Pin Interrupts and Pattern Match (PIN_INT) -----
  360. // ------------------------------------------------------------------------------------------------
  361. typedef struct { /*!< (@ 0xA0004000) PIN_INT Structure */
  362. __IO uint32_t ISEL; /*!< (@ 0xA0004000) Pin Interrupt Mode register */
  363. __IO uint32_t IENR; /*!< (@ 0xA0004004) Pin Interrupt Enable (Rising) register */
  364. __IO uint32_t SIENR; /*!< (@ 0xA0004008) Set Pin Interrupt Enable (Rising) register */
  365. __IO uint32_t CIENR; /*!< (@ 0xA000400C) Clear Pin Interrupt Enable (Rising) register */
  366. __IO uint32_t IENF; /*!< (@ 0xA0004010) Pin Interrupt Enable Falling Edge / Active Level register */
  367. __IO uint32_t SIENF; /*!< (@ 0xA0004014) Set Pin Interrupt Enable Falling Edge / Active Level register */
  368. __IO uint32_t CIENF; /*!< (@ 0xA0004018) Clear Pin Interrupt Enable Falling Edge / Active Level address */
  369. __IO uint32_t RISE; /*!< (@ 0xA000401C) Pin Interrupt Rising Edge register */
  370. __IO uint32_t FALL; /*!< (@ 0xA0004020) Pin Interrupt Falling Edge register */
  371. __IO uint32_t IST; /*!< (@ 0xA0004024) Pin Interrupt Status register */
  372. __IO uint32_t PMCTRL; /*!< (@ 0xA0004028) GPIO pattern match interrupt control register */
  373. __IO uint32_t PMSRC; /*!< (@ 0xA000402C) GPIO pattern match interrupt bit-slice source register */
  374. __IO uint32_t PMCFG; /*!< (@ 0xA0004030) GPIO pattern match interrupt bit slice configuration register */
  375. } LPC_PIN_INT_TypeDef;
  376. //------------- CRC Engine (CRC) -----------------------------------------
  377. typedef struct
  378. {
  379. __IO uint32_t MODE;
  380. __IO uint32_t SEED;
  381. union {
  382. __I uint32_t SUM;
  383. __O uint32_t WR_DATA;
  384. };
  385. } LPC_CRC_TypeDef;
  386. //------------- Comparator (CMP) --------------------------------------------------
  387. typedef struct { /*!< (@ 0x40024000) CMP Structure */
  388. __IO uint32_t CTRL; /*!< (@ 0x40024000) Comparator control register */
  389. __IO uint32_t LAD; /*!< (@ 0x40024004) Voltage ladder register */
  390. } LPC_CMP_TypeDef;
  391. //------------- Self Wakeup Timer (WKT) --------------------------------------------------
  392. typedef struct { /*!< (@ 0x40028000) WKT Structure */
  393. __IO uint32_t CTRL; /*!< (@ 0x40028000) Alarm/Wakeup Timer Control register */
  394. uint32_t Reserved[2];
  395. __IO uint32_t COUNT; /*!< (@ 0x4002800C) Alarm/Wakeup TImer counter register */
  396. } LPC_WKT_TypeDef;
  397. //------------- Multi-Rate Timer (MRT) --------------------------------------------------
  398. typedef struct {
  399. __IO uint32_t INTVAL;
  400. __IO uint32_t TIMER;
  401. __IO uint32_t CTRL;
  402. __IO uint32_t STAT;
  403. } MRT_Channel_cfg_Type;
  404. typedef struct {
  405. MRT_Channel_cfg_Type Channel[4];
  406. uint32_t Reserved0[45]; // Address offsets = 0x40 - 0xF0
  407. __IO uint32_t IDLE_CH;
  408. __IO uint32_t IRQ_FLAG;
  409. } LPC_MRT_TypeDef;
  410. //------------- USART -----------
  411. typedef struct
  412. {
  413. __IO uint32_t CFG;
  414. __IO uint32_t CTL;
  415. __IO uint32_t STAT;
  416. __IO uint32_t INTENSET;
  417. __O uint32_t INTENCLR;
  418. __I uint32_t RXDAT;
  419. __I uint32_t RXDATSTAT;
  420. __IO uint32_t TXDAT;
  421. __IO uint32_t BRG;
  422. __I uint32_t INTSTAT;
  423. __IO uint32_t OSR;
  424. __IO uint32_t ADDR;
  425. } LPC_USART_TypeDef;
  426. //------------- SPI -----------------------
  427. typedef struct
  428. {
  429. __IO uint32_t CFG; /* 0x00 */
  430. __IO uint32_t DLY;
  431. __IO uint32_t STAT;
  432. __IO uint32_t INTENSET;
  433. __O uint32_t INTENCLR; /* 0x10 */
  434. __I uint32_t RXDAT;
  435. __IO uint32_t TXDATCTL;
  436. __IO uint32_t TXDAT;
  437. __IO uint32_t TXCTL; /* 0x20 */
  438. __IO uint32_t DIV;
  439. __I uint32_t INTSTAT;
  440. } LPC_SPI_TypeDef;
  441. //------------- I2C -------------------------------
  442. typedef struct
  443. {
  444. __IO uint32_t CFG; /* 0x00 */
  445. __IO uint32_t STAT;
  446. __IO uint32_t INTENSET;
  447. __O uint32_t INTENCLR;
  448. __IO uint32_t TIMEOUT; /* 0x10 */
  449. union {
  450. __IO uint32_t CLKDIV;
  451. __IO uint32_t DIV;
  452. };
  453. __IO uint32_t INTSTAT;
  454. uint32_t Reserved0[1];
  455. __IO uint32_t MSTCTL; /* 0x20 */
  456. __IO uint32_t MSTTIME;
  457. __IO uint32_t MSTDAT;
  458. uint32_t Reserved1[5];
  459. __IO uint32_t SLVCTL; /* 0x40 */
  460. __IO uint32_t SLVDAT;
  461. __IO uint32_t SLVADR0;
  462. __IO uint32_t SLVADR1;
  463. __IO uint32_t SLVADR2; /* 0x50 */
  464. __IO uint32_t SLVADR3;
  465. __IO uint32_t SLVQUAL0;
  466. uint32_t Reserved2[9];
  467. __I uint32_t MONRXDAT; /* 0x80 */
  468. } LPC_I2C_TypeDef;
  469. //------------------- Standard Counter/Timer (CTIMER) ---------------------
  470. typedef struct {
  471. __IO uint32_t IR; // 0x00
  472. __IO uint32_t TCR; // 0x04
  473. __IO uint32_t TC; // 0x08
  474. __IO uint32_t PR; // 0x0C
  475. __IO uint32_t PC; // 0x10
  476. __IO uint32_t MCR; // 0x14
  477. __IO uint32_t MR[4]; // 0x18 - 0x24
  478. __IO uint32_t CCR; // 0x28
  479. __IO uint32_t CR[4]; // 0x2C - 0x38
  480. __IO uint32_t EMR; // 0x3C
  481. __I uint32_t RESERVED0[12]; // 0x40 - 0x6C
  482. __IO uint32_t CTCR; // 0x70
  483. __IO uint32_t PWMC; // 0x74
  484. } LPC_TIMER_TypeDef;
  485. //------------- Widowed Watchdog Timer (WWDT) -----------------------------------------
  486. typedef struct
  487. {
  488. __IO uint32_t MOD; /*!< Offset: 0x000 Watchdog mode register (R/W) */
  489. __IO uint32_t TC; /*!< Offset: 0x004 Watchdog timer constant register (R/W) */
  490. __O uint32_t FEED; /*!< Offset: 0x008 Watchdog feed sequence register (W) */
  491. __I uint32_t TV; /*!< Offset: 0x00C Watchdog timer value register (R) */
  492. uint32_t RESERVED; /*!< Offset: 0x010 RESERVED */
  493. __IO uint32_t WARNINT; /*!< Offset: 0x014 Watchdog timer warning int. register (R/W) */
  494. __IO uint32_t WINDOW; /*!< Offset: 0x018 Watchdog timer window value register (R/W) */
  495. } LPC_WWDT_TypeDef;
  496. //------------- ADC -----------------------------------------
  497. typedef struct {
  498. __IO uint32_t CTRL; // 0x0
  499. uint32_t RESERVED0; // 0x4
  500. __IO uint32_t SEQA_CTRL; // 0x8
  501. __IO uint32_t SEQB_CTRL; // 0xC
  502. __IO uint32_t SEQA_GDAT; // 0x10
  503. __IO uint32_t SEQB_GDAT; // 0x14
  504. uint32_t RESERVED1[2]; // 0x18 - 0x1C
  505. __IO uint32_t DAT[12]; // 0x20 - 0x4C
  506. __IO uint32_t THR0_LOW; // 0x50
  507. __IO uint32_t THR1_LOW; // 0x54
  508. __IO uint32_t THR0_HIGH; // 0x58
  509. __IO uint32_t THR1_HIGH; // 0x5C
  510. __IO uint32_t CHAN_THRSEL; // 0x60
  511. __IO uint32_t INTEN; // 0x64
  512. __IO uint32_t FLAGS; // 0x68
  513. __IO uint32_t TRM; // 0x6C
  514. } LPC_ADC_TypeDef;
  515. //------------- DAC ----------------
  516. typedef struct {
  517. __IO uint32_t CR; // 0x00
  518. __IO uint32_t CTRL; // 0x04
  519. __IO uint32_t CNTVAL; // 0x08
  520. } LPC_DAC_TypeDef;
  521. //------------- Capacitive Touch module (CAPT) ----------------
  522. typedef struct {
  523. __IO uint32_t CTRL; // 0x00
  524. __IO uint32_t STATUS; // 0x04
  525. __IO uint32_t POLL_TCNT; // 0x08
  526. __I uint32_t reserved0; // 0x0C
  527. __IO uint32_t INTENSET; // 0x10
  528. __O uint32_t INTENCLR; // 0x14
  529. __I uint32_t INTSTAT; // 0x18
  530. __I uint32_t reserved1; // 0x1C
  531. __I uint32_t TOUCH; // 0x20
  532. __I uint32_t A_hole[1014];// 0x24 - 0xFF8
  533. __I uint32_t ID; // 0xFFC
  534. } LPC_CAPT_TypeDef;
  535. #define LUT_INs 5
  536. #define PLU_INs 6
  537. #define PLU_LUTs 26
  538. #define PLU_FFs 4
  539. #define PLU_OUTs 8
  540. typedef struct {
  541. struct { /* Input select register for LUT & Input... */
  542. union {
  543. __IO uint32_t INP[8]; /* Each LUT has maximum 5 inputs, the remaining are reserved. */
  544. struct {
  545. __IO uint32_t INP0;
  546. __IO uint32_t INP1;
  547. __IO uint32_t INP2;
  548. __IO uint32_t INP3;
  549. __IO uint32_t INP4;
  550. uint32_t RESERVED[3];
  551. };
  552. } LUT_MUX[PLU_LUTs];
  553. };
  554. uint32_t RESERVED0[8*64-8*PLU_LUTs]; /* ...-0x7FC */
  555. __IO uint32_t LUT_TRUTH[PLU_LUTs]; /* Truth-Table ("Look-up Table") programming */
  556. uint32_t RESERVED1[64-PLU_LUTs]; /* ...-0x8FC */
  557. __I uint32_t OUTPUTS; /* PLU Outputs Register (Read-only) */
  558. uint32_t RESERVED2[3*64-1]; /* ...-0xBFC */
  559. __IO uint32_t OUTPUT_MUX[PLU_OUTs]; /* Select register for PLU Ouptut */
  560. } LPC_PLU_TypeDef;
  561. #if defined ( __CC_ARM )
  562. #pragma no_anon_unions
  563. #endif
  564. /******************************************************************************/
  565. /* Peripheral memory map */
  566. /******************************************************************************/
  567. // Base addresses
  568. #define LPC_FLASH_BASE (0x00000000UL)
  569. #define LPC_RAM_BASE (0x10000000UL)
  570. #define LPC_ROM_BASE (0x1FFF0000UL)
  571. #define LPC_APB0_BASE (0x40000000UL)
  572. #define LPC_AHB_BASE (0x50000000UL)
  573. // APB0 peripherals
  574. #define LPC_WWDT_BASE (LPC_APB0_BASE + 0x00000)
  575. #define LPC_MRT_BASE (LPC_APB0_BASE + 0x04000)
  576. #define LPC_WKT_BASE (LPC_APB0_BASE + 0x08000)
  577. #define LPC_SWM_BASE (LPC_APB0_BASE + 0x0C000)
  578. // (LPC_APB0_BASE + 0x10000)
  579. #define LPC_DAC0_BASE (LPC_APB0_BASE + 0x14000)
  580. // (LPC_APB0_BASE + 0x18000)
  581. #define LPC_ADC_BASE (LPC_APB0_BASE + 0x1C000)
  582. #define LPC_PMU_BASE (LPC_APB0_BASE + 0x20000)
  583. #define LPC_CMP_BASE (LPC_APB0_BASE + 0x24000)
  584. #define LPC_PLU_BASE (LPC_APB0_BASE + 0x28000)
  585. // (LPC_APB0_BASE + 0x2C000)
  586. // (LPC_APB0_BASE + 0x30000)
  587. // (LPC_APB0_BASE + 0x34000)
  588. #define LPC_CTIMER0_BASE (LPC_APB0_BASE + 0x38000)
  589. // (LPC_APB0_BASE + 0x38000)
  590. #define LPC_FLASHCTRL_BASE (LPC_APB0_BASE + 0x40000)
  591. #define LPC_IOCON_BASE (LPC_APB0_BASE + 0x44000)
  592. #define LPC_SYSCON_BASE (LPC_APB0_BASE + 0x48000)
  593. #define LPC_I2C0_BASE (LPC_APB0_BASE + 0x50000)
  594. #define LPC_I2C1_BASE (LPC_APB0_BASE + 0x54000)
  595. #define LPC_SPI0_BASE (LPC_APB0_BASE + 0x58000)
  596. // (LPC_APB0_BASE + 0x5C000)
  597. #define LPC_CAPT_BASE (LPC_APB0_BASE + 0x60000)
  598. #define LPC_USART0_BASE (LPC_APB0_BASE + 0x64000)
  599. #define LPC_USART1_BASE (LPC_APB0_BASE + 0x68000)
  600. // (LPC_APB0_BASE + 0x6C000)
  601. // (LPC_APB0_BASE + 0x70000)
  602. // (LPC_APB0_BASE + 0x74000)
  603. // AHB peripherals
  604. #define LPC_CRC_BASE (LPC_AHB_BASE + 0x00000)
  605. // (LPC_AHB_BASE + 0x04000)
  606. // (LPC_AHB_BASE + 0x08000)
  607. // (LPC_AHB_BASE + 0x0C000)
  608. // (LPC_AHB_BASE + 0x10000)
  609. #define LPC_GPIO_PORT_BASE (0xA0000000)
  610. #define LPC_PIN_INT_BASE (LPC_GPIO_PORT_BASE + 0x4000)
  611. /******************************************************************************/
  612. /* Peripheral declarations */
  613. /******************************************************************************/
  614. #define LPC_WWDT ((LPC_WWDT_TypeDef *) LPC_WWDT_BASE )
  615. #define LPC_MRT ((LPC_MRT_TypeDef *) LPC_MRT_BASE )
  616. #define LPC_WKT ((LPC_WKT_TypeDef *) LPC_WKT_BASE )
  617. #define LPC_SWM ((LPC_SWM_TypeDef *) LPC_SWM_BASE )
  618. #define LPC_DAC0 ((LPC_DAC_TypeDef *) LPC_DAC0_BASE )
  619. #define LPC_ADC ((LPC_ADC_TypeDef *) LPC_ADC_BASE )
  620. #define LPC_PMU ((LPC_PMU_TypeDef *) LPC_PMU_BASE )
  621. #define LPC_CMP ((LPC_CMP_TypeDef *) LPC_CMP_BASE )
  622. #define LPC_CTIMER0 ((LPC_TIMER_TypeDef *) LPC_CTIMER0_BASE )
  623. #define LPC_FLASHCTRL ((LPC_FLASHCTRL_TypeDef *) LPC_FLASHCTRL_BASE )
  624. #define LPC_IOCON ((LPC_IOCON_TypeDef *) LPC_IOCON_BASE )
  625. #define LPC_SYSCON ((LPC_SYSCON_TypeDef *) LPC_SYSCON_BASE)
  626. #define LPC_I2C0 ((LPC_I2C_TypeDef *) LPC_I2C0_BASE )
  627. #define LPC_I2C1 ((LPC_I2C_TypeDef *) LPC_I2C1_BASE )
  628. #define LPC_SPI0 ((LPC_SPI_TypeDef *) LPC_SPI0_BASE )
  629. #define LPC_CAPT ((LPC_CAPT_TypeDef *) LPC_CAPT_BASE )
  630. #define LPC_USART0 ((LPC_USART_TypeDef *) LPC_USART0_BASE )
  631. #define LPC_USART1 ((LPC_USART_TypeDef *) LPC_USART1_BASE )
  632. #define LPC_CRC ((LPC_CRC_TypeDef *) LPC_CRC_BASE )
  633. #define LPC_GPIO_PORT ((LPC_GPIO_PORT_TypeDef *) LPC_GPIO_PORT_BASE )
  634. #define LPC_PIN_INT ((LPC_PIN_INT_TypeDef *) LPC_PIN_INT_BASE )
  635. #define LPC_PLU0 ((LPC_PLU_TypeDef *) LPC_PLU_BASE)
  636. ///////////////////////////////////////////////////////////////////////////////
  637. // Other chip-specific macro definitions (a.k.a. the chip.h section)
  638. ///////////////////////////////////////////////////////////////////////////////
  639. // ACMP_I-to-IOCON mapping
  640. #define ACMP_I1_PORT PIO0_0
  641. #define ACMP_I2_PORT PIO0_1
  642. #define ACMP_I3_PORT PIO0_14
  643. #define ACMP_I4_PORT PIO0_16
  644. #define ACMP_I5_PORT PIO0_21
  645. // For looping through the pad controls
  646. #define NUM_IOCON_SLOTS 30
  647. #ifdef __cplusplus
  648. }
  649. #endif
  650. #endif /* __LPC8xx_H__ */