106 lines
4.6 KiB
C
106 lines
4.6 KiB
C
/*****************************************************************************/
|
|
/* FILENAME : KeyHdl.h */
|
|
/* */
|
|
/* DESCRIPTION : Handling Key Events for Application. */
|
|
/* */
|
|
/* NOTES : Copyright Sathish Kumar P. All rights reserved. */
|
|
/* */
|
|
/* AUTHOR : Sathish Kumar */
|
|
/* sathishembeddedgeek@gmail.com */
|
|
/* */
|
|
/* START DATE : 9th Feb 2020 */
|
|
/* */
|
|
/* VERSION DATE WHO DETAIL */
|
|
/* 00.00.01 09FEB20 Sathish Kumar initial version */
|
|
/* */
|
|
/*****************************************************************************/
|
|
#ifndef __KEY_HDL_H__
|
|
#define __KEY_HDL_H__
|
|
|
|
|
|
/*****************************************************************************/
|
|
/* */
|
|
/* I N C L U D E S */
|
|
/* */
|
|
/*****************************************************************************/
|
|
#define KEY_EVENT_PRESSED (0x01)
|
|
#define KEY_EVENT_RELEASED (0x02)
|
|
|
|
/*****************************************************************************/
|
|
/* */
|
|
/* D E F I N I T I O N S */
|
|
/* */
|
|
/*****************************************************************************/
|
|
|
|
#define MULTIKEY_MAX_KEY_LINKS 3
|
|
|
|
/* key connection type */
|
|
#define KEY_TYP_ACTIVE_LOW 0 /* key event occurs when pulled low */
|
|
#define KEY_TYP_ACTIVE_HIGH 1 /* key event occurs when pulled high */
|
|
|
|
#if ((KEYHDL_KEY_DEBOUNCE_TIME <= 60)|| !defined(KEYHDL_KEY_DEBOUNCE_TIME))
|
|
#error "Please define a valid DEBOUNCE_TIME (above 60ms) "
|
|
#endif
|
|
|
|
#if !defined(KEYHDL_SUPPORT_SINGLE_KEY)
|
|
#warning "KEYHDL_SUPPORT_SINGLE_KEY is not supported!!!"
|
|
#define KEYHDL_SUPPORT_SINGLE_KEY 0
|
|
#endif
|
|
|
|
#if !defined(KEYHDL_KEY_LIST)
|
|
#warning "KEYHDL_KEY_LIST is empty!!!"
|
|
#define KEYHDL_KEY_LIST EMPTY_KEY_NAME_LIST
|
|
#endif
|
|
|
|
#if !defined(KEYHDL_TASK_TIME_IN_MS)
|
|
#warning "KEYHDL_TASK_TIME_IN_MS is not defined!!! Setting to default 20ms"
|
|
#define KEYHDL_TASK_TIME_IN_MS 20
|
|
#endif
|
|
|
|
/*****************************************************************************/
|
|
/* */
|
|
/* C O N S T A N T S & V A R I A B L E S */
|
|
/* */
|
|
/*****************************************************************************/
|
|
|
|
/* hardware layer for gpio port */
|
|
typedef struct key_gpio_t_
|
|
{
|
|
KeyPort_t port;
|
|
KeyPortPin_t pin;
|
|
}KeyGPIO_t;
|
|
|
|
/* single key gpio port */
|
|
typedef struct key_port_map_t_
|
|
{
|
|
KeyEnumList key_name;
|
|
KeyPort_t port;
|
|
KeyPortPin_t pin;
|
|
}KeyPortMap_t;
|
|
|
|
typedef struct key_multi_map_t_
|
|
{
|
|
KeyEnumList key_name;
|
|
KeyEnumList multi_key_list[MULTIKEY_MAX_KEY_LINKS];
|
|
uint8_t no_of_keys;
|
|
}KeyMultiMap_t;
|
|
|
|
typedef struct key_params_t_
|
|
{
|
|
uint16_t bounce_time;
|
|
uint8_t event_type;
|
|
}KeyParams_t;
|
|
|
|
/*****************************************************************************/
|
|
/* */
|
|
/* F U N C T I O N P R O T O T Y P E S */
|
|
/* */
|
|
/*****************************************************************************/
|
|
|
|
/*****************************************************************************/
|
|
/* */
|
|
/* E N D O F F I L E */
|
|
/* */
|
|
/*****************************************************************************/
|
|
#endif /* END OF __KEY_HDL_H__ */
|