|
这个还真没有试!因为bsp触摸有问题的缘故。也说不清楚,贴下我的按键驱动吧!这个中断号是动态绑定的,我改过它用 静态绑定的 是可以的 ,应该没问题,你可以对照下!!!
#include
//#include
#include
//#include
#include
#include "pmplatform.h"
#include "Pkfuncs.h"
#include "s2440.h"
volatile IOPreg *s2440IOP = (IOPreg *)IOP_BASE;
volatile INTreg *s2440INT = (INTreg *)INT_BASE;
UINT32 g_KeySysIntr[6];
HANDLE KeyThread;
HANDLE KeyEvent;
void Virtual_Alloc(); // Virtual allocation
DWORD UserKeyProcessThread(void);
DWORD UserKeyProcessThread(void)
{
UINT32 IRQ;
KeyEvent = CreateEvent(NULL, FALSE, FALSE, NULL);
if (!KeyEvent) {
RETAILMSG(1, (TEXT("ERROR: kEYBD: Failed to create event.\r\n")));
return FALSE;
}
IRQ = 36; //IRQ_EINT8;
if (!KernelIoControl(IOCTL_HAL_REQUEST_SYSINTR, &IRQ, sizeof(UINT32), &g_KeySysIntr[0], sizeof(UINT32), NULL)) {
RETAILMSG(1, (TEXT("ERROR: kEYBD: Failed to request sysintr value.\r\n")));
return FALSE;
}
IRQ = 39; //IRQ_EINT11;
if (!KernelIoControl(IOCTL_HAL_REQUEST_SYSINTR, &IRQ, sizeof(UINT32), &g_KeySysIntr[1], sizeof(UINT32), NULL)) {
RETAILMSG(1, (TEXT("ERROR: kEYBD: Failed to request sysintr value.\r\n")));
return FALSE;
}
IRQ = 41; //IRQ_EINT13;
if (!KernelIoControl(IOCTL_HAL_REQUEST_SYSINTR, &IRQ, sizeof(UINT32), &g_KeySysIntr[2], sizeof(UINT32), NULL)) {
RETAILMSG(1, (TEXT("ERROR: kEYBD: Failed to request sysintr value.\r\n")));
return FALSE;
}
IRQ = 42; //IRQ_EINT14;
if (!KernelIoControl(IOCTL_HAL_REQUEST_SYSINTR, &IRQ, sizeof(UINT32), &g_KeySysIntr[3], sizeof(UINT32), NULL)) {
RETAILMSG(1, (TEXT("ERROR: kEYBD: Failed to request sysintr value.\r\n")));
return FALSE;
}
IRQ = 43; //IRQ_EINT15;
if (!KernelIoControl(IOCTL_HAL_REQUEST_SYSINTR, &IRQ, sizeof(UINT32), &g_KeySysIntr[4], sizeof(UINT32), NULL)) {
RETAILMSG(1, (TEXT("ERROR: kEYBD: Failed to request sysintr value.\r\n")));
return FALSE;
}
IRQ = 47; //IRQ_EINT19;
if (!KernelIoControl(IOCTL_HAL_REQUEST_SYSINTR, &IRQ, sizeof(UINT32), &g_KeySysIntr[5], sizeof(UINT32), NULL)) {
RETAILMSG(1, (TEXT("ERROR: kEYBD: Failed to request sysintr value.\r\n")));
return FALSE;
}
if (!InterruptInitialize(g_KeySysIntr[0], KeyEvent, NULL, 0)) {
RETAILMSG(1,(TEXT("Fail to initialize userkey interrupt event\r\n")));
return FALSE;
}
if (!InterruptInitialize(g_KeySysIntr[1], KeyEvent, NULL, 0)) {
RETAILMSG(1,(TEXT("Fail to initialize userkey interrupt event\r\n")));
return FALSE;
}
if (!InterruptInitialize(g_KeySysIntr[2], KeyEvent, NULL, 0)) {
RETAILMSG(1,(TEXT("Fail to initialize userkey interrupt event\r\n")));
return FALSE;
}
if (!InterruptInitialize(g_KeySysIntr[3], KeyEvent, NULL, 0)) {
RETAILMSG(1,(TEXT("Fail to initialize userkey interrupt event\r\n")));
return FALSE;
}
if (!InterruptInitialize(g_KeySysIntr[4], KeyEvent, NULL, 0)) {
RETAILMSG(1,(TEXT("Fail to initialize userkey interrupt event\r\n")));
return FALSE;
}
if (!InterruptInitialize(g_KeySysIntr[5], KeyEvent, NULL, 0)) {
RETAILMSG(1,(TEXT("Fail to initialize userkey interrupt event\r\n")));
return FALSE;
}
while(1)
{
WaitForSingleObject(KeyEvent, INFINITE);
RETAILMSG(0,(L"EINTMASK=%X, rGPGCON=%X\r\n", s2440IOP->rEINTMASK, s2440IOP->rGPGCON));
//EINT8 - K1 - VK_TAB - 0x09
if(s2440IOP->rEINTMASK & (DWORD)(0x1<<8))
{
RETAILMSG(1,(TEXT("[Key1 - TAB]\r\n")));
keybd_event(VK_TAB ,0x09, 0, 0);
Sleep(30);
keybd_event(VK_TAB ,0x09, KEYEVENTF_KEYUP, 0);
InterruptDone(g_KeySysIntr[0]);
}
//EINT11 - K2 - VK_UP - 0x26
if(s2440IOP->rEINTMASK & (DWORD)(0x1<<11))
{
RETAILMSG(1,(TEXT("[Key2 - UP]\r\n")));
keybd_event(VK_UP ,0x26, 0, 0);
Sleep(30);
keybd_event(VK_UP ,0x26, KEYEVENTF_KEYUP, 0);
InterruptDone(g_KeySysIntr[1]);
}
//EINT13 - K3 - VK_RETURN - 0x0D
if(s2440IOP->rEINTMASK & (DWORD)(0x1<<13))
{
RETAILMSG(1,(TEXT("[K3 - RETURN]\r\n")));
keybd_event(VK_RETURN ,0x0D, 0, 0);
Sleep(30);
keybd_event(VK_RETURN ,0x0D, KEYEVENTF_KEYUP, 0);
InterruptDone(g_KeySysIntr[2]);
}
//EINT14 - K4 - VK_DOWN - 0x28
if(s2440IOP->rEINTMASK & (DWORD)(0x1<<14))
{
RETAILMSG(1,(TEXT("[K4 - DONW]\r\n")));
keybd_event(VK_DOWN ,0x28, 0, 0);
Sleep(30);
keybd_event(VK_DOWN ,0x28, KEYEVENTF_KEYUP, 0);
InterruptDone(g_KeySysIntr[3]);
}
//EINT15 - K5 - VK_LEFT - 0x25
if(s2440IOP->rEINTMASK & (DWORD)(0x1<<15))
{
RETAILMSG(1,(TEXT("[K5 - LEFT]\r\n")));
keybd_event(VK_LEFT ,0x25, 0, 0);
Sleep(30);
keybd_event(VK_LEFT ,0x25, KEYEVENTF_KEYUP, 0);
InterruptDone(g_KeySysIntr[4]);
}
//EINT19 - K6 - VK_RIGHT - 0x27
if(s2440IOP->rEINTMASK & (DWORD)(0x1<<19))
{
RETAILMSG(1,(TEXT("[K6 - RIGHT]\r\n")));
keybd_event(VK_RIGHT ,0x27, 0, 0);
Sleep(30);
keybd_event(VK_RIGHT ,0x27, KEYEVENTF_KEYUP, 0);
InterruptDone(g_KeySysIntr[5]);
}
}
}
|
|