/*********************************************************************************************************
*
* File                : syhstick.h
* Hardware Environment: 
* Build Environment   : RealView MDK-ARM  Version: 4.20
* Version             : V1.0
* By                  : 
**
*********************************************************************************************************/

#ifndef __BUTTON_H__
#define __BUTTON_H__

/* Includes ------------------------------------------------------------------*/	   
#include <stdint.h>
#include "include.h"


#define BSP_BUTTON_ACTION_KEEP_LONG_PUSH		(BSP_BUTTON_ACTION_LONG_PUSH + 1)

#define KEY_MOTION_1                    IPT_KEY_1              /**< Button that will trigger the notification event with the KEY Button Service */
#define KEY_MOTION_2                    IPT_KEY_2              /**< Button that will trigger the notification event with the KEY Button Service */
#define KEY_MOTION_3                    IPT_KEY_3              /**< Button that will trigger the notification event with the KEY Button Service */
#define KEY_MOTION_4                    IPT_KEY_4              /**< Button that will trigger the notification event with the KEY Button Service */
#define KEY_MOTION_5                    IPT_KEY_5              /**< Button that will trigger the notification event with the KEY Button Service */
#define KEY_MOTION_6                    IPT_KEY_6              /**< Button that will trigger the notification event with the KEY Button Service */
#define PWR_MOTION_CHRG                 BSP_BUTTON_6           /**< Button that will trigger the notification event with the PWR Button Service */
#define PWR_MOTION_STDBY                BSP_BUTTON_7           /**< Button that will trigger the notification event with the PWR Button Service */


/* Public variables-----------------------------------------------*/
typedef enum
{
	KEY_NUM_MIN = -1,
	KEY_NUM_1,
	KEY_NUM_2,
	KEY_NUM_3,
	KEY_NUM_4,
	KEY_NUM_5,
	KEY_NUM_6,
	KEY_NUM_CHRG,
	KEY_NUM_STDBY,
	KEY_NUM_MAX
}KEY_NUM_ENUM;		//按钮编号


typedef struct
{
	STATUS_CTL_STRUCT cnt_ctl[KEY_NUM_MAX];		//按钮计数控制
	uint8_t finish_flag[KEY_NUM_MAX];			//按钮正常松开标志
	uint8_t timeout_flag[KEY_NUM_MAX];			//按钮超时松开标志
	
}BTN_DET_TIMEOUT_STRUCT;

#define BTN_PUSH_TIMEOUT 			30			/*短按超时上限 n*50ms */
#define BTN_LONG_PUSH_TIMEOUT 		80			/*长按超时上限 n*50ms */
#define BTN_DETECT_TIMEOUT 			252			/*超时计数上限 n*50ms */

/* Public function prototypes -----------------------------------------------*/
void init_general_key_button(void);
void uninit_general_key_button(void);

/**@brief Function for general button configuration.
 *
 * @param[in] void.
 */
void init_general_button(void);

//检测开机按钮状态是否为按下状态，如果不是，则强制关机
void detect_bootup_key_status(void);

//初始化按钮缓冲队列
void init_general_button_queue(void);


/**@brief Function for handling events from the general button handler module.
 *
 * @param[in] void.
 */
void general_button_event_detect(void);

/**@brief Function for cycle process general button actions.
 *
 * @param[in] void.
 */
uint8_t cycleProcessKeyMotion(void);

/**@brief Function for cycle detect charging button actions.
 *
 * @param[in] void.
 */
void detectChargePinStatus(void);

void cycle_add_btn_det_timeout(void);

#endif

/*********************************************end of file*********************************************/

