📄 interrupt.c
字号:
//
else if (ulVic1Irq & INT1_TOUCH)
{
*VIC1_INTCLEAR = INT1_TOUCH;
//RETAILMSG(1, (TEXT("TOUCH\r\n")));
// *VIC1_INTENABLE=INT1_TOUCH;
if( !gfResumeFlag )
{
if( *RTC_DR - dwTimeValueWhenSuspend < 1 ) //10 ms, the time1 is running at 508k Hz
{
*TOUCH_TSSETUP2=0x0; // Clear Touch panel interrupt from the device.
*VIC1_INTENABLE=INT1_TOUCH;
}
else
retval = SYSINTR_TOUCH;
}
else
{
// RETAILMSG(1, (TEXT("TOUCH %d\r\n"),dwWakeupSourceIgnored));
retval = SYSINTR_TOUCH;
}
}
//
// See if it is timer 2 also used for the touch interface.
//
else if (ulVic1Irq & INT1_TIMER2)
{
*VIC1_INTCLEAR = INT1_TIMER2;
retval = SYSINTR_TIMER2;
}
#ifdef EDB9315A_CIR
//
// Check to see if it is the GPIO interrupt
//
else if(ulVic2Irq & INT2_GPIO)
{
//
// Check to see if it is the GPIO interrupt from IRDA
//
if( (*GPIO_INTSTATUSB & 0x20) == 0x20 )
{
UINT value;
UINT dir;
value = *GPIO_BINTEN;
value &= ~0x20;
*GPIO_BINTEN = value; // Disable all interrupt.
*GPIO_BEOI = 0x20; // Clean all previous interrupt
//OEMWriteDebugByte('H');
//OEMWriteDebugByte('\r');
//OEMWriteDebugByte('\n');
value = *GPIO_BINTTYPE1;
value |= 0x20; // edge trigure.
*GPIO_BINTTYPE1 = value;
// change direction
value = *GPIO_BINTTYPE2;
if( value & 0x20 )
{
value &=0xDF; // falling edge
//OEMWriteDebugByte('R');
dir = 1;
}
else
{
value |= 0x20; // Rising edge
//OEMWriteDebugByte('F');
dir = 0;
}
*GPIO_BINTTYPE2 = value;
value = *GPIO_BINTEN;
value |= 0x20; // Enable interrupt
*GPIO_BINTEN = value;
*VIC2_INTCLEAR = INT2_GPIO;
*VIC2_INTENABLE = INT2_GPIO;
retval = SYSINTR_NOP;
{
LARGE_INTEGER ulTime;
LARGE_INTEGER ulTimeLast;
int dif =0;
//int i;
BOOL bValid = TRUE;
OEMQueryPerformanceCounter( (LARGE_INTEGER*) &ulTime );
// If this is one valid pulse.
if( gnWi>0 )
{
ulTimeLast = gulIntTime[gnWi-1];
dif = (int)(ulTime.QuadPart - ulTimeLast.QuadPart);
if( dif < gnMinInterval )
{
//OEMWriteDebugByte('<');
bValid = FALSE;
}
if( dif > gnMaxInterval )
{
//OEMWriteDebugByte('>');
bValid = FALSE;
}
if(bValid)
{
gnIntDif[gnWi-1]=(dif>1000)?1:0;
gnKeyCode = (gnKeyCode << 1) | ((dif>1000)?0x1:0x0);
}
}
if( bValid )
{
//OEMWriteDebugByte('V');
gulIntTime[gnWi] = ulTime;
gnWi++;
if(gnWi==26)
{
int k;
#if 0
{
int j;
for( j=0; j<25; j++)
{
if(gnIntDif[j]==0)
OEMWriteDebugByte('.');
else
OEMWriteDebugByte('*');
}
}
#endif
// tell what key it is before reset key code.
gstrKeyName = gstrKeyNameTable[10];
for( k=0; k<10; k++)
if( gnKeyCode == gnKeyTable[k] )
gstrKeyName = gstrKeyNameTable[k];
gnWi=0;
gnKeyCode = 0;
//OEMWriteDebugByte('O');
//OEMWriteDebugByte('\r');
//OEMWriteDebugByte('\n');
retval = SYSINTR_PIO_CIR;
//RETAILMSG(1, (TEXT("key: %s \r\n"), gstrKeyName));
}
}
else
{
#if 0
{
switch( gnWi )
{
case 0:
OEMWriteDebugByte('0');
break;
case 1:
OEMWriteDebugByte('1');
break;
case 2:
OEMWriteDebugByte('2');
break;
case 3:
OEMWriteDebugByte('3');
break;
case 4:
OEMWriteDebugByte('4');
break;
case 5:
OEMWriteDebugByte('5');
break;
case 6:
OEMWriteDebugByte('6');
break;
case 7:
OEMWriteDebugByte('7');
break;
case 8:
OEMWriteDebugByte('8');
break;
case 9:
OEMWriteDebugByte('9');
break;
case 10:
OEMWriteDebugByte('a');
break;
case 11:
OEMWriteDebugByte('b');
break;
case 12:
OEMWriteDebugByte('c');
break;
case 13:
OEMWriteDebugByte('d');
break;
case 14:
OEMWriteDebugByte('e');
break;
case 15:
OEMWriteDebugByte('f');
break;
case 16:
OEMWriteDebugByte('g');
break;
case 17:
OEMWriteDebugByte('h');
break;
case 18:
OEMWriteDebugByte('i');
break;
case 19:
OEMWriteDebugByte('j');
break;
case 20:
OEMWriteDebugByte('k');
break;
case 21:
OEMWriteDebugByte('l');
break;
case 22:
OEMWriteDebugByte('m');
break;
case 23:
OEMWriteDebugByte('n');
break;
case 24:
OEMWriteDebugByte('o');
break;
case 25:
OEMWriteDebugByte('p');
break;
default:
OEMWriteDebugByte('X');
break;
}
}
#endif
gnWi = 0;
gulIntTime[gnWi++] = ulTime;
gnKeyCode = 0;
}
//If a complete key process interrupts are captured, trigure interrupt to notify utility.
//Else not process is needed.
}
}
else
{
*GPIO_BEOI = 0xff; // clean cir interrupt of gpio b
*GPIO_AEOI = 0xff; // clean cir interrupt of gpio b
*VIC2_INTCLEAR = INT2_GPIO;
*VIC2_INTENABLE = INT2_GPIO;
retval = SYSINTR_NOP;
}
}
#else
//
// Check to see if it the IRDA interrupt.
//
else if (ulVic2Irq & INT2_IRDA )
{
*VIC2_INTCLEAR = INT2_IRDA;
retval = SYSINTR_IR;
}
#endif
//
// Check to see if it is the IDE interrupt.
//
else if (ulVic2Irq & INT2_EXT3)
{
*VIC2_INTCLEAR = INT2_EXT3;
retval = SYSINTR_IDE;
}
//
// Check to see if it is the USB slave device.
//
else if (ulVic2Irq & INT2_EXT0)
{
#if EP93XX_USB_SLAVE
*VIC2_INTCLEAR = INT2_EXT0;
retval = SYSINTR_USBSLAVE;
#elif defined(EP93XX_SIMULAT_PS2_KBD)
BOOL EP93XPS2ISR ( void );
// DWORD dwStart;
*VIC2_INTCLEAR = INT2_EXT0;
// dwStart=*TIM_DEBUGVALUELOW;
if( EP93XPS2ISR ( ) )
{/*triger interrupt to notice the driver, when get a whole char*/
// RETAILMSG(1, (TEXT("triger SYSINTR_PS2_PORT\r\n")));
retval = SYSINTR_PS2_PORT;
}
*VIC2_INTENABLE = INT2_EXT0; /*as InterruptDone*/
#endif
}
else if(ulVic2Irq & INT2_PCMCIA_IRQ)
{
*VIC2_INTCLEAR = INT2_PCMCIA_IRQ;
// OEMEthISR();
retval = SYSINTR_PCMCIA_LEVEL;
}
else if((ulVic1Irq & (INT1_PCMCIA_CD1 | INT1_PCMCIA_CD2 | INT1_PCMCIA_BVD1)) ||
(ulVic2Irq & INT2_PCMCIA_BVD2))
{
*VIC1_INTCLEAR = (INT1_PCMCIA_CD1 | INT1_PCMCIA_CD2 | INT1_PCMCIA_BVD1);
*VIC2_INTCLEAR = INT2_PCMCIA_BVD2;
retval = SYSINTR_PCMCIA_STATE;
}
#ifdef EP93XX_SD_MMC
else if(ulVic2Irq & INT2_EXT1)
{
volatile unsigned short *v_pSDReg,SDRegValue;
*VIC2_INTCLEAR = INT2_EXT1;
v_pSDReg = (volatile unsigned short *) MEM_HOST_REG_BASE_SD_MMC;
SDRegValue=*(v_pSDReg+0x1);
if ( ( SDRegValue & 0x8000 ) == 0x8000 )
{
SDRegValue=*(v_pSDReg+0x5);
if ( ( SDRegValue & 0x100 ) == 0x100)
{
retval = SYSINTR_CARD_DETECT;
}
else
{
//RETAILMSG(1,(L"SD_MMC response\n"));
retval = SYSINTR_CARD_RESPONSE;
}
}
}
#endif
#if EP93XX_MS_CARD
else if(ulVic2Irq & INT2_EXT2)
{
volatile unsigned short *v_pSDReg,SDRegValue;
*VIC2_INTCLEAR = INT2_EXT2;
v_pSDReg = (volatile unsigned short *)MEM_HOST_REG_BASE_MS;
SDRegValue=*(v_pSDReg+0x1);
if ( ( SDRegValue & 0x8000 ) == 0x8000 )
{
SDRegValue=*(v_pSDReg+0x3);
if ( ( SDRegValue & 0x1000 ) == 0x1000)
{
retval = SYSINTR_CARD_DETECT;
}
else
{
retval = SYSINTR_CARD_RESPONSE;
}
}
}
#endif
else
{
*VIC1_INTCLEAR= ulVic1Irq;
*VIC2_INTCLEAR= ulVic2Irq;
// NKDbgPrintfW(L"0x%x, 0x%x\r\n", ulVic1Irq, ulVic2Irq);
}
}
// ulVic1Last = ulVic1Irq;
// ulVic2Last = ulVic2Irq;
//
// If we get any device interrupts, signal the resume flag. The flag
// will release the CPU from OEMPowerOff if the user had previously
// chosen to suspend the platform. In OEMPowerOff, only the interrupts
// allowed to wake us up will be enabled so we needn't worry about
// that here.
//
if(retval < SYSINTR_MAXIMUM && (!gfResumeFlag) )
{
if( gfSysIntrWakeupMask[retval] )
{
//RETAILMSG(1, (TEXT("resume %x\r\n"),retval));
gfResumeFlag = TRUE;
gdwLastWakeupSource = retval;
}
}
if( retval !=SYSINTR_NOP )
fInterruptFlag = TRUE;
g_dwLastInterrupt= retval;
return retval;
}
//****************************************************************************
// TimerInterrupt
//****************************************************************************
// Lets put all of the timer interrupt handling in one place.
// This code was taken from the arm integrator platform.
// The code is confusing, so I cleaned it up a little bit by making one
// ending point.
//
int TimerInterrupt(void)
{
DWORD retval = SYSINTR_NOP;
extern volatile DWORD PerfCountValueSinceTick;
CurMSec=GetSystemTimeInMSecAccurate( );
#ifndef REAL_RTC //CurTicks is not used if REAL_RTC is not defined.
CurTicks.QuadPart=CurMSec*983;
#endif
//
// Print out a 1 every second. I want to make sure that we are getting ticks.
//
// Call the profile ISR if it's enabled.
//
/* if (PProfileInterrupt)
{
retval = PProfileInterrupt();
if(retval == SYSINTR_RESCHED)
{
//
// Update the millisecond counter
//
CurMSec += RESCHED_PERIOD;
}
}
else*/
{
//
// if we're timing interrupts, keep track of when this one came in
//
PerfCountValueSinceTick+=RESCHED_INCREMENT;
if (fIntrTime)
{
dwIsrTime1 = PerfCountSinceTick();
wNumInterrupts++;
RETAILMSG(1, (TEXT("IntrTimer\r\n") ));
//
// Not profiling, update the millisecond counter
//
dwIntrTimeCountdown--;
if (dwIntrTimeCountdown == 0)
{
dwIntrTimeCountdown = dwIntrTimeCountdownRef;
wNumInterrupts = 0;
dwIsrTime2 = PerfCountSinceTick();
retval = SYSINTR_TIMING;
}
else
{
if ((int) (CurMSec - dwReschedTime) >= 0)
{
retval = SYSINTR_RESCHED;
}
}
}
else
{
//
// not profiling, update the millisecond counter
//
//CurMSec = dwReschedTime;
if ((int) (CurMSec - dwReschedTime) >= 0)
{
PerfCountValueSinceTick=0;
retval = SYSINTR_RESCHED;
}
}
}
return retval;
}
//****************************************************************************
// SysIntrNumToInterruptMask
//****************************************************************************
// Converts a System interrupt number to the bits used in the interrupt mask.
//
//
BOOL SysIntrNumToInterruptMask
(
DWORD dwSysIntr,
PULONG pulInterruptMask1,
PULONG pulInterruptMask2
)
{
BOOL bRet = TRUE;
switch(dwSysIntr)
{
case SYSINTR_TIMING:
//
// No action necessary. Needs to be handled in the calling routine.
//
*pulInterruptMask1 = 0;
*pulInterruptMask2 = 0;
break;
case SYSINTR_ETHER:
*pulInterruptMask1 = 0;
*pulInterruptMask2 = INT2_ETHERNET;
break;
case SYSINTR_USB:
*pulInterruptMask1 = 0;
*pulInterruptMask2 = INT2_USB;
break;
case SYSINTR_UART1:
*pulInterruptMask1 = 0;
*pulInterruptMask2 = INT2_UART1;
break;
case SYSINTR_UART2:
*pulInterruptMask1 = 0;
*pulInterruptMask2 = INT2_UART2;
break;
case SYSINTR_UART3:
*pulInterruptMask1 = 0;
*pulInterruptMask2 = INT2_UART3;
break;
case SYSINTR_KEYBOARD:
*pulInterruptMask1 = INT1_KEYPAD;
*pulInterruptMask2 = 0;
break;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -