2025-04-26 16:03:23 +08:00

112 lines
3.8 KiB
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.

/** ##########################################################################
** Filename : keyboard_drive.h
** Project : RGB LED
** Module :
** Processor : Cypress CY8C4147AZI-S475
** Version : V1.0
** Compiler : PSoC Creator 4.2
** Date/Time : 2019/10/08
** Abstract :
**
** Contents :
**
**
** (c) Copyright dmdz Co.,Ltd
** --------------------------------------------------------------------------
** R E V I S I O N H I S T O R Y
** --------------------------------------------------------------------------
** Date Ver Author Description
** --------- ---- ----------------- --------------------------------------
** #########################################################################*/
#ifndef _KEY_ADC_DRIVE_H_
#define _KEY_ADC_DRIVE_H_
/*****************************************************************************
* I N C L U D E F I L E S
*****************************************************************************/
#include "key_adc_driver_cfg.h"
#include "key_com_cfg.h"
/*****************************************************************************
* D E F I N E S
*****************************************************************************/
/*****************************************************************************
* M A C R O S
*****************************************************************************/
/*****************************************************************************
* T Y P E D E F I N I T I O N S
*****************************************************************************/
/*****************************************************************************
* S T A T I C V A R I A B L E S
*****************************************************************************/
typedef u8 key_adc_state_e;
typedef enum
{
KEY_ADC_RESULT_UNKNOW=0u, //为了给mid层区分是否有弹起
KEY_ADC_RESULT_IDLE,
KEY_ADC_RESULT_PRESSS,
KEY_ADC_RESULT_LONG,
KEY_ADC_RESULT_STICK,
KEY_ADC_RESULT_FAULT
}key_adc_result_e;
#define KEY_ADC_EVENT_RELEASE 1u
#define KEY_ADC_EVENT_PRESSED 2u
#define KEY_ADC_EVENT_SHORT_DOWN_RELEASE 4u
#define KEY_ADC_EVENT_LONG_DOWN 8u
#define KEY_ADC_EVENT_NULL 0u
#define KEY_ADC_SUB_STATE_UNKNOW 0u
#define KEY_ADC_SUB_STATE_UP 1u // OR IDLE
typedef struct
{
#ifdef RAM_OPTIMIZE_EN
key_adc_state_e sub_state:2; //子状态
key_adc_state_e state:3; //通道,当前状态,
key_adc_state_e pre_state:3; //通道,上一次前状态,
#else
key_adc_state_e state; //通道,当前状态,
key_adc_state_e pre_state; //通道,上一次前状态,
key_adc_state_e sub_state; //子状态
#endif
key_adc_time_t count; //计时
#ifdef KEY_ADC_DEBUG_EN
adc_result_t adc_org; //通道adc电压值
#endif
key_adc_result_e jude_line[KEY_ADC_1CHANNEL_JUDGE_TOTALS]; //每行判断的临时状态
key_adc_result_e result[KEY_ADC_1CHANNEL_PHY_TOTALS]; //每行按鍵的結果
}key_adc_driver_s;
/*****************************************************************************
* G L O B A L V A R I A B L E S
*****************************************************************************/
/*****************************************************************************
* C O N S T A N T S
*****************************************************************************/
/*****************************************************************************
* F U N C T I O N P R O T O T Y P E
*****************************************************************************/
void key_adc_driver_init(void); //按键初始化
void key_adc_driver_task(void); //按键任务周期调用
key_adc_result_e key_adc_driver_get_result(u8 channel,u8 sub_id);
void key_adc_goto_sleep(void);
void key_adc_goto_wakeup(void);
#endif /*_KEYBOARD_DRIVE_H_*/
/* [] END OF FILE */