wince 6.0
pxa270
1*1按键,按照矩阵的方式连接。按下键盘时不产生中断。
部分代码如下
- XLLP_BOOL_T XllpKeyPadConfigure(XLLP_KEYPAD_REGS *v_pKeyPadRegs,XLLP_GPIO_T *v_pGPIOReg)
- {
- XLLP_BOOL_T retval=XLLP_FALSE;
- XLLP_UINT32_T GpioDirOutList[]={1,104};
- XLLP_UINT32_T GpioDirInList[]={1,101};
- XLLP_UINT32_T GpioAltFnPinList[]={2,101,104};
- XLLP_UINT32_T GpioAltFnValList[]={2,1,2};
- if(v_pGPIOReg != 0)
- {
- XllpGpioSetDirectionIn(v_pGPIOReg, GpioDirInList);
- XllpGpioSetDirectionOut(v_pGPIOReg, GpioDirOutList);
- XllpGpioSetOutput0(v_pGPIOReg, GpioDirOutList);
- XllpGpioSetAlternateFn(v_pGPIOReg, GpioAltFnPinList, GpioAltFnValList);
- }
- if(v_pKeyPadRegs != 0)
- {
- v_pKeyPadRegs->kpControlReg = 1<<26 | 1<<23 |
- MAT_SCAN_LINE1|
- MATRIX_KP_ENABLE | MATRIX_INTR_ENABLE |
- IGNORE_MULTIPLE_KEY_PRESS |
- AUTO_SCAN_ON_ACTIVITY;
-
- retval = XLLP_TRUE;
- }
- return(retval);
- }
- //物理中断与系统中断绑定
- OALIntrStaticTranslate(SYSINTR_KEYPAD, IRQ_KEYPAD);
- DWORD KYP_Init(DWORD dwContext)
- {
- DWORD dwRet = 0;
- BOOL result; //
-
- if(!Initialize())//初始化
- {
- goto KYP_Exit;
- }
-
- m_hevInterrupt = CreateEvent(NULL, FALSE, FALSE, NULL); //创建事件
- if (!m_hevInterrupt)
- {
- goto KYP_Exit;
- }
- result = InterruptInitialize(SYSINTR_KEYPAD, m_hevInterrupt, NULL, 0);//注册事件,即
- 与中断相绑定
- if(!result)
- {
- goto KYP_Exit;
- }
- //InterruptDone(SYSINTR_KEYPAD);
- if (!IsrThreadStart())//创建新线程
- {
- goto KYP_Exit;
- }
- RETAILMSG(1,(TEXT("---------->KeyPad:KYP_Init<----------\r\n\r\n")));
- return TRUE;
- KYP_Exit:
- KYP_Deinit(0);
- return dwRet;
- }
- BOOL IsrThreadStart()
- {
- BOOL retval = FALSE;
- hthrd = CreateThread(NULL,0,(LPTHREAD_START_ROUTINE) KeypdIsrThread,NULL,0,NULL);
- if (hthrd != NULL)
- {
- retval = TRUE;
- CloseHandle(hthrd);
- }
- return retval;
- }
- void KeypdIsrThread()
- {
- if ( WaitForSingleObject(hevInterrupt, AutoRepeatTimeout) == WAIT_TIMEOUT )
- {
- }
- else
- {
- InterruptDone(SYSINTR_KEYPAD);
- }
- }
如上,按下按键时不能产生中断。。