R1_up/User/device/detect.c
2025-06-30 14:28:32 +08:00

32 lines
625 B
C

#include "detect.h"
#include "gpio_it.h" // 确保包含 GPIO 中断相关头文件
#include "bsp_delay.h"
int key=0;
int ball_exit=0;
// 按键中断回调函数
void detect_exit(void)
{
delay_ms(10); // 延时10ms
key++; // 按键按下时变量自增
__HAL_GPIO_EXTI_CLEAR_IT(KEY_Pin); // 清除中断标志位
}
void detect_ball(void)
{
ball_exit++; // 按键按下时变量自增
__HAL_GPIO_EXTI_CLEAR_IT(BALL_Pin); // 清除中断标志位
}
void detect_init(void)
{
// BSP_GPIO_RegisterCallback(KEY_Pin, detect_exit);
// BSP_GPIO_RegisterCallback(BALL_Pin, detect_ball);
}