33 #ifndef _ARCH_ARM_NXP_LPC2XXX_CMSIS_H_
34 #define _ARCH_ARM_NXP_LPC2XXX_CMSIS_H_ 1
62 #define i_MCU_MODEL 2101
96 #if (i_MCU_MODEL >= 2300)
129 #define __MPU_PRESENT 0
130 #define __NVIC_PRIO_BITS 4
131 #define __Vendor_SysTickConfig 1
137 #if defined ( __CC_ARM )
146 #if i_MCU_MODEL >= 2300
162 #if i_MCU_MODEL >= 2300
174 #if i_MCU_MODEL >= 2300
183 #define VIC_MAX_IRQ_NUMBER (VIC_SIZE-1)
185 #if i_MCU_MODEL >= 2300
186 #define VIC_HIGHEST_PRIORITY 0x0
187 #define VIC_HIGH_PRIORITY ((1<<(__NVIC_PRIO_BITS - 2)) - 1)
188 #define VIC_MEDIUM_PRIORITY ((1<<(__NVIC_PRIO_BITS - 1)) - 1)
189 #define VIC_LOW_PRIORITY ((1<<(__NVIC_PRIO_BITS - 2))*3 - 1)
190 #define VIC_LOWEST_PRIORITY ((1<<(__NVIC_PRIO_BITS )) - 1)
194 #define VIC_ENABLE (1 << 5)
197 #define VIC_BIT(chan) (1 << (chan))
266 #if (i_MCU_MODEL > 2300)
268 #define LPC_SC_PLLCFG_OSCEN_Pos 5
269 #define LPC_SC_PLLCFG_OSCSTAT_Pos 6
270 #define LPC_SC_PLLCFG_NSEL_Pos 16
272 #define LPC_SC_PLLSTAT_PLLE_Pos 24
274 #define PLLCFG_Val (PLL_MValue | (PLL_NValue << 16))
276 #define LPC_SC_PLLCFG_NSEL_Pos 5
277 #define LPC_SC_PLLSTAT_PLLE_Pos 8
278 #define PLLCFG_Val (PLL_MValue | (PLL_NValue << 5))
280 #define LPC_SC_PLLSTAT_PLLC_Pos (LPC_SC_PLLSTAT_PLLE_Pos + 1)
281 #define LPC_SC_PLLSTAT_PLOCK_Pos (LPC_SC_PLLSTAT_PLLE_Pos + 2)
283 #define LPC_SC_MAM_MODE_DISABLED 0
284 #define LPC_SC_MAM_MODE_PARTIAL 1
285 #define LPC_SC_MAM_MODE_FULL 2
290 #define TIR_MR0I_Msk (1 << 0) // Interrupt flag for match channel 0
291 #define TIR_MR1I_Msk (1 << 1) // Interrupt flag for match channel 1
292 #define TIR_MR2I_Msk (1 << 2) // Interrupt flag for match channel 2
293 #define TIR_MR3I_Msk (1 << 3) // Interrupt flag for match channel 3
294 #define TIR_CR0I_Msk (1 << 4) // Interrupt flag for capture channel 0 event
295 #define TIR_CR1I_Msk (1 << 5) // Interrupt flag for capture channel 1 event
296 #define TIR_CR2I_Msk (1 << 6) // Interrupt flag for capture channel 2 event
297 #define TIR_CR3I_Msk (1 << 7) // Interrupt flag for capture channel 3 event
300 #define PWMIR_MR0I_Msk (1 << 0) // Interrupt flag for match channel 0
301 #define PWMIR_MR1I_Msk (1 << 1) // Interrupt flag for match channel 1
302 #define PWMIR_MR2I_Msk (1 << 2) // Interrupt flag for match channel 2
303 #define PWMIR_MR3I_Msk (1 << 3) // Interrupt flag for match channel 3
304 #define PWMIR_MR4I_Msk (1 << 8) // Interrupt flag for match channel 4
305 #define PWMIR_MR5I_Msk (1 << 9) // Interrupt flag for match channel 5
306 #define PWMIR_MR6I_Msk (1 << 10) // Interrupt flag for match channel 6
307 #define PWMIR_Msk (0x070F)
310 #define TCR_ENABLE_Msk (1 << 0)
311 #define TCR_RESET_Msk (1 << 1)
314 #define TMCR_MR0_I_Msk (1 << 0) // Enable Interrupt when MR0 matches TC
315 #define TMCR_MR0_R_Msk (1 << 1) // Enable Reset of TC upon MR0 match
316 #define TMCR_MR0_S_Msk (1 << 2) // Enable Stop of TC upon MR0 match
317 #define TMCR_MR1_I_Msk (1 << 3) // Enable Interrupt when MR1 matches TC
318 #define TMCR_MR1_R_Msk (1 << 4) // Enable Reset of TC upon MR1 match
319 #define TMCR_MR1_S_Msk (1 << 5) // Enable Stop of TC upon MR1 match
320 #define TMCR_MR2_I_Msk (1 << 6) // Enable Interrupt when MR2 matches TC
321 #define TMCR_MR2_R_Msk (1 << 7) // Enable Reset of TC upon MR2 match
322 #define TMCR_MR2_S_Msk (1 << 8) // Enable Stop of TC upon MR2 match
323 #define TMCR_MR3_I_Msk (1 << 9) // Enable Interrupt when MR3 matches TC
324 #define TMCR_MR3_R_Msk (1 << 10) // Enable Reset of TC upon MR3 match
325 #define TMCR_MR3_S_Msk (1 << 11) // Enable Stop of TC upon MR3 match
328 #define TCCR_CR0_R_Msk (1 << 0) // Enable Rising edge on CAPn.0 will load TC to CR0
329 #define TCCR_CR0_F_Msk (1 << 1) // Enable Falling edge on CAPn.0 will load TC to CR0
330 #define TCCR_CR0_I_Msk (1 << 2) // Enable Interrupt on load of CR0
331 #define TCCR_CR1_R_Msk (1 << 3) // Enable Rising edge on CAPn.1 will load TC to CR1
332 #define TCCR_CR1_F_Msk (1 << 4) // Enable Falling edge on CAPn.1 will load TC to CR1
333 #define TCCR_CR1_I_Msk (1 << 5) // Enable Interrupt on load of CR1
334 #define TCCR_CR2_R_Msk (1 << 6) // Enable Rising edge on CAPn.2 will load TC to CR2
335 #define TCCR_CR2_F_Msk (1 << 7) // Enable Falling edge on CAPn.2 will load TC to CR2
336 #define TCCR_CR2_I_Msk (1 << 8) // Enable Interrupt on load of CR2
337 #define TCCR_CR3_R_Msk (1 << 9) // Enable Rising edge on CAPn.3 will load TC to CR3
338 #define TCCR_CR3_F_Msk (1 << 10) // Enable Falling edge on CAPn.3 will load TC to CR3
339 #define TCCR_CR3_I_Msk (1 << 11) // Enable Interrupt on load of CR3
365 #define PWMCR_ENABLE_Msk (1 << 0)
366 #define PWMCR_RESET_Msk (1 << 1)
431 #define PINSEL_n(n) (*(REG32*)(LPC_PINSEL_BASE + (n<<2)))
433 #define LPC2XXX_PORT0 0
434 #define LPC2XXX_PORT1 1
435 #define LPC2XXX_PORT2 2
436 #define LPC2XXX_PORT3 3
437 #define LPC2XXX_PORT4 4
450 #define PORT_PIN_NUMBER(prt,number) (prt*32+number)
468 #define PORT_SELECT_PIN(number,value) PINSEL_n(number>>4) = \
469 (PINSEL_n(number>>4) & (~(3<<((number&0xf)<<1)))) | ((value&3)<<((number&0xf)<<1))
472 #define PORT_PIN_MODE_GPIO 0
474 #define PINMODE_n(n) (*(REG32*)(LPC_PINSEL_BASE + 0x40 + (n<<2)))
475 #define PINMODE_PULL_UP 0
476 #define PINMODE_DEFAULT PINMODE_PULL_UP
477 #define PINMODE_NO_PULL_ 2
478 #define PINMODE_PULL_DOWN 3
582 #define IO0_INT_EN_R (*(REG32*)(GPIO_BASE + 0x90))
583 #define IO0_INT_EN_F (*(REG32*)(GPIO_BASE + 0x94))
584 #define IO0_INT_STAT_R (*(REG32*)(GPIO_BASE + 0x84))
585 #define IO0_INT_STAT_F (*(REG32*)(GPIO_BASE + 0x88))
586 #define IO0_INT_CLR (*(REG32*)(GPIO_BASE + 0x8C))
588 #define IO2_INT_EN_R (*(REG32*)(GPIO_BASE + 0xB0))
589 #define IO2_INT_EN_F (*(REG32*)(GPIO_BASE + 0xB4))
590 #define IO2_INT_STAT_R (*(REG32*)(GPIO_BASE + 0xA4))
591 #define IO2_INT_STAT_F (*(REG32*)(GPIO_BASE + 0xA8))
592 #define IO2_INT_CLR (*(REG32*)(GPIO_BASE + 0xAC))
594 #define IO_INT_STAT (*(REG32*)(GPIO_BASE + 0x80))
596 #define PARTCFG (*(REG32*)(PARTCFG_BASE + 0x00))
598 #define FIOREG_BASE_ADDR_n(n,off) (*(REG32*)(FIO_BASE + (n<<5)+ off))
599 #define FIOREG_BASE_ADDR_n16(n,off) (*(REG16*)(FIO_BASE + (n<<5)+ off))
600 #define FIOREG_BASE_ADDR_n8(n,off) (*(REG8*)(FIO_BASE + (n<<5)+ off))
602 #define FIO0DIR FIOREG_BASE_ADDR_n(0,0)
603 #define FIO0MASK FIOREG_BASE_ADDR_n(0,0x10)
604 #define FIO0PIN FIOREG_BASE_ADDR_n(0,0x14)
605 #define FIO0SET FIOREG_BASE_ADDR_n(0,0x18)
606 #define FIO0CLR FIOREG_BASE_ADDR_n(0,0x1C)
613 #define PORT_DIRECTION_PIN(number,direction) \
614 FIOREG_BASE_ADDR_n(((number)>>5),0x00) = 1 << ((number)&0x1F); \
615 if ((number>>6) == 0){ \
620 #define PORT_SET_PIN(number) \
621 FIOREG_BASE_ADDR_n(((number)>>5),0x18) = 1 << ((number)&0x1F)
623 #define PORT_CLEAR_PIN(number) \
624 FIOREG_BASE_ADDR_n(((number)>>5),0x1C) = 1 << ((number)&0x1F)
626 #define PORT_GET_PIN(number) \
627 (FIOREG_BASE_ADDR_n(((number)>>5),0x14) &(1 << ((number)&0x1F)))
629 #define FIO1DIR FIOREG_BASE_ADDR_n(1,0)
630 #define FIO1MASK FIOREG_BASE_ADDR_n(1,0x10)
631 #define FIO1PIN FIOREG_BASE_ADDR_n(1,0x14)
632 #define FIO1SET FIOREG_BASE_ADDR_n(1,0x18)
633 #define FIO1CLR FIOREG_BASE_ADDR_n(1,0x1C)
635 #define FIO2DIR FIOREG_BASE_ADDR_n(2,0)
636 #define FIO2MASK FIOREG_BASE_ADDR_n(2,0x10)
637 #define FIO2PIN FIOREG_BASE_ADDR_n(2,0x14)
638 #define FIO2SET FIOREG_BASE_ADDR_n(2,0x18)
639 #define FIO2CLR FIOREG_BASE_ADDR_n(2,0x1C)
641 #define FIO3DIR FIOREG_BASE_ADDR_n(3,0)
642 #define FIO3MASK FIOREG_BASE_ADDR_n(3,0x10)
643 #define FIO3PIN FIOREG_BASE_ADDR_n(3,0x14)
644 #define FIO3SET FIOREG_BASE_ADDR_n(3,0x18)
645 #define FIO3CLR FIOREG_BASE_ADDR_n(3,0x1C)
647 #define FIO4DIR FIOREG_BASE_ADDR_n(4,0)
648 #define FIO4MASK FIOREG_BASE_ADDR_n(4,0x10)
649 #define FIO4PIN FIOREG_BASE_ADDR_n(4,0x14)
650 #define FIO4SET FIOREG_BASE_ADDR_n(4,0x18)
651 #define FIO4CLR FIOREG_BASE_ADDR_n(4,0x1C)
655 #define FIO0DIR0 FIOREG_BASE_ADDR_n8(0,0)
656 #define FIO1DIR0 FIOREG_BASE_ADDR_n8(1,0)
657 #define FIO2DIR0 FIOREG_BASE_ADDR_n8(2,0)
658 #define FIO3DIR0 FIOREG_BASE_ADDR_n8(3,0)
659 #define FIO4DIR0 FIOREG_FIOREG_BASE_ADDR_n8BASE_ADDR_n8(4,0)
661 #define FIO0DIR1 FIOREG_BASE_ADDR_n8(0,1)
662 #define FIO1DIR1 FIOREG_BASE_ADDR_n8(1,1)
663 #define FIO2DIR1 FIOREG_BASE_ADDR_n8(2,1)
664 #define FIO3DIR1 FIOREG_BASE_ADDR_n8(3,1)
665 #define FIO4DIR1 FIOREG_BASE_ADDR_n8(4,1)
667 #define FIO0DIR2 FIOREG_BASE_ADDR_n8(0,2)
668 #define FIO1DIR2 FIOREG_BASE_ADDR_n8(1,2)
669 #define FIO2DIR2 FIOREG_BASE_ADDR_n8(2,2)
670 #define FIO3DIR2 FIOREG_BASE_ADDR_n8(3,2)
671 #define FIO4DIR2 FIOREG_BASE_ADDR_n8(4,2)
673 #define FIO0DIR3 FIOREG_BASE_ADDR_n8(0,3)
674 #define FIO1DIR3 FIOREG_BASE_ADDR_n8(1,3)
675 #define FIO2DIR3 FIOREG_BASE_ADDR_n8(2,3)
676 #define FIO3DIR3 FIOREG_BASE_ADDR_n8(3,3)
677 #define FIO4DIR3 FIOREG_BASE_ADDR_n8(4,3)
679 #define FIO0DIRL FIOREG_BASE_ADDR_n16(0,0)
680 #define FIO1DIRL FIOREG_BASE_ADDR_n16(1,0)
681 #define FIO2DIRL FIOREG_BASE_ADDR_n16(2,0)
682 #define FIO3DIRL FIOREG_BASE_ADDR_n16(3,0)
683 #define FIO4DIRL FIOREG_BASE_ADDR_n16(4,0)
685 #define FIO0DIRU FIOREG_BASE_ADDR_n16(0,2)
686 #define FIO1DIRU FIOREG_BASE_ADDR_n16(1,2)
687 #define FIO2DIRU FIOREG_BASE_ADDR_n16(2,2)
688 #define FIO3DIRU FIOREG_BASE_ADDR_n16(3,2)
689 #define FIO4DIRU FIOREG_BASE_ADDR_n16(4,2)
691 #define FIOREG_BASE_ADDR_n8_FIOMASK(letter1,letter2) \
692 FIOREG_BASE_ADDR_n8(letter1,0x10+letter2)
694 #define FIO0MASK0 FIOREG_BASE_ADDR_n8_FIOMASK(0,0)
695 #define FIO1MASK0 FIOREG_BASE_ADDR_n8_FIOMASK(1,0)
696 #define FIO2MASK0 FIOREG_BASE_ADDR_n8_FIOMASK(2,0)
697 #define FIO3MASK0 FIOREG_BASE_ADDR_n8_FIOMASK(3,0)
698 #define FIO4MASK0 FIOREG_BASE_ADDR_n8_FIOMASK(4,0)
700 #define FIO0MASK1 FIOREG_BASE_ADDR_n8_FIOMASK(0,1)
701 #define FIO1MASK1 FIOREG_BASE_ADDR_n8_FIOMASK(1,1)
702 #define FIO2MASK1 FIOREG_BASE_ADDR_n8_FIOMASK(2,1)
703 #define FIO3MASK1 FIOREG_BASE_ADDR_n8_FIOMASK(3,1)
704 #define FIO4MASK1 FIOREG_BASE_ADDR_n8_FIOMASK(4,1)
706 #define FIO0MASK2 FIOREG_BASE_ADDR_n8_FIOMASK(0,2)
707 #define FIO1MASK2 FIOREG_BASE_ADDR_n8_FIOMASK(1,2)
708 #define FIO2MASK2 FIOREG_BASE_ADDR_n8_FIOMASK(2,2)
709 #define FIO3MASK2 FIOREG_BASE_ADDR_n8_FIOMASK(3,2)
710 #define FIO4MASK2 FIOREG_BASE_ADDR_n8_FIOMASK(4,2)
712 #define FIO0MASK3 FIOREG_BASE_ADDR_n8_FIOMASK(0,3)
713 #define FIO1MASK3 FIOREG_BASE_ADDR_n8_FIOMASK(1,3)
714 #define FIO2MASK3 FIOREG_BASE_ADDR_n8_FIOMASK(2,3)
715 #define FIO3MASK3 FIOREG_BASE_ADDR_n8_FIOMASK(3,3)
716 #define FIO4MASK3 FIOREG_BASE_ADDR_n8_FIOMASK(4,3)
718 #define FIOREG_BASE_ADDR_n16_FIOMASKL(letter1) \
719 FIOREG_BASE_ADDR_n16(letter1,0x10)
721 #define FIOREG_BASE_ADDR_n16_FIOMASKU(letter1) \
722 FIOREG_BASE_ADDR_n16(letter1,0x12)
724 #define FIO0MASKL FIOREG_BASE_ADDR_n16_FIOMASKL(0)
725 #define FIO1MASKL FIOREG_BASE_ADDR_n16_FIOMASKL(1)
726 #define FIO2MASKL FIOREG_BASE_ADDR_n16_FIOMASKL(2)
727 #define FIO3MASKL FIOREG_BASE_ADDR_n16_FIOMASKL(3)
728 #define FIO4MASKL FIOREG_BASE_ADDR_n16_FIOMASKL(4)
730 #define FIO0MASKU FIOREG_BASE_ADDR_n16_FIOMASKU(0)
731 #define FIO1MASKU FIOREG_BASE_ADDR_n16_FIOMASKU(1)
732 #define FIO2MASKU FIOREG_BASE_ADDR_n16_FIOMASKU(2)
733 #define FIO3MASKU FIOREG_BASE_ADDR_n16_FIOMASKU(3)
734 #define FIO4MASKU FIOREG_BASE_ADDR_n16_FIOMASKU(4)
736 #define FIO0PIN0 (*(volatile unsigned char *)(FIO_BASE + 0x14))
737 #define FIO1PIN0 (*(volatile unsigned char *)(FIO_BASE + 0x34))
738 #define FIO2PIN0 (*(volatile unsigned char *)(FIO_BASE + 0x54))
739 #define FIO3PIN0 (*(volatile unsigned char *)(FIO_BASE + 0x74))
740 #define FIO4PIN0 (*(volatile unsigned char *)(FIO_BASE + 0x94))
742 #define FIO0PIN1 (*(volatile unsigned char *)(FIO_BASE + 0x15))
743 #define FIO1PIN1 (*(volatile unsigned char *)(FIO_BASE + 0x35))
744 #define FIO2PIN1 (*(volatile unsigned char *)(FIO_BASE + 0x55))
745 #define FIO3PIN1 (*(volatile unsigned char *)(FIO_BASE + 0x75))
746 #define FIO4PIN1 (*(volatile unsigned char *)(FIO_BASE + 0x95))
748 #define FIO0PIN2 (*(volatile unsigned char *)(FIO_BASE + 0x16))
749 #define FIO1PIN2 (*(volatile unsigned char *)(FIO_BASE + 0x36))
750 #define FIO2PIN2 (*(volatile unsigned char *)(FIO_BASE + 0x56))
751 #define FIO3PIN2 (*(volatile unsigned char *)(FIO_BASE + 0x76))
752 #define FIO4PIN2 (*(volatile unsigned char *)(FIO_BASE + 0x96))
754 #define FIO0PIN3 (*(volatile unsigned char *)(FIO_BASE + 0x17))
755 #define FIO1PIN3 (*(volatile unsigned char *)(FIO_BASE + 0x37))
756 #define FIO2PIN3 (*(volatile unsigned char *)(FIO_BASE + 0x57))
757 #define FIO3PIN3 (*(volatile unsigned char *)(FIO_BASE + 0x77))
758 #define FIO4PIN3 (*(volatile unsigned char *)(FIO_BASE + 0x97))
760 #define FIO0PINL (*(volatile unsigned short *)(FIO_BASE + 0x14))
761 #define FIO1PINL (*(volatile unsigned short *)(FIO_BASE + 0x34))
762 #define FIO2PINL (*(volatile unsigned short *)(FIO_BASE + 0x54))
763 #define FIO3PINL (*(volatile unsigned short *)(FIO_BASE + 0x74))
764 #define FIO4PINL (*(volatile unsigned short *)(FIO_BASE + 0x94))
766 #define FIO0PINU (*(volatile unsigned short *)(FIO_BASE + 0x16))
767 #define FIO1PINU (*(volatile unsigned short *)(FIO_BASE + 0x36))
768 #define FIO2PINU (*(volatile unsigned short *)(FIO_BASE + 0x56))
769 #define FIO3PINU (*(volatile unsigned short *)(FIO_BASE + 0x76))
770 #define FIO4PINU (*(volatile unsigned short *)(FIO_BASE + 0x96))
772 #define FIO0SET0 (*(volatile unsigned char *)(FIO_BASE + 0x18))
773 #define FIO1SET0 (*(volatile unsigned char *)(FIO_BASE + 0x38))
774 #define FIO2SET0 (*(volatile unsigned char *)(FIO_BASE + 0x58))
775 #define FIO3SET0 (*(volatile unsigned char *)(FIO_BASE + 0x78))
776 #define FIO4SET0 (*(volatile unsigned char *)(FIO_BASE + 0x98))
778 #define FIO0SET1 (*(volatile unsigned char *)(FIO_BASE + 0x19))
779 #define FIO1SET1 (*(volatile unsigned char *)(FIO_BASE + 0x29))
780 #define FIO2SET1 (*(volatile unsigned char *)(FIO_BASE + 0x59))
781 #define FIO3SET1 (*(volatile unsigned char *)(FIO_BASE + 0x79))
782 #define FIO4SET1 (*(volatile unsigned char *)(FIO_BASE + 0x99))
784 #define FIO0SET2 (*(volatile unsigned char *)(FIO_BASE + 0x1A))
785 #define FIO1SET2 (*(volatile unsigned char *)(FIO_BASE + 0x3A))
786 #define FIO2SET2 (*(volatile unsigned char *)(FIO_BASE + 0x5A))
787 #define FIO3SET2 (*(volatile unsigned char *)(FIO_BASE + 0x7A))
788 #define FIO4SET2 (*(volatile unsigned char *)(FIO_BASE + 0x9A))
790 #define FIO0SET3 (*(volatile unsigned char *)(FIO_BASE + 0x1B))
791 #define FIO1SET3 (*(volatile unsigned char *)(FIO_BASE + 0x3B))
792 #define FIO2SET3 (*(volatile unsigned char *)(FIO_BASE + 0x5B))
793 #define FIO3SET3 (*(volatile unsigned char *)(FIO_BASE + 0x7B))
794 #define FIO4SET3 (*(volatile unsigned char *)(FIO_BASE + 0x9B))
796 #define FIO0SETL (*(volatile unsigned short *)(FIO_BASE + 0x18))
797 #define FIO1SETL (*(volatile unsigned short *)(FIO_BASE + 0x38))
798 #define FIO2SETL (*(volatile unsigned short *)(FIO_BASE + 0x58))
799 #define FIO3SETL (*(volatile unsigned short *)(FIO_BASE + 0x78))
800 #define FIO4SETL (*(volatile unsigned short *)(FIO_BASE + 0x98))
802 #define FIO0SETU (*(volatile unsigned short *)(FIO_BASE + 0x1A))
803 #define FIO1SETU (*(volatile unsigned short *)(FIO_BASE + 0x3A))
804 #define FIO2SETU (*(volatile unsigned short *)(FIO_BASE + 0x5A))
805 #define FIO3SETU (*(volatile unsigned short *)(FIO_BASE + 0x7A))
806 #define FIO4SETU (*(volatile unsigned short *)(FIO_BASE + 0x9A))
808 #define FIO0CLR0 (*(volatile unsigned char *)(FIO_BASE + 0x1C))
809 #define FIO1CLR0 (*(volatile unsigned char *)(FIO_BASE + 0x3C))
810 #define FIO2CLR0 (*(volatile unsigned char *)(FIO_BASE + 0x5C))
811 #define FIO3CLR0 (*(volatile unsigned char *)(FIO_BASE + 0x7C))
812 #define FIO4CLR0 (*(volatile unsigned char *)(FIO_BASE + 0x9C))
814 #define FIO0CLR1 (*(volatile unsigned char *)(FIO_BASE + 0x1D))
815 #define FIO1CLR1 (*(volatile unsigned char *)(FIO_BASE + 0x2D))
816 #define FIO2CLR1 (*(volatile unsigned char *)(FIO_BASE + 0x5D))
817 #define FIO3CLR1 (*(volatile unsigned char *)(FIO_BASE + 0x7D))
818 #define FIO4CLR1 (*(volatile unsigned char *)(FIO_BASE + 0x9D))
820 #define FIO0CLR2 (*(volatile unsigned char *)(FIO_BASE + 0x1E))
821 #define FIO1CLR2 (*(volatile unsigned char *)(FIO_BASE + 0x3E))
822 #define FIO2CLR2 (*(volatile unsigned char *)(FIO_BASE + 0x5E))
823 #define FIO3CLR2 (*(volatile unsigned char *)(FIO_BASE + 0x7E))
824 #define FIO4CLR2 (*(volatile unsigned char *)(FIO_BASE + 0x9E))
826 #define FIO0CLR3 (*(volatile unsigned char *)(FIO_BASE + 0x1F))
827 #define FIO1CLR3 (*(volatile unsigned char *)(FIO_BASE + 0x3F))
828 #define FIO2CLR3 (*(volatile unsigned char *)(FIO_BASE + 0x5F))
829 #define FIO3CLR3 (*(volatile unsigned char *)(FIO_BASE + 0x7F))
830 #define FIO4CLR3 (*(volatile unsigned char *)(FIO_BASE + 0x9F))
832 #define FIO0CLRU (*(volatile unsigned short *)(FIO_BASE + 0x1E))
833 #define FIO1CLRU (*(volatile unsigned short *)(FIO_BASE + 0x3E))
834 #define FIO2CLRU (*(volatile unsigned short *)(FIO_BASE + 0x5E))
835 #define FIO3CLRU (*(volatile unsigned short *)(FIO_BASE + 0x7E))
836 #define FIO4CLRU (*(volatile unsigned short *)(FIO_BASE + 0x9E))
854 #ifndef UART_0_TX_PIN_NUMBER
855 #if i_MCU_MODEL >= 2300
856 #define UART_0_TX_PIN_NUMBER PORT_PIN_NUMBER(LPC2XXX_PORT0,2)
858 #define UART_0_TX_PIN_NUMBER PORT_PIN_NUMBER(LPC2XXX_PORT0,0)
862 #ifndef UART_0_RX_PIN_NUMBER
863 #define UART_0_RX_PIN_NUMBER (UART_0_TX_PIN_NUMBER+1)
865 #ifndef UART_0_TX_PIN_SELECT
866 #define UART_0_TX_PIN_SELECT 1
868 #ifndef UART_0_RX_PIN_SELECT
869 #define UART_0_RX_PIN_SELECT UART_0_TX_PIN_SELECT
872 #ifndef UART_1_TX_PIN_NUMBER
873 #if i_MCU_MODEL >= 2300
874 #define UART_1_TX_PIN_NUMBER PORT_PIN_NUMBER(LPC2XXX_PORT0,10)
876 #define UART_1_TX_PIN_NUMBER PORT_PIN_NUMBER(LPC2XXX_PORT0,8)
881 #ifndef UART_1_RX_PIN_NUMBER
882 #define UART_1_RX_PIN_NUMBER (UART_1_TX_PIN_NUMBER+1)
884 #ifndef UART_1_TX_PIN_SELECT
885 #define UART_1_TX_PIN_SELECT 1
887 #ifndef UART_1_RX_PIN_SELECT
888 #define UART_1_RX_PIN_SELECT UART_1_TX_PIN_SELECT
890 #if i_MCU_MODEL >= 2300
891 #ifndef UART_2_TX_PIN_NUMBER
892 #define UART_2_TX_PIN_NUMBER PORT_PIN_NUMBER(LPC2XXX_PORT0,10)
894 #ifndef UART_2_RX_PIN_NUMBER
895 #define UART_2_RX_PIN_NUMBER (UART_2_TX_PIN_NUMBER+1)
897 #ifndef UART_2_TX_PIN_SELECT
898 #define UART_2_TX_PIN_SELECT 1
900 #ifndef UART_2_RX_PIN_SELECT
901 #define UART_2_RX_PIN_SELECT UART_2_TX_PIN_SELECT
907 #ifndef UART_3_TX_PIN_NUMBER
908 #define UART_3_TX_PIN_NUMBER PORT_PIN_NUMBER(LPC2XXX_PORT0,25)
910 #ifndef UART_3_RX_PIN_NUMBER
911 #define UART_3_RX_PIN_NUMBER (UART_3_TX_PIN_NUMBER+1)
913 #ifndef UART_3_TX_PIN_SELECT
914 #define UART_3_TX_PIN_SELECT 3
916 #ifndef UART_3_RX_PIN_SELECT
917 #define UART_3_RX_PIN_SELECT UART_3_TX_PIN_SELECT
1039 #if i_MCU_MODEL >= 2300
1040 #ifndef SPI_0_SCK_PIN_NUMBER
1041 #define SPI_0_SCK_PIN_NUMBER PORT_PIN_NUMBER(LPC2XXX_PORT0,15)
1043 #ifndef SPI_0_SEL_PIN_NUMBER
1044 #define SPI_0_SEL_PIN_NUMBER (SPI_0_SCK_PIN_NUMBER + 1)
1046 #ifndef SPI_0_MISO_PIN_NUMBER
1047 #define SPI_0_MISO_PIN_NUMBER (SPI_0_SCK_PIN_NUMBER + 2)
1049 #ifndef SPI_0_ALL_PIN_SELECT
1050 #define SPI_0_ALL_PIN_SELECT 3
1052 #ifndef SSP_0_ALL_PIN_SELECT
1053 #define SSP_0_ALL_PIN_SELECT 2
1056 #ifndef SPI_0_ALL_PIN_SELECT
1057 #define SPI_0_ALL_PIN_SELECT 2
1060 #ifndef SPI_0_SCK_PIN_NUMBER
1061 #define SPI_0_SCK_PIN_NUMBER PORT_PIN_NUMBER(LPC2XXX_PORT0,4)
1063 #ifndef SPI_0_MISO_PIN_NUMBER
1064 #define SPI_0_MISO_PIN_NUMBER (SPI_0_SCK_PIN_NUMBER + 1)
1066 #ifndef SPI_0_SEL_PIN_NUMBER
1067 #define SPI_0_SEL_PIN_NUMBER (SPI_0_SCK_PIN_NUMBER + 3)
1072 #ifndef SPI_0_MOSI_PIN_NUMBER
1073 #define SPI_0_MOSI_PIN_NUMBER (SPI_0_MISO_PIN_NUMBER + 1)
1273 #if (i_MCU_MODEL >= 2300)
1335 #if (i_MCU_MODEL >= 2470)
1370 #if (i_MCU_MODEL >= 2420)
1716 #if defined ( __CC_ARM )
1717 #pragma no_anon_unions
1722 #define VIC ((VIC_TypeDef *) VIC_BASE )
1724 #define LPC_SC ((LPC_SC_TypeDef *) LPC_SC_BASE )
1726 #define LPC_IO ((LPC_IO_TypeDef_old *) LPC_GPIO_BASE )
1727 #define LPC_IO0 ((LPC_IO_TypeDef_old *) LPC_GPIO_BASE )
1728 #define LPC_IO1 ((LPC_IO_TypeDef_old *) LPC_GPIO_BASE + 0x10)
1730 #define LPC_GPIO0 ((LPC_GPIO_TypeDef *) LPC_GPIO0_BASE )
1731 #define LPC_GPIO1 ((LPC_GPIO_TypeDef *) LPC_GPIO1_BASE )
1732 #define LPC_GPIO2 ((LPC_GPIO_TypeDef *) LPC_GPIO2_BASE )
1733 #define LPC_GPIO3 ((LPC_GPIO_TypeDef *) LPC_GPIO3_BASE )
1734 #define LPC_GPIO4 ((LPC_GPIO_TypeDef *) LPC_GPIO4_BASE )
1735 #define LPC_WDT ((LPC_WDT_TypeDef *) LPC_WDT_BASE )
1736 #define LPC_TIM0 ((LPC_TIM_TypeDef *) LPC_TIM0_BASE )
1737 #define LPC_TIM1 ((LPC_TIM_TypeDef *) LPC_TIM1_BASE )
1738 #define LPC_TIM2 ((LPC_TIM_TypeDef *) LPC_TIM2_BASE )
1739 #define LPC_TIM3 ((LPC_TIM_TypeDef *) LPC_TIM3_BASE )
1740 #define LPC_RIT ((LPC_RIT_TypeDef *) LPC_RIT_BASE )
1741 #define LPC_UART0 ((LPC_UART_TypeDef *) LPC_UART0_BASE )
1742 #define LPC_UART1 ((LPC_UART1_TypeDef *) LPC_UART1_BASE )
1743 #define LPC_UART2 ((LPC_UART_TypeDef *) LPC_UART2_BASE )
1744 #define LPC_UART3 ((LPC_UART_TypeDef *) LPC_UART3_BASE )
1745 #define LPC_PWM0 ((LPC_PWM_TypeDef *) LPC_PWM0_BASE )
1746 #define LPC_PWM1 ((LPC_PWM_TypeDef *) LPC_PWM1_BASE )
1747 #define LPC_I2C0 ((LPC_I2C_TypeDef *) LPC_I2C0_BASE )
1748 #define LPC_I2C1 ((LPC_I2C_TypeDef *) LPC_I2C1_BASE )
1749 #define LPC_I2C2 ((LPC_I2C_TypeDef *) LPC_I2C2_BASE )
1751 #define LPC_SPI ((LPC_SPI_TypeDef *) LPC_SPI_BASE )
1752 #define LPC_RTC ((LPC_RTC_TypeDef *) LPC_RTC_BASE )
1753 #define LPC_GPIOINT ((LPC_GPIOINT_TypeDef *) LPC_GPIOINT_BASE )
1754 #define LPC_PINCON ((LPC_PINCON_TypeDef *) LPC_PINSEL_BASE )
1755 #define LPC_SSP0 ((LPC_SSP_TypeDef *) LPC_SSP0_BASE )
1756 #define LPC_SSP1 ((LPC_SSP_TypeDef *) LPC_SSP1_BASE )
1757 #define LPC_ADC ((LPC_ADC_TypeDef *) LPC_AD0_BASE )
1758 #define LPC_DAC ((LPC_DAC_TypeDef *) LPC_DAC_BASE )
1759 #define LPC_CANAF_RAM ((LPC_CANAF_RAM_TypeDef *) LPC_CANAF_RAM_BASE)
1760 #define LPC_CANAF ((LPC_CANAF_TypeDef *) LPC_CANAF_BASE )
1761 #define LPC_CANCR ((LPC_CANCR_TypeDef *) LPC_CANCR_BASE )
1762 #define LPC_CAN1 ((LPC_CAN_TypeDef *) LPC_CAN1_BASE )
1763 #define LPC_CAN2 ((LPC_CAN_TypeDef *) LPC_CAN2_BASE )
1764 #define LPC_MCPWM ((LPC_MCPWM_TypeDef *) LPC_MCPWM_BASE )
1765 #define LPC_QEI ((LPC_QEI_TypeDef *) LPC_QEI_BASE )
1767 #if (i_MCU_MODEL >= 2300)
1769 #define LPC_MCI ((LPC_MCI_TypeDef *) LPC_MCI_BASE )
1770 #define LPC_EMAC ((LPC_EMAC_TypeDef *) LPC_EMAC_BASE )
1771 #define LPC_GPDMA ((LPC_GPDMA_TypeDef *) LPC_GPDMA_BASE )
1772 #define LPC_I2S ((LPC_I2S_TypeDef *) LPC_I2S_BASE )
1773 #define LPC_GPDMACH0 ((LPC_GPDMACH_TypeDef *) LPC_GPDMACH0_BASE )
1774 #define LPC_GPDMACH1 ((LPC_GPDMACH_TypeDef *) LPC_GPDMACH1_BASE )
1775 #define LPC_GPDMACH2 ((LPC_GPDMACH_TypeDef *) LPC_GPDMACH2_BASE )
1776 #define LPC_GPDMACH3 ((LPC_GPDMACH_TypeDef *) LPC_GPDMACH3_BASE )
1777 #define LPC_GPDMACH4 ((LPC_GPDMACH_TypeDef *) LPC_GPDMACH4_BASE )
1778 #define LPC_GPDMACH5 ((LPC_GPDMACH_TypeDef *) LPC_GPDMACH5_BASE )
1779 #define LPC_GPDMACH6 ((LPC_GPDMACH_TypeDef *) LPC_GPDMACH6_BASE )
1780 #define LPC_GPDMACH7 ((LPC_GPDMACH_TypeDef *) LPC_GPDMACH7_BASE )
1781 #define LPC_USB ((LPC_USB_TypeDef *) LPC_USBHC_BASE)
1782 #if (i_MCU_MODEL >= 2420)
1783 #define LPC_EMC ((LPC_EMC_TypeDef *) LPC_EMC_BASE )
1796 #if defined(__cplusplus)
1799 #define NULL ((void *)0)
1826 ISR_ptr_type isr_func;
1830 VIC->VectCntl[
IRQn] = priority & 0xF;