阅读:2224回复:6
wince 5.0 中断问题,,,,急!!!!
向BSP里面加个按键驱动,现在是起来后按一次就没有反应了,请问是哪的问题? 引脚是EINT13.14.15.17.18五个. 下面帖上我的IST程序
UINT32 g_KeyButton1Irq = IRQ_EINT13; UINT32 g_PwrButton1SysIntr = SYSINTR_UNDEFINED; UINT32 g_KeyButton2Irq = IRQ_EINT14; UINT32 g_PwrButton2SysIntr = SYSINTR_UNDEFINED; UINT32 g_KeyButton3Irq = IRQ_EINT15; UINT32 g_PwrButton3SysIntr = SYSINTR_UNDEFINED; UINT32 g_KeyButton4Irq = IRQ_EINT17; UINT32 g_PwrButton4SysIntr = SYSINTR_UNDEFINED; UINT32 g_KeyButton5Irq = IRQ_EINT18; UINT32 g_PwrButton5SysIntr = SYSINTR_UNDEFINED; DWORD Kbd_IntrThread(PVOID pArg) { //HKEY hmykey; DWORD ret; DWORD dwErr; INT Column; long EINTPENDValue; INT IOData; //long bit; //BYTE bit; //DWORD dwRet; //DWORD dwKey; //DWORD dwKey1; InitializeAddresses(); Kbd_ConfigIOPin(2); //GPB6&7 Configure as out and low Kbd_ConfigInterruptPin(1); //set pin as interrupt and fall gWaitEvent = CreateEvent(NULL, FALSE, FALSE, NULL); // 创建外部中断中断事件 RETAILMSG(1, (TEXT("::: In EINTKey_IntrThread----The GPBDAT is: 0x%x .---when the thread start \r\n"),v_pIOPregs->GPBDAT)); if (!KernelIoControl(IOCTL_HAL_REQUEST_SYSINTR, &g_KeyButton1Irq, sizeof(UINT32), &g_PwrButton1SysIntr, sizeof(UINT32), NULL)) { RETAILMSG(1, (TEXT("ERROR: KeyButton1: Failed to request sysintr value for key1 button interrupt.\r\n"))); return(0); } RETAILMSG(1,(TEXT("INFO: KeyButton1: Mapped Irq 0x%x to SysIntr 0x%x.\r\n"), g_KeyButton1Irq, g_PwrButton1SysIntr)); if (!KernelIoControl(IOCTL_HAL_REQUEST_SYSINTR, &g_KeyButton2Irq, sizeof(UINT32), &g_PwrButton2SysIntr, sizeof(UINT32), NULL)) { RETAILMSG(1, (TEXT("ERROR: KeyButton2: Failed to request sysintr value for key1 button interrupt.\r\n"))); return(0); } RETAILMSG(1,(TEXT("INFO: KeyButton2: Mapped Irq 0x%x to SysIntr 0x%x.\r\n"), g_KeyButton2Irq, g_PwrButton2SysIntr)); if (!KernelIoControl(IOCTL_HAL_REQUEST_SYSINTR, &g_KeyButton3Irq, sizeof(UINT32), &g_PwrButton3SysIntr, sizeof(UINT32), NULL)) { RETAILMSG(1, (TEXT("ERROR: KeyButton3: Failed to request sysintr value for key1 button interrupt.\r\n"))); return(0); } RETAILMSG(1,(TEXT("INFO: KeyButton3: Mapped Irq 0x%x to SysIntr 0x%x.\r\n"), g_KeyButton3Irq, g_PwrButton3SysIntr)); if (!KernelIoControl(IOCTL_HAL_REQUEST_SYSINTR, &g_KeyButton4Irq, sizeof(UINT32), &g_PwrButton4SysIntr, sizeof(UINT32), NULL)) { RETAILMSG(1, (TEXT("ERROR: KeyButton4: Failed to request sysintr value for key1 button interrupt.\r\n"))); return(0); } RETAILMSG(1,(TEXT("INFO: KeyButton4: Mapped Irq 0x%x to SysIntr 0x%x.\r\n"), g_KeyButton4Irq, g_PwrButton4SysIntr)); if (!KernelIoControl(IOCTL_HAL_REQUEST_SYSINTR, &g_KeyButton5Irq, sizeof(UINT32), &g_PwrButton5SysIntr, sizeof(UINT32), NULL)) { RETAILMSG(1, (TEXT("ERROR: KeyButton5: Failed to request sysintr value for key1 button interrupt.\r\n"))); return(0); } RETAILMSG(1,(TEXT("INFO: KeyButton5: Mapped Irq 0x%x to SysIntr 0x%x.\r\n"), g_KeyButton5Irq, g_PwrButton5SysIntr)); if (!(InterruptInitialize(g_PwrButton1SysIntr, gWaitEvent, 0, 0))) { RETAILMSG(1, (TEXT("ERROR: PwrButton: Interrupt initialize failed.\r\n"))); } if (!(InterruptInitialize(g_PwrButton2SysIntr, gWaitEvent, 0, 0))) { RETAILMSG(1, (TEXT("ERROR: PwrButton: Interrupt initialize failed.\r\n"))); } if (!(InterruptInitialize(g_PwrButton3SysIntr, gWaitEvent, 0, 0))) { RETAILMSG(1, (TEXT("ERROR: PwrButton: Interrupt initialize failed.\r\n"))); } if (!(InterruptInitialize(g_PwrButton4SysIntr, gWaitEvent, 0, 0))) { RETAILMSG(1, (TEXT("ERROR: PwrButton: Interrupt initialize failed.\r\n"))); } if (!(InterruptInitialize(g_PwrButton5SysIntr, gWaitEvent, 0, 0))) { RETAILMSG(1, (TEXT("ERROR: PwrButton: Interrupt initialize failed.\r\n"))); } while (1) { //Kbd_ConfigIOPin(2); //GPB6&7 Configure as out and low //Kbd_ConfigInterruptPin(1); //set pin as interrupt and fall RETAILMSG(0, (TEXT("::: In EINTKey_IntrThread----KA BU KA !!! \r\n"))); WaitForSingleObject(gWaitEvent,INFINITE ); //INFINITE RETAILMSG(1, (TEXT("::: In EINTKey_IntrThread----SYSINTR_POWER Interrupt Occured. \r\n"))); if(Key_IsPushed1()) { keybd_event('A',0,0,0); keybd_event('A',0,KEYEVENTF_KEYUP,0); RETAILMSG(1, (TEXT("::: ddddddddddddddddddddddddddd!!!"))); Sleep(0); InterruptDone(g_PwrButton1SysIntr); } else if(Key_IsPushed2()) { keybd_event('B',0,0,0); keybd_event('B',0,KEYEVENTF_KEYUP,0); RETAILMSG(1, (TEXT("::: sssssssssssssssssssssssssss!!!"))); Sleep(0); InterruptDone(g_PwrButton2SysIntr); } else if(Key_IsPushed3()) { keybd_event('C',0,0,0); keybd_event('C',0,KEYEVENTF_KEYUP,0); RETAILMSG(1, (TEXT("::: fffffffffffffffff!!!"))); Sleep(0); InterruptDone(g_PwrButton3SysIntr); } else if(Key_IsPushed4()) { keybd_event('D',0,0,0); keybd_event('D',0,KEYEVENTF_KEYUP,0); RETAILMSG(1, (TEXT("::: hhhhhhhhhhhhhhh!!!"))); Sleep(0); InterruptDone(g_PwrButton4SysIntr); } else if(Key_IsPushed5()) { keybd_event('E',0,0,0); keybd_event('E',0,KEYEVENTF_KEYUP,0); RETAILMSG(1, (TEXT("::: rrrrrrrrrrrrrrrrrrrrrrrrrr!!!"))); Sleep(0); InterruptDone(g_PwrButton5SysIntr); } else { } return 1; } 麻烦各位帮忙看一下,谢谢! |
|
沙发#
发布于:2008-05-08 17:58
用户被禁言,该主题自动屏蔽! |
|
板凳#
发布于:2008-05-08 18:50
一个型号两只能和一个逻辑中断连接.
|
|
地板#
发布于:2008-05-09 09:19
可不可以在IST里面创建4个CreateEvent,每个对应一个中断号?
|
|
地下室#
发布于:2008-05-09 11:03
但是我看电源里面有:
if (!(InterruptInitialize(g_PwrButtonSysIntr, gPwrButtonIntrEvent, 0, 0))) { RETAILMSG(1, (TEXT("ERROR: PwrButton: Interrupt initialize failed.\r\n"))); } if (!(InterruptInitialize(g_RebootButtonSysIntr, gPwrButtonIntrEvent, 0, 0))) { RETAILMSG(1, (TEXT("ERROR: RebootButton: Interrupt initialize failed.\r\n"))); } if (!(InterruptInitialize(g_BattFLTSysIntr, gPwrButtonIntrEvent, 0, 0))) { RETAILMSG(1, (TEXT("ERROR: g_BattFLTSysIntr: Interrupt initialize failed.\r\n"))); } while (1) { WaitForSingleObject(gPwrButtonIntrEvent, INFINITE); |
|
5楼#
发布于:2008-05-10 10:32
各位,我现在是按键按一次后就没反应,要按另外一个键后才可以按这个键,就是同一个键不能按两次,请问是哪的问题?是不是IO口按完后没设置对,还是什么,先谢谢!下面是我IST里面部分代码
if (ret == WAIT_OBJECT_0) { if(Key_IsPushed1()) { RETAILMSG(1, (TEXT("11111111111111111111!!!!"))); InterruptDone(g_PwrButton5SysIntr); InterruptDone(g_PwrButton1SysIntr); InterruptDone(g_PwrButton2SysIntr); InterruptDone(g_PwrButton4SysIntr); InterruptDone(g_PwrButton3SysIntr); } else if(Key_IsPushed2()) { RETAILMSG(1, (TEXT("222222222222222222222222!!!!"))); InterruptDone(g_PwrButton5SysIntr); InterruptDone(g_PwrButton1SysIntr); InterruptDone(g_PwrButton2SysIntr); InterruptDone(g_PwrButton4SysIntr); InterruptDone(g_PwrButton3SysIntr); } else if(Key_IsPushed3()) { RETAILMSG(1, (TEXT("3333333333333333333333!!!!"))); InterruptDone(g_PwrButton5SysIntr); InterruptDone(g_PwrButton1SysIntr); InterruptDone(g_PwrButton2SysIntr); InterruptDone(g_PwrButton4SysIntr); InterruptDone(g_PwrButton3SysIntr); } else if(Key_IsPushed4()) { RETAILMSG(1, (TEXT("444444444444444444444!!!!"))); InterruptDone(g_PwrButton5SysIntr); InterruptDone(g_PwrButton1SysIntr); InterruptDone(g_PwrButton2SysIntr); InterruptDone(g_PwrButton4SysIntr); InterruptDone(g_PwrButton3SysIntr); } else if(Key_IsPushed5()) { RETAILMSG(1, (TEXT("55555555555555555555555!!!"))); InterruptDone(g_PwrButton5SysIntr); InterruptDone(g_PwrButton1SysIntr); InterruptDone(g_PwrButton2SysIntr); InterruptDone(g_PwrButton4SysIntr); InterruptDone(g_PwrButton3SysIntr); } } 望各位DX指点!谢谢 |
|
6楼#
发布于:2008-05-14 10:04
问题已解决,无需多开线程,上面的问题是因为我少了closehandle而造成的
|
|