/**
******************************************************************************************************************************************************************************************
*@file                       dm_button_gpio.h
*@author         
*@data                       
*@version                    v1.0
*@par Copyright(c):
*
*@par History:
*     version:author,date,desc
*     v1.0   :create this file
*
*******************************************************************************************************************************************************************************************
*/
#ifndef _DM_BUTTON_GPIO_H_
#define _DM_BUTTON_GPIO_H_


typedef uint16_t dm_btn_id_t;
typedef uint16_t dm_gpio_btn_id;

typedef enum _kb_led_id{
	cap_led,      	
	num_led,      		
	scroll_led,  
	power_led,   		
	power2_led,		
	bt_led,      		
}kb_led_id;

typedef enum
{
    DM_BTN_ACT_RELEASED,
	DM_BTN_ACT_PRESSED,
	DM_BTN_ACT_GHOST_PRESS,		//¹í¼ü°´ÏÂ
	DM_BTN_ACT_GHOST_RELEASE,		//¹í¼üÊÍ·Å
	DM_BTN_ACT_NONE,

}dm_gpio_btn_action;

typedef struct
{
    dm_gpio_btn_id     btn_id;
	dm_gpio_btn_action action;

}dm_gpio_btn_report;



#include <stdint.h>
#include "app_config.h"
#include "datatype.h"
#if HID_SURPORT
#include "ble_keyboard_ui.h"
#endif
/*
* brief to identify button
* if it is button matrix
*     key = col_io_idx|row_io_idx
* else
*     key = io_idx
*/



typedef void (*sdk_event_cbk)(SDK_EVENT event,uint32_t param);
typedef void (*dm_gpio_btn_cbk)(dm_gpio_btn_report* p_rpt);




typedef struct
{
    uint32_t      scan_interval;     /// scan interval defaule 10ms (ms)
    uint8_t       scan_valid_times;  /// scan valid times.
	uint8_t       scan_times;        /// scan times
	uint32_t      row_io_map;        /// io row map
	uint32_t      col_io_map;        /// io column map
	uint32_t	  interrupt_io_map;

	uint32_t      scan_io_map;      	/// É¨Ãè°´¼ü
	uint32_t      cap_led_io_map;      /// É¨Ãè°´¼ü
	uint32_t      num_led_io_map;      	/// É¨Ãè°´¼ü
	uint32_t      scroll_led_io_map;      	/// É¨Ãè°´¼ü

	
	uint32_t      power_led_io_map;   /// É¨Ãè°´¼ü
	uint32_t      power2_led_io_map;   /// É¨Ãè°´¼ü


	
	uint32_t      bt_led_io_map;      	/// É¨Ãè°´¼ü

	
	dm_gpio_btn_cbk  button_cbk;              /// must not be NULL
	sdk_event_cbk  	 event_cbk;

}dm_gpio_btn_conf;





void dm_set_gpio_wake(uint32_t pins_map);
void close_all_kb_led(void);

void dm_button_init(void);
void dm_button_keyboard_config(dm_gpio_btn_conf *p_conf);
uint32_t get_kb_led_pin(kb_led_id type);
void reg_dm_button_gpio(dm_gpio_btn_conf *pdm_button_param,dm_gpio_btn_cbk  cbk,sdk_event_cbk	con_cbk);

uint16_t get_key_value(uint16_t btn_id);


#endif

