/*********************************************************************************************************************
* RT1064DVL6A Opensourec Library RT1064DVL6A Դ⣩һڹٷ SDK ӿڵĵԴ
* Copyright (c) 2022 SEEKFREE ɿƼ
* 
* ļ RT1064DVL6A Դһ
* 
* RT1064DVL6A Դ 
* Ըᷢ GPLGNU General Public License GNUͨù֤
*  GPL ĵ3棨 GPL3.0ѡģκκİ汾·/޸
* 
* Դķϣܷãδκεı֤
* ûԻʺض;ı֤
* ϸμ GPL
* 
* ӦյԴͬʱյһ GPL ĸ
* ûУ<https://www.gnu.org/licenses/>
* 
* ע
* Դʹ GPL3.0 Դ֤Э Ϊİ汾
* Ӣİ libraries/doc ļµ GPL3_permission_statement.txt ļ
* ֤ libraries ļ ļµ LICENSE ļ
* ӭλʹò ޸ʱ뱣ɿƼİȨ
* 
* ļ          zf_device_key
* ˾          ɶɿƼ޹˾
* 汾Ϣ          鿴 libraries/doc ļ version ļ 汾˵
*           IAR 8.32.4 or MDK 5.33
* ƽ̨          RT1064DVL6A
*           https://seekfree.taobao.com/
* 
* ޸ļ¼
*                               ע
* 2022-09-21        SeekFree            first version
********************************************************************************************************************/
/*********************************************************************************************************************
* ߶壺
*                   ------------------------------------
*                   ģܽ            Ƭܽ
*                   // һ尴Ӧ
*                   KEY1/S1             鿴 zf_device_key.h  KEY_LIST[0]
*                   KEY2/S2             鿴 zf_device_key.h  KEY_LIST[1]
*                   KEY3/S3             鿴 zf_device_key.h  KEY_LIST[2]
*                   KEY4/S4             鿴 zf_device_key.h  KEY_LIST[3]
*                   ------------------------------------
********************************************************************************************************************/

#ifndef _zf_device_key_h_
#define _zf_device_key_h_

#include "zf_common_debug.h"

#include "zf_driver_gpio.h"

// 尴 û޸ Ĭ϶ĸ
// 尴˳Ӧ· key_index_enum öж˳
// û ôҪͬ· key_index_enum ö
#define KEY_LIST                    {C13,C15 ,C12 ,C14 ,C11}

#define KEY_RELEASE_LEVEL           (GPIO_HIGH)                                 // Ĭ״̬ Ҳǰͷ״̬ĵƽ
#define KEY_MAX_SHOCK_PERIOD        (10       )                                 // ʱ λ ʱźŻᱻΪӲ
#define KEY_LONG_PRESS_PERIOD       (400     )                                 // Сʱ λ ʱźŻᱻΪǳ

typedef enum
{
    UP,
    DOWN,
    LEFT,
    RIGHT,
	PRESS,
    KEY_NUMBER,
}key_index_enum;                                                                //  ӦϷİŸ Ĭ϶ĸ

typedef enum
{
    KEY_RELEASE,                                                                // ͷ״̬
    KEY_SHORT_PRESS,                                                            // ̰״̬
    KEY_LONG_PRESS,                                                             // ״̬
}key_state_enum;

void            key_scanner             (void);
key_state_enum  key_get_state           (key_index_enum key_n);
void            key_clear_state         (key_index_enum key_n);
void            key_clear_all_state     (void);
void            key_init                (uint32 period);

#endif
