IoT_SCV_CH584M/bsp/inc/bsp_key.h

45 lines
1008 B
C

#ifndef __BSP_KEY_H__
#define __BSP_KEY_H__
#include "CONFIG.h"
#include <stdint.h>
#include <stdbool.h>
#define KEY_TIMOUT_MS 1000
#define KEY_LONG_PRESS_MS 5000
#define KEY_SACN_MS 40
#define KEY_IDLE_TIMEOUT_MS 10000
#define KEY_SCAN_EVT (0x0001 << 0)
#define KEY_WAKEUP_EVT (0x0001 << 1)
#define KEY_RELEASE_EVT (0x0001 << 2)
#define KEY_IDLE_TIMEOUT_EVT (0x0001 << 3)
// KEY_B_PIN at PB7,low->active
#define KEY_A_PIN GPIO_Pin_7
extern volatile uint8_t key_wakeup_flag;
#define IS_KEY_Vaild() ((GPIOA_ReadPortPin(KEY_A_PIN) ? 0 : 1))
typedef enum
{
kKeyShort = 0,
kKeyLong,
kKeyRelease,
} TeAppEvtType;
typedef void (*app_task_evt_handler_t)(TeAppEvtType app_task_evt_type);
void app_task_handler(TeAppEvtType app_evt_type);
void BSP_KEY_EnterLowpower(void);
void BSP_KEY_ExitLowpower(void);
void BSP_KEY_Init(app_task_evt_handler_t handler);
void KEY_ProcessLoop(void);
#endif // !__BSP_KEY_H__