irq.c
上传用户:jndfzc
上传日期:2014-06-02
资源大小:325k
文件大小:4k
- #define __IRQ_C
- #include "irq.h"
- #include "define.h"
- #include "display.h"
- #include "P103_MMI2DSP.H"
- #include "maindef.h"
- #define SECOND 100
- /*0:FIQ,1:SWIRQ,2:US0IRQ,3:US1IRQ,4:TC0IRQ,5:TC1IRQ,6:TC2IRQ,7:WDIRQ,8:PIOIRQ, 16:IRQ0,17:IRQ1,18:IRQ2 */
- typedef void (* FunctionPtr)();
- const unsigned char RegOffset[12]={0x00,0x04,0x08,0x0c,0x10,0x14,0x18,0x1c,0x20,0x40,0x44,0x48};
- const unsigned char SMRValue[12]={0x60,0x60,0x60,0x60,0x65,0x60,0x60,0x60,0x60,0x60,0x60,0x60};
- const FunctionPtr HandlerArray[12]={
- FIQ_Handler,SWIRQ_Handler,
- US0IRQ_Handler,US1IRQ_Handler,
- TC0IRQ_Handler,TC1IRQ_Handler,TC2IRQ_Handler,
- WDIRQ_Handler,PIOIRQ_Handler,
- IRQ0IRQ_Handler,IRQ1IRQ_Handler,IRQ2IRQ_Handler
- };
- US usT_1000ms=0;
- UC ucsigned_1000ms_flag=0;
- UC ucsigned_60s=0;
- US ucsigned_60s_Count=0;
- extern UC time_modify_flag;
- void EnableIRQ(void)
- {
- int tmp;
- __asm
- {
- mrs tmp,CPSR
- bic tmp,tmp,#0x80
- msr CPSR_c,tmp // use CPSR_c instead of CPSR for ADS1.2
- }
- }
-
- // enable the F bit in current CPSR
- void EnableFIQ(void)
- {
- int tmp;
- __asm
- {
- mrs tmp,CPSR
- bic tmp,tmp,#0x40
- msr CPSR_c,tmp
- }
- }
- // disable the I bit in current CPSR
- void DisableIRQ(void)
- {
- int tmp;
- __asm
- {
- mrs tmp,CPSR
- orr tmp,tmp,#0x80
- msr CPSR_c,tmp
- }
- }
- // enable the F bit in current CPSR
- void DisableFIQ(void)
- {
- int tmp;
- __asm
- {
- mrs tmp,CPSR
- orr tmp,tmp,#0x40
- msr CPSR_c,tmp
- }
- }
- void Delay(unsigned int count)
- {
- unsigned int i, j;
-
- for(i = 0; i < count; i++)
- for(j = 0; j < 1650; j++);
- }
- void C_Undefined_Handler(void)
- {
- while(1);
- }
- void C_Prefetch_Handler(void)
- {
- while(1);
- }
- void C_Abort_Handler(void)
- {
- while(1);
- }
- void C_FIQ_Handler(void)
- {
- while(1);
- REG32_WRITE(AIC_EOICR,0x1);
- }
- void C_SWIRQ_Handler(void)
- {
- while(1);
- REG32_WRITE(AIC_EOICR,0x1);
- }
- void C_US0IRQ_Handler(void) //Sci0_Int
- {
- REG32_WRITE(AIC_EOICR,0x1);
- }
- //串口1中断
- void C_US1IRQ_Handler(void)
- {
- REG32_WRITE(AIC_EOICR,0x1);
- }
- void C_TC0IRQ_Handler(void)
- {
-
- // while(1);
- unsigned int i;
- /*中断计时*/
- WATCHDOG_OUT0;
- if(time_modify_flag==0)
- {
- usT_1000ms++;
- if( usT_1000ms >= 3*SECOND ) // 3秒
- { usT_1000ms=0;ucsigned_60s_Count++;
- ucsigned_1000ms_flag=1;
- }
- if( ucsigned_60s_Count>= 100 ) /*5min*/
- {
- ucsigned_60s_Count=0; ucsigned_60s=1;
-
- }
- }
- WATCHDOG_OUT1;
- Updata_key(RdPortE32(PIO_PDSR));
- CommDspTimeUpdate();
- WATCHDOG_OUT0;
- i=REG32_READ(TC0+TCSR);
- REG32_WRITE(AIC_EOICR,0x1);
- }
- void C_TC1IRQ_Handler(void)
- {
- unsigned int i;
- i=REG32_READ(TC1+TCSR);
- REG32_WRITE(AIC_EOICR,0x1);
- }
- void C_TC2IRQ_Handler(void)
- {
- while(1);
- REG32_WRITE(AIC_EOICR,0x1);
- }
- void C_WDIRQ_Handler(void) //Watch Dog Interrupt
- {
- REG32_WRITE(AIC_EOICR,0x1);
- }
- void C_PIOIRQ_Handler(void)
- {
- while(1);
- REG32_WRITE(AIC_EOICR,0x1);
- }
- void C_IRQ0IRQ_Handler(void)
- {
- while(1);
- REG32_WRITE(AIC_EOICR,0x1);
- }
- void C_IRQ1IRQ_Handler(void)
- {
- while(1);
- REG32_WRITE(AIC_EOICR,0x1);
- }
- void C_IRQ2IRQ_Handler(void)
- {
- while(1);
- REG32_WRITE(AIC_EOICR,0x1);
- }
- //中断初始化
- void Interrupt_Init(void)
- {
- int i;
- i=REG32_READ(AIC_IPR);
- REG32_WRITE(AIC_EOICR,0x1);
-
- REG32_WRITE(AIC_IDCR,0xFFFFFFFF);
- REG32_WRITE(AIC_ICCR,0xFFFFFFFF);
- for(i=0;i<12;i++){
- REG32_WRITE(AIC_SMR0+RegOffset[i],SMRValue[i]);
- REG32_WRITE(AIC_SVR0+RegOffset[i],(unsigned int)(HandlerArray[i]));
- }
- }
- //参数为EnumInitKind类型
- void Interrupt_Enable(EnumIntKind IntKind)
- {
- REG32_WRITE(AIC_IECR,IntKind);
- }
- void Interrupt_Disable(EnumIntKind IntKind)
- {
- REG32_WRITE(AIC_IDCR,IntKind);
- }