|
|
@@ -416,20 +416,70 @@ void RTC_Alarm_IRQHandler(void)
|
|
|
void HAL_GPIO_EXTI_Callback(uint16_t GPIO_Pin)
|
|
|
{
|
|
|
RTC_DateTimeTypeDef now;
|
|
|
- RTC_GetDateTime(&hrtc, &now);
|
|
|
+ RTC_GetDateTime(&hrtc, &now); // 获取当前时间
|
|
|
|
|
|
+ // ===== SOS_KEY =====
|
|
|
if(GPIO_Pin == SOS_KEY_Pin)
|
|
|
{
|
|
|
- printf("SOS_KEY 按下\r\n");
|
|
|
+ if(HAL_GPIO_ReadPin(SOS_KEY_GPIO_Port, SOS_KEY_Pin) == GPIO_PIN_SET)
|
|
|
+ {
|
|
|
+ // 松开(上升沿)
|
|
|
+ printf("SOS_KEY 松开\r\n");
|
|
|
+
|
|
|
+ uint16_t key_Duration = 0;
|
|
|
+ if(SOS_key_struct.key_Duration > now.seconds) {
|
|
|
+ key_Duration = now.seconds + 60 - SOS_key_struct.key_Duration;
|
|
|
+ } else {
|
|
|
+ key_Duration = now.seconds - SOS_key_struct.key_Duration;
|
|
|
+ }
|
|
|
|
|
|
- // 处理 SOS
|
|
|
+ printf("SOS_KEY 按压了:%d 秒\r\n", key_Duration);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ // 按下(下降沿)
|
|
|
+ printf("SOS_KEY 按下\r\n");
|
|
|
+ SOS_key_struct.key_Duration = now.seconds;
|
|
|
+ }
|
|
|
}
|
|
|
+ // ===== JUGE_KEY =====
|
|
|
else if(GPIO_Pin == JUGE_PIN_Pin)
|
|
|
{
|
|
|
- printf("JUGE_KEY 按下\r\n");
|
|
|
- // 处理 JUGE
|
|
|
- HAL_GPIO_WritePin(POWER_ON_GPIO_Port, POWER_ON_Pin, GPIO_PIN_RESET);
|
|
|
+ if(HAL_GPIO_ReadPin(JUGE_PIN_GPIO_Port, JUGE_PIN_Pin) == GPIO_PIN_SET)
|
|
|
+ {
|
|
|
+ // 松开(上升沿)
|
|
|
+ printf("JUGE_KEY 松开\r\n");
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ // 按下(下降沿)
|
|
|
+ printf("JUGE_KEY 按下\r\n");
|
|
|
+ HAL_GPIO_WritePin(POWER_ON_GPIO_Port, POWER_ON_Pin, GPIO_PIN_RESET);
|
|
|
+ }
|
|
|
}
|
|
|
+
|
|
|
+ // if (GPIO_Pin == SOS_KEY_Pin)
|
|
|
+ // {
|
|
|
+ // if (HAL_GPIO_ReadPin(SOS_KEY_GPIO_Port, SOS_KEY_Pin) == GPIO_PIN_SET)
|
|
|
+ // {
|
|
|
+ // printf("SOS_KEY 上升沿\r\n"); // 现在是高电平,说明刚从低到高
|
|
|
+ // }
|
|
|
+ // else
|
|
|
+ // {
|
|
|
+ // printf("SOS_KEY 下降沿\r\n"); // 现在是低电平,说明刚从高到低
|
|
|
+ // }
|
|
|
+ // }
|
|
|
+ // else if (GPIO_Pin == JUGE_PIN_Pin)
|
|
|
+ // {
|
|
|
+ // if (HAL_GPIO_ReadPin(JUGE_PIN_GPIO_Port, JUGE_PIN_Pin) == GPIO_PIN_SET)
|
|
|
+ // {
|
|
|
+ // printf("JUGE_KEY 上升沿\r\n");
|
|
|
+ // }
|
|
|
+ // else
|
|
|
+ // {
|
|
|
+ // printf("JUGE_KEY 下降沿\r\n");
|
|
|
+ // }
|
|
|
+ // }
|
|
|
}
|
|
|
|
|
|
/* USER CODE END 1 */
|