Files
CHJ/user/Device/key_power.h
2026-03-20 21:19:53 +08:00

25 lines
791 B
C
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#ifndef __KEY_POWER_H
#define __KEY_POWER_H
// 按键参数配置
#define KEY_PRESS_TIME_SHORT 50 // 短按阈值50ms防抖
#define KEY_PRESS_TIME_LONG 500 // 长按阈值2000ms关机触发
#define KEY_SCAN_INTERVAL 10 // 按键扫描间隔10ms
// 设备状态枚举
typedef enum {
DEVICE_STATE_OFF = 0, // 关机(深度休眠)
DEVICE_STATE_ON, // 开机(正常工作)
// DEVICE_STATE_SHUTDOWN // 关机中(过渡状态)
} Device_StateTypeDef;
// 函数声明
void Key_Power_Init(void); // 引脚初始化PA0输入、PA1输出
void Key_Scan_Task(void); // 按键扫描任务(需定时调用)
Device_StateTypeDef Get_Device_State(void); // 获取当前设备状态
void Unit_key(void); //单位按键检测函数,在定时器中断里调用
#endif