lpc2000 arm7的中断设定如果每次都写比较讨厌,如下的方法,可以使设置多个中断时候,比较简化
/////interrupt.h//////////////
#ifndef _INTERRUPT_H #define _INTERRUPT_H
#include <lpc2103.h>
#define WDT 0 #define T0 4 #define T1 5 #define UART0 6 #define UART1 7 #define I2C0 9 #define SPI0 10 #define SSP 11 #define PLL 12 #define RTC 13 #define EINT0 14 #define EINT1 15 #define EINT2 16 #define ADC 18 #define I2C1 19 #define T2 26 #define T3 27
#define BASE_VIC_VECT_ADDR 0xFFFFF100 #define BASE_VIC_VECT_CNTL 0xFFFFF200
void InitInterrupt(void); void SetInterrupt(unsigned char intSource,unsigned long irqAddr,unsigned char intPRI);
#endif
///////////////interrupt.c////////////////
#include "interrupt.h"
void InitInterrupt() { VICIntSelect = 0;//全部为IRQ,无FRQ VICIntEnable = 0; }
//参数为中断源,中断处理函数地址,中断优先级 void SetInterrupt(unsigned char intSource,unsigned long irqAddr,unsigned char intPRI) { (*((volatile unsigned long *) (BASE_VIC_VECT_ADDR+(intPRI<<2)))) = (unsigned long)irqAddr;//VICVectAddrn = (*((volatile unsigned long *) (BASE_VIC_VECT_CNTL+(intPRI<<2)))) = (0x00000020|intSource);//VICVectCntln = VICIntEnable |= (0x01<<intSource); }
要使用T0中断 SetInterrupt(T0,(unsigned long)T0IRQ,0); 即可
要使用ADC中断 SetInterrupt(ADC,(unsigned long)ADCIRQ,1); 即可
一次预定义好,不必都去查中断号,使用起来比较方便
|