From 8a1e33a48bf01d69a574b25433dcb5d711ddafce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=B0=8F=E5=86=AFSir?= Date: Fri, 3 May 2024 03:32:02 +0800 Subject: [PATCH] add key control --- Firmware/Core/apps/src/key.c | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/Firmware/Core/apps/src/key.c b/Firmware/Core/apps/src/key.c index 82f64ed..075cb1f 100644 --- a/Firmware/Core/apps/src/key.c +++ b/Firmware/Core/apps/src/key.c @@ -1,11 +1,23 @@ -#include #include "key.h" -#include "tim.h" -#include "stdbool.h" - - void HAL_GPIO_EXTI_Callback(uint16_t GPIO_Pin) { - + if (GPIO_Pin == KEY1_Pin) { + if (HAL_GPIO_ReadPin(KEY1_GPIO_Port, KEY1_Pin) == GPIO_PIN_SET) { + while (HAL_GPIO_ReadPin(KEY1_GPIO_Port, KEY1_Pin) == GPIO_PIN_SET); + keyVal = 1; + } + } + if (GPIO_Pin == KEY2_Pin) { + if (HAL_GPIO_ReadPin(KEY2_GPIO_Port, KEY2_Pin) == GPIO_PIN_RESET) { + while (HAL_GPIO_ReadPin(KEY2_GPIO_Port, KEY2_Pin) == GPIO_PIN_RESET); + keyVal = 2; + } + } + if (GPIO_Pin == KEY3_Pin) { + if (HAL_GPIO_ReadPin(KEY3_GPIO_Port, KEY3_Pin) == GPIO_PIN_RESET) { + while (HAL_GPIO_ReadPin(KEY3_GPIO_Port, KEY3_Pin) == GPIO_PIN_RESET); + keyVal = 3; + } + } }