我现在遇到的问题是不知道如何编写硬件触发中断处理程序 环境为wince.net x86,代码如下希望您给予关注 //Öжϴ¦Àí²¿·Ö HANDLE g_hevInterrupt;; HANDLE g_htIST; DWORD g_dwSysInt; DWORD SetupInterrupt ( void ); DWORD WINAPI ThreadIST ( LPVOID lpvParam ); DWORD SetupInterrupt( void ) { BOOL fRetVal; DWORD dwIrq = 7(这是硬件设置的中断号) DWORD dwThreadID; // Create an event // g_hevInterrupt = CreateEvent(NULL, FALSE, FALSE, NULL); if(!g_hevInterrupt) return 10; // Have the OAL Translate the IRQ to a system irq // fRetVal = KernelIoControl( IOCTL_HAL_TRANSLATE_IRQ, &dwIrq, sizeof( dwIrq ), &g_dwSysInt, sizeof( g_dwSysInt ), NULL ); if( !fRetVal )return 11; // Create a thread that waits for signaling // g_htIST = CreateThread(NULL,// CE Has No Security 0, // No Stack Size ThreadIST,// Interrupt Thread NULL,// No Parameters CREATE_SUSPENDED,// Create Suspended until we are done &dwThreadID // Thread Id ); if( !g_htIST )return 12; // Set the thread priority to real time // int m_nISTPriority = 7; if(!CeSetThreadPriority( g_htIST, m_nISTPriority)) return 13; // Initialize the interrupt // if ( !InterruptInitialize(g_dwSysInt,g_hevInterrupt,NULL,0) )return 14; ResumeThread( g_htIST ); return 0; }
DWORD WINAPI ThreadIST( LPVOID lpvParam ) { DWORD dwStatus; // Always chec the running flag // BOOL g_fRun = TRUE; while( g_fRun ) { dwStatus = WaitForSingleObject(g_hevInterrupt, INFINITE); // Make sure we have the object // if( dwStatus == WAIT_OBJECT_0 ) { // Handle Interrupt Here // ::MessageBox (NULL, _T("²âÊÔ!"), _T("¾¯¸æÌáʾ"), MB_ICONQUESTION); // Finish the interrupt // InterruptDone( g_dwSysInt ); } } return 0; } 不知道为什么不能触发
|