fixed problem developerkitgui key register gpio irq
@@ -27,42 +27,47 @@ int handing_shake()
return ret;
}
-void HAL_GPIO_EXTI_Callback(uint16_t GPIO_Pin)
+void key1_handle(void *arg)
{
- GUI_KEY_A10 key = 0;
-
if (handing_shake())
return;
-
- switch (GPIO_Pin) {
- case KEY_1_Pin:
- key = GUI_KEY_1;
if (key_flag) {
old_key_flag = key_flag;
key_flag = 0;
} else {
key_flag = old_key_flag;
}
- break;
- case KEY_2_Pin:
- key = GUI_KEY_2;
- // ++key_flag;
- break;
- case KEY_3_Pin:
- key = GUI_KEY_3;
- if (key_flag)
- ++key_flag;
- break;
- default:
- return;
+ GUI_StoreKeyMsg(GUI_KEY_1, 1);
+ GUI_StoreKeyMsg(GUI_KEY_1, 0);
}
- GUI_StoreKeyMsg(key, 1);
- GUI_StoreKeyMsg(key, 0);
+
+void key2_handle(void *arg)
+{
+ if (handing_shake())
+ return;
+ GUI_StoreKeyMsg(GUI_KEY_2, 1);
+ GUI_StoreKeyMsg(GUI_KEY_2, 0);
}
+void key3_handle(void *arg)
+{
+ if (handing_shake())
+ return;
+ if (key_flag)
+ ++key_flag;
+ GUI_StoreKeyMsg(GUI_KEY_3, 1);
+ GUI_StoreKeyMsg(GUI_KEY_3, 0);
+}
static void app_delayed_action(void *arg)
{
+ int ret = 0;
+ ret |= hal_gpio_enable_irq(&brd_gpio_table[GPIO_KEY_1], IRQ_TRIGGER_RISING_EDGE, key1_handle, NULL);
+ ret |= hal_gpio_enable_irq(&brd_gpio_table[GPIO_KEY_2], IRQ_TRIGGER_RISING_EDGE, key2_handle, NULL);
+ ret |= hal_gpio_enable_irq(&brd_gpio_table[GPIO_KEY_3], IRQ_TRIGGER_RISING_EDGE, key3_handle, NULL);
+ if (ret != 0) {
+ printf("hal_gpio_enable_irq key return failed.\n");
+ }
GUIDEMO_Main();
LOG("helloworld %s:%d %s\r\n", __func__, __LINE__, aos_task_name());
aos_post_delayed_action(5000, app_delayed_action, NULL);
