有做过矩阵键盘的指导下:
在oalintr.h 添加了中断的定义,CFW.C和ARMINTI.C添加了相应的实现。
s3c2440kbd.cpp文件修改如下:
BOOL Ps2Keybd::IsrThreadProc()
{
....
extern UINT v_uiPddId;
extern PFN_KEYBD_EVENT v_pfnKeybdEvent;
KEYBD_IST keybdIst;
keybdIst.hevInterrupt = m_hevInterrupt;
keybdIst.dwSysIntr_Keybd = dwSysIntr_Keybd;
keybdIst.uiPddId = v_uiPddId;
keybdIst.pfnGetKeybdEvent = KeybdPdd_GetEventEx2;
keybdIst.pfnKeybdEvent = v_pfnKeybdEvent;
RETAILMSG(DEBUGMODE, (TEXT("IsrThreadProc Call KeybdIstLoop()\r\n")));
KeybdIstLoop(&keybdIst);
....
}
static UINT KeybdPdd_GetEventEx2(UINT uiPddId, UINT32 rguiScanCode[16], BOOL rgfKeyUp[16])
{
....
ui8ScanCode = (UINT8)GetKeySCode(); //add 这个是我的键盘扫描函数
RETAILMSG(DEBUGMODE, (TEXT("[KeybdPdd_GetEventEx2] ui8ScanCode : %x\r\n"),ui8ScanCode));
DEBUGMSG(ZONE_SCANCODES,
(_T("%s: scan code 0x%08x, code in progress 0x%08x, previous 0x%08x\r\n"),
pszFname, ui8ScanCode, scInProgress, scPrevious));
scInProgress = ui8ScanCode;
....
}
BOOL Ps2Keybd::KeybdPowerOn()
这个函数进行了中断和IO的初始话,
其他的几个文件改动不打。
编译下载后出现了:
-----Call Matrix_Entry-----
Initialize Matrix ID
Ps2Keybd::Initialize
IsrThreadStart:
++KeybdDriverInitializeAddresses
Touch Init
call Ps2KeybdIsrThread:
call IsrThreadProc:
HARDWARE\DEVICEMAP\KEYBD\Priority256: 0
KEYBDCreateEventm_hevInterrupt: 2fbe4c6a
Call InterruptInitialize()
IsrThreadProc Call KeybdIstLoop()
Data Abort: Thread=8fbf6c9c Proc=8d426a08 'gwes.exe'
AKY=00000009 PC=034a5d40 RA=034a5d30 BVA=080000d4 FSR=00000007
按键没有任何反应,大家看下那里错了,谢谢了
产生异常自己退出DLL了
4.2和5.0 没有什么不同,只有中断申请不同而已。
我就是让4.2的键盘驱动放在5.0下运行的。
中断初始化的问题吧,InterruptInitialize()初始化硬件管脚、中断等。
之后就进入IsrThreadStart->KeybdIstLoop等待键盘中断。
看你的信息,是KeybdIstLoop函数中,直接发生数据异常了Data Abort
- IsrThreadProc Call KeybdIstLoop()
- Data Abort: Thread=8fbf6c9c Proc=8d426a08 'gwes.exe'
- AKY=00000009 PC=034a5d40 RA=034a5d30 BVA=080000d4 FSR=00000007
给你这个网址参考一下
[url=http://space.itpub.net/13771794/viewspace-520884][/url]
谢谢,楼上的,我参考了那文章,那问题解决了!!出现新问题了!!
static DWORD g_dwSysIntr_Keybd[MAX_HDKEY] = {SYSINTR_EINT13,SYSINTR_EINT14,SYSINTR_EINT17,SYSINTR_EINT19,SYSINTR_EINT20,SYSINTR_EINT21};
我定义的中断号
BOOL Ps2Keybd::IsrThreadProc(DWORD index)
{
DWORD dwPriority;
//add wy
DWORD dwIrq_Keybd = dwIrq_Keybdbuf[index];
// HANDLE m_hevInterrupt;
RETAILMSG(DEBUGMODE, (TEXT("call IsrThreadProc:\r\n")));
// look for our priority in the registry -- this routine sets it to zero if
// it can't find it.
ReadRegDWORD( TEXT("HARDWARE\\DEVICEMAP\\KEYBD"), _T("Priority256"), &dwPriority );
RETAILMSG(DEBUGMODE, (TEXT("HARDWARE\\DEVICEMAP\\KEYBD\\Priority256: %x\r\n"), dwPriority));
if(dwPriority == 0) {
// dwPriority = 145; // default value is 145
dwPriority = 240; // default value is 145
}
// RETAILMSG(DEBUGMODE, (TEXT("HARDWARE\\DEVICEMAP\\KEYBD\\Priority256: %x\r\n"), dwPriority));
DEBUGMSG(1, (TEXT("IsrThreadProc:\r\n")));
m_hevInterrupt = CreateEvent(NULL,FALSE,FALSE,NULL);
if (m_hevInterrupt == NULL) {
DEBUGMSG(1, (TEXT("IsrThreadProc: InterruptInitialize\r\n")));
goto leave;
}
RETAILMSG(DEBUGMODE, (TEXT("KEYBD\CreateEvent\m_hevInterrupt: %x\r\n"), m_hevInterrupt ));
//ReadRegDWORD( TEXT("HARDWARE\\DEVICEMAP\\KEYBD"), _T("SysIntr"), &dwSysIntr_Keybd );
// RETAILMSG(DEBUGMODE, (TEXT("HARDWARE\\DEVICEMAP\\KEYBD\\SysIntr: %x\r\n"), dwSysIntr_Keybd));
/*#if 0
while (1)
{
if ( WaitForSingleObject(m_hevInterrupt, INFINITE) == WAIT_TIMEOUT )
DEBUGMSG(1, (TEXT("timeout\r\n")));
else
DEBUGMSG(1, (TEXT("I got one\r\n")));
InterruptDone(dwSysIntr_Keybd);
}
#endif*/
if (!InterruptInitialize(g_dwSysIntr_Keybd[index],m_hevInterrupt,NULL,0)) {
RETAILMSG(1, (TEXT("IsrThreadProc: KeybdInterruptEnable\r\n")));
goto leave;
}
RETAILMSG(1,(TEXT("[KBD]m_hevInterrupt[%d]=0x%08x,irq=%d,sysIntr=% d\r\n"),index,m_hevInterrupt,dwIrq_Keybd,g_dwSysIntr_Keybd[index]));
// update the IST priority
CeSetThreadPriority(GetCurrentThread(), (int)dwPriority);
extern UINT v_uiPddId;
extern PFN_KEYBD_EVENT v_pfnKeybdEvent;
KEYBD_IST keybdIst;
keybdIst.hevInterrupt = m_hevInterrupt;
keybdIst.dwSysIntr_Keybd = g_dwSysIntr_Keybd[index]; //dwSysIntr_Keybd;
keybdIst.uiPddId = v_uiPddId;
keybdIst.pfnGetKeybdEvent = KeybdPdd_GetEventEx2;
keybdIst.pfnKeybdEvent = v_pfnKeybdEvent;
RETAILMSG(DEBUGMODE, (TEXT("IsrThreadProc Call KeybdIstLoop()\r\n")));
KeybdIstLoop(&keybdIst);
leave:
return 0;
}
DWORD Ps2KeybdIsrThread(Ps2Keybd *pp2k)
{
DEBUGMSG(1,(TEXT("Ps2KeybdIsrThread:\r\n")));
RETAILMSG(DEBUGMODE,(TEXT("call Ps2KeybdIsrThread:\r\n")));
pp2k->IsrThreadProc(pp2k->key_index);
return 0;
}
BOOL Ps2Keybd::IsrThreadStart()
{
HANDLE hthrd;
DEBUGMSG(1,(TEXT("IsrThreadStart:\r\n")));
while((key_index<(MAX_HDKEY))&&(key_index>=0))
{
hthrd = CreateThread(NULL,0,(LPTHREAD_START_ROUTINE)Ps2KeybdIsrThread,this,0,NULL);
// Since we don't need the handle, close it now.
CloseHandle(hthrd);
Sleep(1);
key_index ++;
}
return TRUE;
}
只有SYSINTR_EINT13 调用InterruptInitialize()成功,其他的全失败了,和SYSINTR_EINT13在数组中的位置无关,在CFW.C和arminit.c中它们的相应实现时一样的啊,为什么啊,有其他好的方法实现矩阵键盘的吗?
问题解决了,但是我没明白原理呵呵,采用的是系统的原有的中断