]> rtime.felk.cvut.cz Git - lincan.git/blob - embedded/arch/arm/mach-lpc17xx/defines/LPC17xx.h
Contributed support for LCP17xx devices and PiKRON's LMC1 board.
[lincan.git] / embedded / arch / arm / mach-lpc17xx / defines / LPC17xx.h
1 /****************************************************************************//**
2  * @file :    LPC17xx.h
3  * @brief :      CMSIS Cortex-M3 Core Peripheral Access Layer Header File for
4  *           NXP LPC17xx Device Series
5  * @version : V1.1
6  * @date :    14th May 2009
7  *----------------------------------------------------------------------------
8  *
9  * Copyright (C) 2008 ARM Limited. All rights reserved.
10  *
11  * ARM Limited (ARM) is supplying this software for use with Cortex-M3
12  * processor based microcontrollers.  This file can be freely distributed
13  * within development tools that are supporting such ARM based processors.
14  *
15  * THIS SOFTWARE IS PROVIDED "AS IS".  NO WARRANTIES, WHETHER EXPRESS, IMPLIED
16  * OR STATUTORY, INCLUDING, BUT NOT LIMITED TO, IMPLIED WARRANTIES OF
17  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE.
18  * ARM SHALL NOT, IN ANY CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL, OR
19  * CONSEQUENTIAL DAMAGES, FOR ANY REASON WHATSOEVER.
20  *
21  ******************************************************************************/
22
23
24 #ifndef __LPC17xx_H__
25 #define __LPC17xx_H__
26
27 ///////////////////////////////////////////////////////////////////////////////
28 // Keyval
29 #define KVPB_CHUNK_SIZE 16
30
31 ///////////////////////////////////////////////////////////////////////////////
32 // ISP_RAM2FLASH_BLOCK_SIZE for 17xx CPU
33 #ifndef ISP_RAM2FLASH_BLOCK_SIZE
34   #define ISP_RAM2FLASH_BLOCK_SIZE      256
35 #endif /* ISP_RAM2FLASH_BLOCK_SIZE */
36
37 /** @addtogroup CMSIS_Configuration
38   * @{
39   */
40
41 /*
42  * ==========================================================================
43  * ---------- Interrupt Number Definition -----------------------------------
44  * ==========================================================================
45  */
46
47 /**
48  * @brief Interrupt Number Type Definition
49  */
50 typedef enum IRQn
51 {
52 /******  Cortex-M3 Processor Exceptions Numbers ***************************************************/
53   NonMaskableInt_IRQn           = -14,      /*!< 2 Non Maskable Interrupt                         */
54   MemoryManagement_IRQn         = -12,      /*!< 4 Cortex-M3 Memory Management Interrupt          */
55   BusFault_IRQn                 = -11,      /*!< 5 Cortex-M3 Bus Fault Interrupt                  */
56   UsageFault_IRQn               = -10,      /*!< 6 Cortex-M3 Usage Fault Interrupt                */
57   SVCall_IRQn                   = -5,       /*!< 11 Cortex-M3 SV Call Interrupt                   */
58   DebugMonitor_IRQn             = -4,       /*!< 12 Cortex-M3 Debug Monitor Interrupt             */
59   PendSV_IRQn                   = -2,       /*!< 14 Cortex-M3 Pend SV Interrupt                   */
60   SysTick_IRQn                  = -1,       /*!< 15 Cortex-M3 System Tick Interrupt               */
61
62 /******  LPC17xx Specific Interrupt Numbers *******************************************************/
63   WDT_IRQn                      = 0,        /*!< Watchdog Timer Interrupt                         */
64   TIMER0_IRQn                   = 1,        /*!< Timer0 Interrupt                                 */
65   TIMER1_IRQn                   = 2,        /*!< Timer1 Interrupt                                 */
66   TIMER2_IRQn                   = 3,        /*!< Timer2 Interrupt                                 */
67   TIMER3_IRQn                   = 4,        /*!< Timer3 Interrupt                                 */
68   UART0_IRQn                    = 5,        /*!< UART0 Interrupt                                  */
69   UART1_IRQn                    = 6,        /*!< UART1 Interrupt                                  */
70   UART2_IRQn                    = 7,        /*!< UART2 Interrupt                                  */
71   UART3_IRQn                    = 8,        /*!< UART3 Interrupt                                  */
72   PWM1_IRQn                     = 9,        /*!< PWM1 Interrupt                                   */
73   I2C0_IRQn                     = 10,       /*!< I2C0 Interrupt                                   */
74   I2C1_IRQn                     = 11,       /*!< I2C1 Interrupt                                   */
75   I2C2_IRQn                     = 12,       /*!< I2C2 Interrupt                                   */
76   SPI_IRQn                      = 13,       /*!< SPI Interrupt                                    */
77   SSP0_IRQn                     = 14,       /*!< SSP0 Interrupt                                   */
78   SSP1_IRQn                     = 15,       /*!< SSP1 Interrupt                                   */
79   PLL0_IRQn                     = 16,       /*!< PLL0 Lock (Main PLL) Interrupt                   */
80   RTC_IRQn                      = 17,       /*!< Real Time Clock Interrupt                        */
81   EINT0_IRQn                    = 18,       /*!< External Interrupt 0 Interrupt                   */
82   EINT1_IRQn                    = 19,       /*!< External Interrupt 1 Interrupt                   */
83   EINT2_IRQn                    = 20,       /*!< External Interrupt 2 Interrupt                   */
84   EINT3_IRQn                    = 21,       /*!< External Interrupt 3 Interrupt                   */
85   ADC_IRQn                      = 22,       /*!< A/D Converter Interrupt                          */
86   BOD_IRQn                      = 23,       /*!< Brown-Out Detect Interrupt                       */
87   USB_IRQn                      = 24,       /*!< USB Interrupt                                    */
88   CAN_IRQn                      = 25,       /*!< CAN Interrupt                                    */
89   DMA_IRQn                      = 26,       /*!< General Purpose DMA Interrupt                    */
90   I2S_IRQn                      = 27,       /*!< I2S Interrupt                                    */
91   ENET_IRQn                     = 28,       /*!< Ethernet Interrupt                               */
92   RIT_IRQn                      = 29,       /*!< Repetitive Interrupt Timer Interrupt             */
93   MCPWM_IRQn                    = 30,       /*!< Motor Control PWM Interrupt                      */
94   QEI_IRQn                      = 31,       /*!< Quadrature Encoder Interface Interrupt           */
95   PLL1_IRQn                     = 32,       /*!< PLL1 Lock (USB PLL) Interrupt                    */
96 } IRQn_Type;
97
98
99 /*
100  * ==========================================================================
101  * ----------- Processor and Core Peripheral Section ------------------------
102  * ==========================================================================
103  */
104
105 /* Configuration of the Cortex-M3 Processor and Core Peripherals */
106 #define __MPU_PRESENT             1         /*!< MPU present or not                               */
107 #define __NVIC_PRIO_BITS          5         /*!< Number of Bits used for Priority Levels          */
108 #define __Vendor_SysTickConfig    0         /*!< Set to 1 if different SysTick Config is used     */
109
110 /**
111  * @}
112  */
113
114 #include "core_cm3.h"                    /* Cortex-M3 processor and core peripherals           */
115
116
117
118 /**
119  * Initialize the system clock
120  *
121  * @param  none
122  * @return none
123  *
124  * @brief  Setup the microcontroller system.
125  *         Initialize the System and update the SystemFrequency variable.
126  */
127 extern void SystemInit (void);
128
129
130 /** @addtogroup Peripheral_register_structures
131   * @{
132   */
133
134 /******************************************************************************/
135 /*                Device Specific Peripheral registers structures             */
136 /******************************************************************************/
137
138 //#ifndef __IAR_SYSTEMS_ICC__
139 //#pragma anon_unions
140 //#endif
141
142
143 /*------------- System Control (SC) ------------------------------------------*/
144 /**
145  * @brief System Control Structure Type Definition
146  */
147 typedef struct
148 {
149   __IO uint32_t FLASHCFG;               /* Flash Accelerator Module           */
150        uint32_t RESERVED0[31];
151   __IO uint32_t PLL0CON;                /* Clocking and Power Control         */
152   __IO uint32_t PLL0CFG;
153   __I  uint32_t PLL0STAT;
154   __O  uint32_t PLL0FEED;
155        uint32_t RESERVED1[4];
156   __IO uint32_t PLL1CON;
157   __IO uint32_t PLL1CFG;
158   __I  uint32_t PLL1STAT;
159   __O  uint32_t PLL1FEED;
160        uint32_t RESERVED2[4];
161   __IO uint32_t PCON;
162   __IO uint32_t PCONP;
163        uint32_t RESERVED3[15];
164   __IO uint32_t CCLKCFG;
165   __IO uint32_t USBCLKCFG;
166   __IO uint32_t CLKSRCSEL;
167        uint32_t RESERVED4[12];
168   __IO uint32_t EXTINT;                 /* External Interrupts                */
169        uint32_t RESERVED5;
170   __IO uint32_t EXTMODE;
171   __IO uint32_t EXTPOLAR;
172        uint32_t RESERVED6[12];
173   __IO uint32_t RSID;                   /* Reset                              */
174        uint32_t RESERVED7[7];
175   __IO uint32_t SCS;                    /* Syscon Miscellaneous Registers     */
176   __IO uint32_t IRCTRIM;                /* Clock Dividers                     */
177   __IO uint32_t PCLKSEL0;
178   __IO uint32_t PCLKSEL1;
179        uint32_t RESERVED8[4];
180   __IO uint32_t USBIntSt;               /* USB Device/OTG Interrupt Register  */
181        uint32_t RESERVED9;
182   __IO uint32_t CLKOUTCFG;              /* Clock Output Configuration         */
183  } SC_TypeDef;
184
185 /*------------- Pin Connect Block (PINCON) -----------------------------------*/
186 /**
187  * @brief Pin Connect (Select) Structure Type Definition
188  */
189 typedef struct
190 {
191   __IO uint32_t PINSEL0;
192   __IO uint32_t PINSEL1;
193   __IO uint32_t PINSEL2;
194   __IO uint32_t PINSEL3;
195   __IO uint32_t PINSEL4;
196   __IO uint32_t PINSEL5;
197   __IO uint32_t PINSEL6;
198   __IO uint32_t PINSEL7;
199   __IO uint32_t PINSEL8;
200   __IO uint32_t PINSEL9;
201   __IO uint32_t PINSEL10;
202        uint32_t RESERVED0[5];
203   __IO uint32_t PINMODE0;
204   __IO uint32_t PINMODE1;
205   __IO uint32_t PINMODE2;
206   __IO uint32_t PINMODE3;
207   __IO uint32_t PINMODE4;
208   __IO uint32_t PINMODE5;
209   __IO uint32_t PINMODE6;
210   __IO uint32_t PINMODE7;
211   __IO uint32_t PINMODE8;
212   __IO uint32_t PINMODE9;
213   __IO uint32_t PINMODE_OD0;
214   __IO uint32_t PINMODE_OD1;
215   __IO uint32_t PINMODE_OD2;
216   __IO uint32_t PINMODE_OD3;
217   __IO uint32_t PINMODE_OD4;
218   __IO uint32_t I2CPADCFG;
219 } PINCON_TypeDef;
220
221
222 /*------------- General Purpose Input/Output (GPIO) --------------------------*/
223 /**
224  * @brief GPIO Structure Type Definition
225  */
226 typedef struct
227 {
228   __IO uint32_t FIODIR;
229        uint32_t RESERVED0[3];
230   __IO uint32_t FIOMASK;
231   __IO uint32_t FIOPIN;
232   __IO uint32_t FIOSET;
233   __O  uint32_t FIOCLR;
234 } GPIO_TypeDef;
235
236 /**
237  * @brief GPIO Interrupt Structure Type Definition
238  */
239 typedef struct
240 {
241   __I  uint32_t IntStatus;
242   __I  uint32_t IO0IntStatR;
243   __I  uint32_t IO0IntStatF;
244   __O  uint32_t IO0IntClr;
245   __IO uint32_t IO0IntEnR;
246   __IO uint32_t IO0IntEnF;
247        uint32_t RESERVED0[3];
248   __I  uint32_t IO2IntStatR;
249   __I  uint32_t IO2IntStatF;
250   __O  uint32_t IO2IntClr;
251   __IO uint32_t IO2IntEnR;
252   __IO uint32_t IO2IntEnF;
253 } GPIOINT_TypeDef;
254
255 /*------------- Timer (TIM) --------------------------------------------------*/
256 /**
257  * @brief Timer Structure Type Definition
258  */
259 typedef struct
260 {
261   __IO uint32_t IR;
262   __IO uint32_t TCR;
263   __IO uint32_t TC;
264   __IO uint32_t PR;
265   __IO uint32_t PC;
266   __IO uint32_t MCR;
267   __IO uint32_t MR0;
268   __IO uint32_t MR1;
269   __IO uint32_t MR2;
270   __IO uint32_t MR3;
271   __IO uint32_t CCR;
272   __I  uint32_t CR0;
273   __I  uint32_t CR1;
274        uint32_t RESERVED0[2];
275   __IO uint32_t EMR;
276        uint32_t RESERVED1[24];
277   __IO uint32_t CTCR;
278 } TIM_TypeDef;
279
280 /*------------- Pulse-Width Modulation (PWM) ---------------------------------*/
281 /**
282  * @brief Pulse Width ModulationStructure Type Definition
283  */
284 typedef struct
285 {
286   __IO uint32_t IR;
287   __IO uint32_t TCR;
288   __IO uint32_t TC;
289   __IO uint32_t PR;
290   __IO uint32_t PC;
291   __IO uint32_t MCR;
292   __IO uint32_t MR0;
293   __IO uint32_t MR1;
294   __IO uint32_t MR2;
295   __IO uint32_t MR3;
296   __IO uint32_t CCR;
297   __I  uint32_t CR0;
298   __I  uint32_t CR1;
299   __I  uint32_t CR2;
300   __I  uint32_t CR3;
301            uint32_t RESERVED0;
302   __IO uint32_t MR4;
303   __IO uint32_t MR5;
304   __IO uint32_t MR6;
305   __IO uint32_t PCR;
306   __IO uint32_t LER;
307        uint32_t RESERVED1[7];
308   __IO uint32_t CTCR;
309 } PWM_TypeDef;
310
311 /*------------- Universal Asynchronous Receiver Transmitter (UART) -----------*/
312 /**
313  * @brief Universal Asynchronous Receiver Transmitter 0/2/3 Structure Type Definition
314  */
315 typedef struct
316 {
317         union {
318                 __I uint8_t RBR;
319                 __O uint8_t THR;
320                 __IO uint8_t DLL;
321                 uint32_t RESERVED0;
322         };
323
324         union {
325                 __IO uint8_t DLM;
326                 __IO uint32_t IER;
327         };
328
329         union {
330                 __I uint32_t IIR;
331                 __O uint8_t FCR;
332         };
333
334         __IO uint8_t LCR;
335         uint8_t RESERVED1[7];
336         __I uint8_t LSR;
337         uint8_t RESERVED2[7];
338         __IO uint8_t SCR;
339         uint8_t RESERVED3[3];
340         __IO uint32_t ACR;
341         __IO uint32_t ICR;
342         __IO uint32_t FDR;
343         uint32_t RESERVED4;
344         __IO uint8_t TER;
345         uint8_t RESERVED5[39];
346         __I uint32_t FIFOLVL;
347 } UART_TypeDef;
348
349 /**
350  * @brief Universal Asynchronous Receiver Transmitter 1 Structure Type Definition
351  */
352 typedef struct
353 {
354         union {
355                 __I  uint8_t  RBR;
356                 __O  uint8_t  THR;
357                 __IO uint8_t  DLL;
358                    uint32_t RESERVED0;
359         };
360         union {
361                 __IO uint8_t  DLM;
362                 __IO uint32_t IER;
363         };
364         union {
365                 __I  uint32_t IIR;
366                 __O  uint8_t  FCR;
367         };
368         __IO uint8_t  LCR;
369            uint8_t  RESERVED1[3];
370         __IO uint8_t  MCR;
371            uint8_t  RESERVED2[3];
372         __IO uint8_t  LSR;
373            uint8_t  RESERVED3[3];
374         __IO uint8_t  MSR;
375            uint8_t  RESERVED4[3];
376         __IO uint8_t  SCR;
377            uint8_t  RESERVED5[3];
378         __IO uint32_t ACR;
379            uint32_t RESERVED6;
380         __IO uint32_t FDR;
381            uint32_t RESERVED7;
382         __IO uint8_t  TER;
383            uint8_t  RESERVED8[27];
384         __IO uint8_t  RS485CTRL;
385            uint8_t  RESERVED9[3];
386         __IO uint8_t  ADRMATCH;
387            uint8_t  RESERVED10[3];
388         __IO uint8_t  RS485DLY;
389                 uint8_t RESERVED11[3];
390         __IO uint32_t FIFOLVL;
391 } UART1_TypeDef;
392
393
394 /*------------- Serial Peripheral Interface (SPI) ----------------------------*/
395 /**
396  * @brief Serial Peripheral InterfaceStructure Type Definition
397  */
398 typedef struct
399 {
400   __IO uint32_t SPCR;
401   __I  uint32_t SPSR;
402   __IO uint32_t SPDR;
403   __IO uint32_t SPCCR;
404        uint32_t RESERVED0[3];
405   __IO uint32_t SPINT;
406 } SPI_TypeDef;
407
408 /*------------- Synchronous Serial Communication (SSP) -----------------------*/
409 /**
410  * @brief Synchronous Serial Communication Structure Type Definition
411  */
412 typedef struct
413 {
414   __IO uint32_t CR0;
415   __IO uint32_t CR1;
416   __IO uint32_t DR;
417   __I  uint32_t SR;
418   __IO uint32_t CPSR;
419   __IO uint32_t IMSC;
420   __IO uint32_t RIS;
421   __IO uint32_t MIS;
422   __IO uint32_t ICR;
423   __IO uint32_t DMACR;
424 } SSP_TypeDef;
425
426 /*------------- Inter-Integrated Circuit (I2C) -------------------------------*/
427 /**
428  * @brief Inter-Intergrated Circuit Structure Type Definition
429  */
430 typedef struct
431 {
432   __IO uint32_t I2CONSET;
433   __I  uint32_t I2STAT;
434   __IO uint32_t I2DAT;
435   __IO uint32_t I2ADR0;
436   __IO uint32_t I2SCLH;
437   __IO uint32_t I2SCLL;
438   __O  uint32_t I2CONCLR;
439   __IO uint32_t MMCTRL;
440   __IO uint32_t I2ADR1;
441   __IO uint32_t I2ADR2;
442   __IO uint32_t I2ADR3;
443   __I  uint32_t I2DATA_BUFFER;
444   __IO uint32_t I2MASK0;
445   __IO uint32_t I2MASK1;
446   __IO uint32_t I2MASK2;
447   __IO uint32_t I2MASK3;
448 } I2C_TypeDef;
449
450 /*------------- Inter IC Sound (I2S) -----------------------------------------*/
451 /**
452  * @brief Inter IC Sound Structure Type Definition
453  */
454 typedef struct
455 {
456   __IO uint32_t I2SDAO;
457   __IO uint32_t I2SDAI;
458   __O  uint32_t I2STXFIFO;
459   __I  uint32_t I2SRXFIFO;
460   __I  uint32_t I2SSTATE;
461   __IO uint32_t I2SDMA1;
462   __IO uint32_t I2SDMA2;
463   __IO uint32_t I2SIRQ;
464   __IO uint32_t I2STXRATE;
465   __IO uint32_t I2SRXRATE;
466   __IO uint32_t I2STXBITRATE;
467   __IO uint32_t I2SRXBITRATE;
468   __IO uint32_t I2STXMODE;
469   __IO uint32_t I2SRXMODE;
470 } I2S_TypeDef;
471
472 /*------------- Repetitive Interrupt Timer (RIT) -----------------------------*/
473 /**
474  * @brief Repetitive Interrupt Timer Structure Type Definition
475  */
476 typedef struct
477 {
478   __IO uint32_t RICOMPVAL;
479   __IO uint32_t RIMASK;
480   __IO uint8_t  RICTRL;
481        uint8_t  RESERVED0[3];
482   __IO uint32_t RICOUNTER;
483 } RIT_TypeDef;
484
485 /*------------- Real-Time Clock (RTC) ----------------------------------------*/
486 /**
487  * @brief Real Time Clock Structure Type Definition
488  */
489 typedef struct
490 {
491   __IO uint8_t  ILR;
492        uint8_t  RESERVED0[7];
493   __IO uint8_t  CCR;
494        uint8_t  RESERVED1[3];
495   __IO uint8_t  CIIR;
496        uint8_t  RESERVED2[3];
497   __IO uint8_t  AMR;
498        uint8_t  RESERVED3[3];
499   __I  uint32_t CTIME0;
500   __I  uint32_t CTIME1;
501   __I  uint32_t CTIME2;
502   __IO uint8_t  SEC;
503        uint8_t  RESERVED4[3];
504   __IO uint8_t  MIN;
505        uint8_t  RESERVED5[3];
506   __IO uint8_t  HOUR;
507        uint8_t  RESERVED6[3];
508   __IO uint8_t  DOM;
509        uint8_t  RESERVED7[3];
510   __IO uint8_t  DOW;
511        uint8_t  RESERVED8[3];
512   __IO uint16_t DOY;
513        uint16_t RESERVED9;
514   __IO uint8_t  MONTH;
515        uint8_t  RESERVED10[3];
516   __IO uint16_t YEAR;
517        uint16_t RESERVED11;
518   __IO uint32_t CALIBRATION;
519   __IO uint32_t GPREG0;
520   __IO uint32_t GPREG1;
521   __IO uint32_t GPREG2;
522   __IO uint32_t GPREG3;
523   __IO uint32_t GPREG4;
524   __IO uint8_t  WAKEUPDIS;
525        uint8_t  RESERVED12[3];
526   __IO uint8_t  PWRCTRL;
527        uint8_t  RESERVED13[3];
528   __IO uint8_t  ALSEC;
529        uint8_t  RESERVED14[3];
530   __IO uint8_t  ALMIN;
531        uint8_t  RESERVED15[3];
532   __IO uint8_t  ALHOUR;
533        uint8_t  RESERVED16[3];
534   __IO uint8_t  ALDOM;
535        uint8_t  RESERVED17[3];
536   __IO uint8_t  ALDOW;
537        uint8_t  RESERVED18[3];
538   __IO uint16_t ALDOY;
539        uint16_t RESERVED19;
540   __IO uint8_t  ALMON;
541        uint8_t  RESERVED20[3];
542   __IO uint16_t ALYEAR;
543        uint16_t RESERVED21;
544 } RTC_TypeDef;
545
546
547 /*------------- Watchdog Timer (WDT) -----------------------------------------*/
548 /**
549  * @brief Watchdog Timer Structure Type Definition
550  */
551 typedef struct
552 {
553   __IO uint8_t  WDMOD;
554        uint8_t  RESERVED0[3];
555   __IO uint32_t WDTC;
556   __O  uint8_t  WDFEED;
557        uint8_t  RESERVED1[3];
558   __I  uint32_t WDTV;
559   __IO uint32_t WDCLKSEL;
560 } WDT_TypeDef;
561
562 /*------------- Analog-to-Digital Converter (ADC) ----------------------------*/
563 /**
564  * @brief Analog to Digital Structure Type Definition
565  */
566 typedef struct
567 {
568   __IO uint32_t ADCR;
569   __IO uint32_t ADGDR;
570 #ifndef __LPC17XX_REV00
571   uint32_t RESERVED0;
572 #endif
573   __IO uint32_t ADINTEN;
574   __I  uint32_t ADDR0;
575   __I  uint32_t ADDR1;
576   __I  uint32_t ADDR2;
577   __I  uint32_t ADDR3;
578   __I  uint32_t ADDR4;
579   __I  uint32_t ADDR5;
580   __I  uint32_t ADDR6;
581   __I  uint32_t ADDR7;
582   __I  uint32_t ADSTAT;
583   __IO uint32_t ADTRM;
584 } ADC_TypeDef;
585
586
587 /*------------- Digital-to-Analog Converter (DAC) ----------------------------*/
588 /**
589  * @brief Digital to Analog Structure Type Definition
590  */
591 typedef struct
592 {
593   __IO uint32_t DACR;
594   __IO uint32_t DACCTRL;
595   __IO uint16_t DACCNTVAL;
596 } DAC_TypeDef;
597
598 /*------------- Motor Control Pulse-Width Modulation (MCPWM) -----------------*/
599 /**
600  * @brief Motor Control Pulse Width Modulation Structure Type Definition
601  */
602 typedef struct
603 {
604   __I  uint32_t MCCON;
605   __O  uint32_t MCCON_SET;
606   __O  uint32_t MCCON_CLR;
607   __I  uint32_t MCCAPCON;
608   __O  uint32_t MCCAPCON_SET;
609   __O  uint32_t MCCAPCON_CLR;
610   __IO uint32_t MCTIM0;
611   __IO uint32_t MCTIM1;
612   __IO uint32_t MCTIM2;
613   __IO uint32_t MCPER0;
614   __IO uint32_t MCPER1;
615   __IO uint32_t MCPER2;
616   __IO uint32_t MCPW0;
617   __IO uint32_t MCPW1;
618   __IO uint32_t MCPW2;
619   __IO uint32_t MCDEADTIME;
620   __IO uint32_t MCCCP;
621   __IO uint32_t MCCR0;
622   __IO uint32_t MCCR1;
623   __IO uint32_t MCCR2;
624   __I  uint32_t MCINTEN;
625   __O  uint32_t MCINTEN_SET;
626   __O  uint32_t MCINTEN_CLR;
627   __I  uint32_t MCCNTCON;
628   __O  uint32_t MCCNTCON_SET;
629   __O  uint32_t MCCNTCON_CLR;
630   __I  uint32_t MCINTFLAG;
631   __O  uint32_t MCINTFLAG_SET;
632   __O  uint32_t MCINTFLAG_CLR;
633   __O  uint32_t MCCAP_CLR;
634 } MCPWM_TypeDef;
635
636 /*------------- Quadrature Encoder Interface (QEI) ---------------------------*/
637 /**
638  * @brief Quadrature Encoder Interface Structure Type Definition
639  */
640 typedef struct
641 {
642   __O  uint32_t QEICON;
643   __I  uint32_t QEISTAT;
644   __IO uint32_t QEICONF;
645   __I  uint32_t QEIPOS;
646   __IO uint32_t QEIMAXPOS;
647   __IO uint32_t CMPOS0;
648   __IO uint32_t CMPOS1;
649   __IO uint32_t CMPOS2;
650   __I  uint32_t INXCNT;
651   __IO uint32_t INXCMP;
652   __IO uint32_t QEILOAD;
653   __I  uint32_t QEITIME;
654   __I  uint32_t QEIVEL;
655   __I  uint32_t QEICAP;
656   __IO uint32_t VELCOMP;
657   __IO uint32_t FILTER;
658        uint32_t RESERVED0[998];
659   __O  uint32_t QEIIEC;
660   __O  uint32_t QEIIES;
661   __I  uint32_t QEIINTSTAT;
662   __I  uint32_t QEIIE;
663   __O  uint32_t QEICLR;
664   __O  uint32_t QEISET;
665 } QEI_TypeDef;
666
667 /*------------- Controller Area Network (CAN) --------------------------------*/
668 /**
669  * @brief Control Area Network Structure Type Definition
670  */
671 typedef struct
672 {
673   __IO uint32_t mask[512];              /* ID Masks                           */
674 } CANAF_RAM_TypeDef;
675
676 /**
677  * @brief Acceptance Filter Structure Type Definition
678  */
679 typedef struct                          /* Acceptance Filter Registers        */
680 {
681   __IO uint32_t AFMR;
682   __IO uint32_t SFF_sa;
683   __IO uint32_t SFF_GRP_sa;
684   __IO uint32_t EFF_sa;
685   __IO uint32_t EFF_GRP_sa;
686   __IO uint32_t ENDofTable;
687   __I  uint32_t LUTerrAd;
688   __I  uint32_t LUTerr;
689   __IO uint32_t FCANIE;
690   __I  uint32_t FCANIC0;
691   __I  uint32_t FCANIC1;
692 } CANAF_TypeDef;
693
694 /**
695  * @brief CAN Central Structure Type Definition
696  */
697 typedef struct                          /* Central Registers                  */
698 {
699   __I  uint32_t CANTxSR;
700   __I  uint32_t CANRxSR;
701   __I  uint32_t CANMSR;
702 } CANCR_TypeDef;
703
704 /**
705  * @brief CAN Controller Structure Type Definition
706  */
707 typedef struct                          /* Controller Registers               */
708 {
709   __IO uint32_t MOD;
710   __O  uint32_t CMR;
711   __IO uint32_t GSR;
712   __I  uint32_t ICR;
713   __IO uint32_t IER;
714   __IO uint32_t BTR;
715   __IO uint32_t EWL;
716   __I  uint32_t SR;
717   __IO uint32_t RFS;
718   __IO uint32_t RID;
719   __IO uint32_t RDA;
720   __IO uint32_t RDB;
721   __IO uint32_t TFI1;
722   __IO uint32_t TID1;
723   __IO uint32_t TDA1;
724   __IO uint32_t TDB1;
725   __IO uint32_t TFI2;
726   __IO uint32_t TID2;
727   __IO uint32_t TDA2;
728   __IO uint32_t TDB2;
729   __IO uint32_t TFI3;
730   __IO uint32_t TID3;
731   __IO uint32_t TDA3;
732   __IO uint32_t TDB3;
733 } CAN_TypeDef;
734
735 /*------------- General Purpose Direct Memory Access (GPDMA) -----------------*/
736 /**
737  * @brief General Purpose Direct Memory Access Structure Type Definition
738  */
739 typedef struct                          /* Common Registers                   */
740 {
741   __I  uint32_t DMACIntStat;
742   __I  uint32_t DMACIntTCStat;
743   __O  uint32_t DMACIntTCClear;
744   __I  uint32_t DMACIntErrStat;
745   __O  uint32_t DMACIntErrClr;
746   __I  uint32_t DMACRawIntTCStat;
747   __I  uint32_t DMACRawIntErrStat;
748   __I  uint32_t DMACEnbldChns;
749   __IO uint32_t DMACSoftBReq;
750   __IO uint32_t DMACSoftSReq;
751   __IO uint32_t DMACSoftLBReq;
752   __IO uint32_t DMACSoftLSReq;
753   __IO uint32_t DMACConfig;
754   __IO uint32_t DMACSync;
755 } GPDMA_TypeDef;
756
757 /**
758  * @brief GPDMA Channel Structure Type Definition
759  */
760 typedef struct                          /* Channel Registers                  */
761 {
762   __IO uint32_t DMACCSrcAddr;
763   __IO uint32_t DMACCDestAddr;
764   __IO uint32_t DMACCLLI;
765   __IO uint32_t DMACCControl;
766   __IO uint32_t DMACCConfig;
767 } GPDMACH_TypeDef;
768
769
770 /*------------- Universal Serial Bus (USB) -----------------------------------*/
771 /**
772  * @brief Universal Serial Bus Structure Type Definition
773  */
774 typedef struct
775 {
776   __I  uint32_t HcRevision;             /* USB Host Registers                 */
777   __IO uint32_t HcControl;
778   __IO uint32_t HcCommandStatus;
779   __IO uint32_t HcInterruptStatus;
780   __IO uint32_t HcInterruptEnable;
781   __IO uint32_t HcInterruptDisable;
782   __IO uint32_t HcHCCA;
783   __I  uint32_t HcPeriodCurrentED;
784   __IO uint32_t HcControlHeadED;
785   __IO uint32_t HcControlCurrentED;
786   __IO uint32_t HcBulkHeadED;
787   __IO uint32_t HcBulkCurrentED;
788   __I  uint32_t HcDoneHead;
789   __IO uint32_t HcFmInterval;
790   __I  uint32_t HcFmRemaining;
791   __I  uint32_t HcFmNumber;
792   __IO uint32_t HcPeriodicStart;
793   __IO uint32_t HcLSTreshold;
794   __IO uint32_t HcRhDescriptorA;
795   __IO uint32_t HcRhDescriptorB;
796   __IO uint32_t HcRhStatus;
797   __IO uint32_t HcRhPortStatus1;
798   __IO uint32_t HcRhPortStatus2;
799        uint32_t RESERVED0[40];
800   __I  uint32_t Module_ID;
801
802   __I  uint32_t OTGIntSt;               /* USB On-The-Go Registers            */
803   __IO uint32_t OTGIntEn;
804   __O  uint32_t OTGIntSet;
805   __O  uint32_t OTGIntClr;
806   __IO uint32_t OTGStCtrl;
807   __IO uint32_t OTGTmr;
808        uint32_t RESERVED1[58];
809
810   __I  uint32_t USBDevIntSt;            /* USB Device Interrupt Registers     */
811   __IO uint32_t USBDevIntEn;
812   __O  uint32_t USBDevIntClr;
813   __O  uint32_t USBDevIntSet;
814
815   __O  uint32_t USBCmdCode;             /* USB Device SIE Command Registers   */
816   __I  uint32_t USBCmdData;
817
818   __I  uint32_t USBRxData;              /* USB Device Transfer Registers      */
819   __O  uint32_t USBTxData;
820   __I  uint32_t USBRxPLen;
821   __O  uint32_t USBTxPLen;
822   __IO uint32_t USBCtrl;
823   __O  uint32_t USBDevIntPri;
824
825   __I  uint32_t USBEpIntSt;             /* USB Device Endpoint Interrupt Regs */
826   __IO uint32_t USBEpIntEn;
827   __O  uint32_t USBEpIntClr;
828   __O  uint32_t USBEpIntSet;
829   __O  uint32_t USBEpIntPri;
830
831   __IO uint32_t USBReEp;                /* USB Device Endpoint Realization Reg*/
832   __O  uint32_t USBEpInd;
833   __IO uint32_t USBMaxPSize;
834
835   __I  uint32_t USBDMARSt;              /* USB Device DMA Registers           */
836   __O  uint32_t USBDMARClr;
837   __O  uint32_t USBDMARSet;
838        uint32_t RESERVED2[9];
839   __IO uint32_t USBUDCAH;
840   __I  uint32_t USBEpDMASt;
841   __O  uint32_t USBEpDMAEn;
842   __O  uint32_t USBEpDMADis;
843   __I  uint32_t USBDMAIntSt;
844   __IO uint32_t USBDMAIntEn;
845        uint32_t RESERVED3[2];
846   __I  uint32_t USBEoTIntSt;
847   __O  uint32_t USBEoTIntClr;
848   __O  uint32_t USBEoTIntSet;
849   __I  uint32_t USBNDDRIntSt;
850   __O  uint32_t USBNDDRIntClr;
851   __O  uint32_t USBNDDRIntSet;
852   __I  uint32_t USBSysErrIntSt;
853   __O  uint32_t USBSysErrIntClr;
854   __O  uint32_t USBSysErrIntSet;
855        uint32_t RESERVED4[15];
856
857   __I  uint32_t I2C_RX;                 /* USB OTG I2C Registers              */
858   __O  uint32_t I2C_WO;
859   __I  uint32_t I2C_STS;
860   __IO uint32_t I2C_CTL;
861   __IO uint32_t I2C_CLKHI;
862   __O  uint32_t I2C_CLKLO;
863        uint32_t RESERVED5[823];
864
865   union {
866   __IO uint32_t USBClkCtrl;             /* USB Clock Control Registers        */
867   __IO uint32_t OTGClkCtrl;
868   };
869   union {
870   __I  uint32_t USBClkSt;
871   __I  uint32_t OTGClkSt;
872   };
873 } USB_TypeDef;
874
875 /*------------- Ethernet Media Access Controller (EMAC) ----------------------*/
876 /**
877  * @brief Ethernet Media Access Controller Structure Type Definition
878  */
879 typedef struct
880 {
881   __IO uint32_t MAC1;                   /* MAC Registers                      */
882   __IO uint32_t MAC2;
883   __IO uint32_t IPGT;
884   __IO uint32_t IPGR;
885   __IO uint32_t CLRT;
886   __IO uint32_t MAXF;
887   __IO uint32_t SUPP;
888   __IO uint32_t TEST;
889   __IO uint32_t MCFG;
890   __IO uint32_t MCMD;
891   __IO uint32_t MADR;
892   __O  uint32_t MWTD;
893   __I  uint32_t MRDD;
894   __I  uint32_t MIND;
895        uint32_t RESERVED0[2];
896   __IO uint32_t SA0;
897   __IO uint32_t SA1;
898   __IO uint32_t SA2;
899        uint32_t RESERVED1[45];
900   __IO uint32_t Command;                /* Control Registers                  */
901   __I  uint32_t Status;
902   __IO uint32_t RxDescriptor;
903   __IO uint32_t RxStatus;
904   __IO uint32_t RxDescriptorNumber;
905   __I  uint32_t RxProduceIndex;
906   __IO uint32_t RxConsumeIndex;
907   __IO uint32_t TxDescriptor;
908   __IO uint32_t TxStatus;
909   __IO uint32_t TxDescriptorNumber;
910   __IO uint32_t TxProduceIndex;
911   __I  uint32_t TxConsumeIndex;
912        uint32_t RESERVED2[10];
913   __I  uint32_t TSV0;
914   __I  uint32_t TSV1;
915   __I  uint32_t RSV;
916        uint32_t RESERVED3[3];
917   __IO uint32_t FlowControlCounter;
918   __I  uint32_t FlowControlStatus;
919        uint32_t RESERVED4[34];
920   __IO uint32_t RxFilterCtrl;           /* Rx Filter Registers                */
921   __IO uint32_t RxFilterWoLStatus;
922   __IO uint32_t RxFilterWoLClear;
923        uint32_t RESERVED5;
924   __IO uint32_t HashFilterL;
925   __IO uint32_t HashFilterH;
926        uint32_t RESERVED6[882];
927   __I  uint32_t IntStatus;              /* Module Control Registers           */
928   __IO uint32_t IntEnable;
929   __O  uint32_t IntClear;
930   __O  uint32_t IntSet;
931        uint32_t RESERVED7;
932   __IO uint32_t PowerDown;
933        uint32_t RESERVED8;
934   __IO uint32_t Module_ID;
935 } EMAC_TypeDef;
936
937 //#ifndef __IAR_SYSTEMS_ICC__
938 //#pragma no_anon_unions
939 //#endif
940
941 /**
942  * @}
943  */
944
945
946 /** @addtogroup Peripheral_memory_map
947   * @{
948   */
949
950 /******************************************************************************/
951 /*                         Peripheral memory map                              */
952 /******************************************************************************/
953 /* Base addresses                                                             */
954 #define FLASH_BASE            (0x00000000UL)
955 #define RAM_BASE              (0x10000000UL)
956 #ifdef __LPC17XX_REV00
957 #define AHBRAM0_BASE          (0x20000000UL)
958 #define AHBRAM1_BASE          (0x20004000UL)
959 #else
960 #define AHBRAM0_BASE          (0x2007C000UL)
961 #define AHBRAM1_BASE          (0x20080000UL)
962 #define GPIO_BASE             (0x2009C000UL)
963 #endif
964 #define APB0_BASE             (0x40000000UL)
965 #define APB1_BASE             (0x40080000UL)
966 #define AHB_BASE              (0x50000000UL)
967 #define CM3_BASE              (0xE0000000UL)
968
969 #ifdef __LPC17XX_REV00
970 #define GPIO_BASE                         (AHB_BASE  + 0x14000)
971 #endif
972
973 /* APB0 peripherals                                                           */
974 #define WDT_BASE              (APB0_BASE + 0x00000)
975 #define TIM0_BASE             (APB0_BASE + 0x04000)
976 #define TIM1_BASE             (APB0_BASE + 0x08000)
977 #define UART0_BASE            (APB0_BASE + 0x0C000)
978 #define UART1_BASE            (APB0_BASE + 0x10000)
979 #define PWM1_BASE             (APB0_BASE + 0x18000)
980 #define I2C0_BASE             (APB0_BASE + 0x1C000)
981 #define SPI_BASE              (APB0_BASE + 0x20000)
982 #define RTC_BASE              (APB0_BASE + 0x24000)
983 #define GPIOINT_BASE          (APB0_BASE + 0x28080)
984 #define PINCON_BASE           (APB0_BASE + 0x2C000)
985 #define SSP1_BASE             (APB0_BASE + 0x30000)
986 #define ADC_BASE              (APB0_BASE + 0x34000)
987 #define CANAF_RAM_BASE        (APB0_BASE + 0x38000)
988 #define CANAF_BASE            (APB0_BASE + 0x3C000)
989 #define CANCR_BASE            (APB0_BASE + 0x40000)
990 #define CAN1_BASE             (APB0_BASE + 0x44000)
991 #define CAN2_BASE             (APB0_BASE + 0x48000)
992 #define I2C1_BASE             (APB0_BASE + 0x5C000)
993
994 /* APB1 peripherals                                                           */
995 #define SSP0_BASE             (APB1_BASE + 0x08000)
996 #define DAC_BASE              (APB1_BASE + 0x0C000)
997 #define TIM2_BASE             (APB1_BASE + 0x10000)
998 #define TIM3_BASE             (APB1_BASE + 0x14000)
999 #define UART2_BASE            (APB1_BASE + 0x18000)
1000 #define UART3_BASE            (APB1_BASE + 0x1C000)
1001 #define I2C2_BASE             (APB1_BASE + 0x20000)
1002 #define I2S_BASE              (APB1_BASE + 0x28000)
1003 #define RIT_BASE              (APB1_BASE + 0x30000)
1004 #define MCPWM_BASE            (APB1_BASE + 0x38000)
1005 #define QEI_BASE              (APB1_BASE + 0x3C000)
1006 #define SC_BASE               (APB1_BASE + 0x7C000)
1007
1008 /* AHB peripherals                                                            */
1009 #define EMAC_BASE             (AHB_BASE  + 0x00000)
1010 #define GPDMA_BASE            (AHB_BASE  + 0x04000)
1011 #define GPDMACH0_BASE         (AHB_BASE  + 0x04100)
1012 #define GPDMACH1_BASE         (AHB_BASE  + 0x04120)
1013 #define GPDMACH2_BASE         (AHB_BASE  + 0x04140)
1014 #define GPDMACH3_BASE         (AHB_BASE  + 0x04160)
1015 #define GPDMACH4_BASE         (AHB_BASE  + 0x04180)
1016 #define GPDMACH5_BASE         (AHB_BASE  + 0x041A0)
1017 #define GPDMACH6_BASE         (AHB_BASE  + 0x041C0)
1018 #define GPDMACH7_BASE         (AHB_BASE  + 0x041E0)
1019 #define USB_BASE              (AHB_BASE  + 0x0C000)
1020
1021 /* GPIOs                                                                      */
1022 #define GPIO0_BASE            (GPIO_BASE + 0x00000)
1023 #define GPIO1_BASE            (GPIO_BASE + 0x00020)
1024 #define GPIO2_BASE            (GPIO_BASE + 0x00040)
1025 #define GPIO3_BASE            (GPIO_BASE + 0x00060)
1026 #define GPIO4_BASE            (GPIO_BASE + 0x00080)
1027
1028 /**
1029  * @}
1030  */
1031
1032
1033 /** @addtogroup Peripheral_declaration
1034   * @{
1035   */
1036
1037 /******************************************************************************/
1038 /*                         Peripheral declaration                             */
1039 /******************************************************************************/
1040 #define SC                    ((     SC_TypeDef *)       SC_BASE)
1041 #define GPIO0                 ((   GPIO_TypeDef *)    GPIO0_BASE)
1042 #define GPIO1                 ((   GPIO_TypeDef *)    GPIO1_BASE)
1043 #define GPIO2                 ((   GPIO_TypeDef *)    GPIO2_BASE)
1044 #define GPIO3                 ((   GPIO_TypeDef *)    GPIO3_BASE)
1045 #define GPIO4                 ((   GPIO_TypeDef *)    GPIO4_BASE)
1046 #define WDT                   ((    WDT_TypeDef *)      WDT_BASE)
1047 #define TIM0                  ((    TIM_TypeDef *)     TIM0_BASE)
1048 #define TIM1                  ((    TIM_TypeDef *)     TIM1_BASE)
1049 #define TIM2                  ((    TIM_TypeDef *)     TIM2_BASE)
1050 #define TIM3                  ((    TIM_TypeDef *)     TIM3_BASE)
1051 #define RIT                   ((    RIT_TypeDef *)      RIT_BASE)
1052 #define UART0                 ((   UART_TypeDef *)    UART0_BASE)
1053 #define UART1                 ((  UART1_TypeDef *)    UART1_BASE)
1054 #define UART2                 ((   UART_TypeDef *)    UART2_BASE)
1055 #define UART3                 ((   UART_TypeDef *)    UART3_BASE)
1056 #define PWM1                  ((    PWM_TypeDef *)     PWM1_BASE)
1057 #define I2C0                  ((    I2C_TypeDef *)     I2C0_BASE)
1058 #define I2C1                  ((    I2C_TypeDef *)     I2C1_BASE)
1059 #define I2C2                  ((    I2C_TypeDef *)     I2C2_BASE)
1060 #define I2S                   ((    I2S_TypeDef *)      I2S_BASE)
1061 #define SPI                   ((    SPI_TypeDef *)      SPI_BASE)
1062 #define RTC                   ((    RTC_TypeDef *)      RTC_BASE)
1063 #define GPIOINT               ((GPIOINT_TypeDef *)  GPIOINT_BASE)
1064 #define PINCON                (( PINCON_TypeDef *)   PINCON_BASE)
1065 #define SSP0                  ((    SSP_TypeDef *)     SSP0_BASE)
1066 #define SSP1                  ((    SSP_TypeDef *)     SSP1_BASE)
1067 #define ADC                   ((    ADC_TypeDef *)      ADC_BASE)
1068 #define DAC                   ((    DAC_TypeDef *)      DAC_BASE)
1069 #define CANAF_RAM           ((CANAF_RAM_TypeDef *)CANAF_RAM_BASE)
1070 #define CANAF                 ((  CANAF_TypeDef *)    CANAF_BASE)
1071 #define CANCR                 ((  CANCR_TypeDef *)    CANCR_BASE)
1072 #define CAN1                  ((    CAN_TypeDef *)     CAN1_BASE)
1073 #define CAN2                  ((    CAN_TypeDef *)     CAN2_BASE)
1074 #define MCPWM                 ((  MCPWM_TypeDef *)    MCPWM_BASE)
1075 #define QEI                   ((    QEI_TypeDef *)      QEI_BASE)
1076 #define EMAC                  ((   EMAC_TypeDef *)     EMAC_BASE)
1077 #define GPDMA                 ((  GPDMA_TypeDef *)    GPDMA_BASE)
1078 #define DMAREQSEL             (*(__IO uint32_t *)  ( 0x4000C1C4))
1079 #define GPDMACH0              ((GPDMACH_TypeDef *) GPDMACH0_BASE)
1080 #define GPDMACH1              ((GPDMACH_TypeDef *) GPDMACH1_BASE)
1081 #define GPDMACH2              ((GPDMACH_TypeDef *) GPDMACH2_BASE)
1082 #define GPDMACH3              ((GPDMACH_TypeDef *) GPDMACH3_BASE)
1083 #define GPDMACH4              ((GPDMACH_TypeDef *) GPDMACH4_BASE)
1084 #define GPDMACH5              ((GPDMACH_TypeDef *) GPDMACH5_BASE)
1085 #define GPDMACH6              ((GPDMACH_TypeDef *) GPDMACH6_BASE)
1086 #define GPDMACH7              ((GPDMACH_TypeDef *) GPDMACH7_BASE)
1087 #define USB                   ((    USB_TypeDef *)      USB_BASE)
1088
1089 /**
1090  * @}
1091  */
1092
1093 #endif  // __LPC17xx_H__
1094
1095 /* End Of File ---------------------------------------------------------------- */