BLE_TYQ_CH584M/BSP/inc/bsp_key.h

41 lines
882 B
C
Raw Normal View History

2024-12-09 11:41:44 +08:00
#ifndef __BSP_KEY_H__
#define __BSP_KEY_H__
2024-12-14 13:31:23 +08:00
#include "CONFIG.h"
2024-12-09 11:41:44 +08:00
2024-12-14 13:31:23 +08:00
#include <stdint.h>
#include <stdbool.h>
2024-12-09 11:41:44 +08:00
2024-12-17 14:51:12 +08:00
#define KEY_TIMOUT_MS 3000
#define KEY_LONG_PRESS_MS 5000
#define KEY_SACN_MS 40
2024-12-14 16:00:58 +08:00
#define KEY_SCAN_EVT (0x0001 << 0)
#define KEY_WAKEUP_EVT (0x0001 << 1)
#define KEY_RELEASE_EVT (0x0001 << 2)
2024-12-17 14:51:12 +08:00
#define KEY_IDLE_TIMEOUT_EVT (0x0001 << 3)
2024-12-09 11:41:44 +08:00
2024-12-14 13:31:23 +08:00
// KEY_B_PIN at PB7,low->active
#define KEY_B_PIN GPIO_Pin_7
2024-12-09 11:41:44 +08:00
2024-12-14 13:31:23 +08:00
#define IS_KEY_Vaild() ((GPIOB_ReadPortPin(KEY_B_PIN) ? 0 : 1))
2024-12-09 11:41:44 +08:00
2024-12-14 13:31:23 +08:00
typedef enum
{
kKeyShort = 0,
kKeyLong,
kKeyRelease,
2024-12-14 16:00:58 +08:00
} TeAppEvtType;
2024-12-09 11:41:44 +08:00
typedef void (*app_task_evt_handler_t)(TeAppEvtType app_task_evt_type);
2024-12-09 11:41:44 +08:00
2024-12-14 13:31:23 +08:00
void BSP_KEY_EnterLowpower(void);
void BSP_KEY_ExitLowpower(void);
2024-12-09 11:41:44 +08:00
void BSP_KEY_Init(app_task_evt_handler_t handler);
2024-12-09 11:41:44 +08:00
2024-12-14 16:00:58 +08:00
void KEY_ProcessLoop(void);
2024-12-09 11:41:44 +08:00
#endif // !__BSP_KEY_H__