39 lines
897 B
C
39 lines
897 B
C
#ifndef __BUTTON_H__
|
|
#define __BUTTON_H__
|
|
|
|
#include "common.h"
|
|
#include "gpio.h"
|
|
|
|
#define BUTTON_NO_PIN P0_6 // 按钮引脚
|
|
#define BUTTON_NC_PIN P0_7 // 按钮引脚
|
|
|
|
#define BUTTON_SHORT_PRESS_TIME 100 // 短按时间阈值,单位为毫秒
|
|
#define BUTTON_LONG_PRESS_TIME 2000 // 长按时间阈值,单位为毫秒
|
|
|
|
typedef enum
|
|
{
|
|
BUTTON_LED_OFF = 0,
|
|
BUTTON_LED_R = P3_7,
|
|
BUTTON_LED_G = P3_6,
|
|
BUTTON_LED_O = P3_5,
|
|
} button_led_enum;
|
|
|
|
typedef enum
|
|
{
|
|
BUTTON_NO_PRESS = 0, // 空闲状态
|
|
BUTTON_SHORT_PRESS = 1, // 短按
|
|
BUTTON_SHORT_PRESS_HANDLED = 2, // 短按已处理
|
|
BUTTON_LONG_PRESS = 3, // 长按
|
|
} button_status_enum;
|
|
|
|
|
|
extern uint32 button_press_time;
|
|
|
|
void button_init();
|
|
void button_1ms_callback(); // 1ms定时器回调函数
|
|
button_status_enum button_get_status(); // 获取按钮状态
|
|
void button_led_set(button_led_enum led);
|
|
|
|
|
|
#endif
|