Browse Source

update:软件键盘还是中断里扫描吧

alienwalker 3 years ago
parent
commit
e6da632be7
2 changed files with 7 additions and 4 deletions
  1. 1 1
      application/src/luat_softkeyboard_air105.c
  2. 6 3
      bsp/air105/hal/core_soft_keyboard.c

+ 1 - 1
application/src/luat_softkeyboard_air105.c

@@ -39,7 +39,7 @@ static void l_softkeyboard_irq_cb(void *pData, void *pParam) {
 }
 
 int luat_softkeyboard_init(luat_softkeyboard_conf_t *conf){
-	SoftKB_Setup(6250, 4, 2, 0, l_softkeyboard_irq_cb, NULL);
+	SoftKB_Setup(6250, 4, 2, 1, l_softkeyboard_irq_cb, NULL);
 	SoftKB_IOConfig(conf->inio, conf->inio_num, conf->outio, conf->outio_num, 0);
     SoftKB_Start();
     return 0;

+ 6 - 3
bsp/air105/hal/core_soft_keyboard.c

@@ -32,6 +32,7 @@ static int32_t prvSoftKB_DummyCB(void *pData, void *pParam)
 static int32_t prvSoftKB_IOIrqCB(void *pData, void *pParam)
 {
 	int i;
+
 	for(i = 0; i < prvSoftKB.InIONum; i++)
 	{
 		GPIO_ExtiConfig(prvSoftKB.InIO[i], 0, 0, 0);
@@ -41,7 +42,6 @@ static int32_t prvSoftKB_IOIrqCB(void *pData, void *pParam)
 	{
 		GPIO_ODConfig(prvSoftKB.OutIO[i], !prvSoftKB.PressKeyIOLevel);
 	}
-
 	if (prvSoftKB.IsEnable)
 	{
 		Timer_StartUS(prvSoftKB.ScanTimer, prvSoftKB.ScanPeriod, 1);
@@ -184,18 +184,20 @@ void SoftKB_ScanOnce(void)
 	uint32_t KeySn;
 	if (!prvSoftKB.IsEnable || !prvSoftKB.IsScan)
 	{
-		return;
+		goto STOP;
 	}
+
 	for(i = 0; i < prvSoftKB.OutIONum; i++)
 	{
 		GPIO_Output(prvSoftKB.OutIO[i], prvSoftKB.PressKeyIOLevel);
 		for(j = 0; j < prvSoftKB.InIONum; j++)
 		{
-			//DBG("%d,%d,%d", i, j, GPIO_Input(prvSoftKB.InIO[j]));
+//			DBG("%d,%d,%d", i, j, GPIO_Input(prvSoftKB.InIO[j]));
 			prvSoftKB.KeyPress[(i << 4) + j] += (GPIO_Input(prvSoftKB.InIO[j]) == prvSoftKB.PressKeyIOLevel);
 		}
 		GPIO_Output(prvSoftKB.OutIO[i], !prvSoftKB.PressKeyIOLevel);
 	}
+
 	prvSoftKB.ScanCnt++;
 	if (prvSoftKB.ScanCnt >= prvSoftKB.ScanTimes)
 	{
@@ -231,6 +233,7 @@ void SoftKB_ScanOnce(void)
 				return;
 			}
 		}
+STOP:
 		Timer_Stop(prvSoftKB.ScanTimer);
 		prvSoftKB.IsScan = 0;
 		for(i = 0; i < prvSoftKB.OutIONum; i++)