/* ****************************************************************************** * * @file key.c * @brief key module * * * @version 1.0 * @date 2022/08/04 15:00:40 * @author Alex Xu * * Copyright (c) 2013-2099,Tkplusemi Technology Co.,Ltd. * All Rights Reserved * * History: * Revision Date Author Desc * 1.0.0 2022/08/04 Alex build this file ******************************************************************************/ /*_____ I N C L U D E S ____________________________________________________*/ #include "key.h" #include "system.h" #include "led.h" #include "sleep.h" #include "adc.h" #include "bat.h" #include "vox_module.h" #if KEY_ENABLE /******************************************************************************\ Macro definitions \******************************************************************************/ /******************************************************************************\ Variables definitions \******************************************************************************/ bit Key_Press_short_irq = 0; bit Key_Press_l_irq = 0; bit Key_Press_ll_irq = 0; idata KEY_EVENT_E Event_key = 0; /******************************************************************************\ Functions definitions \******************************************************************************/ /* ******************************************************************************* * void Key_Handler(void) * * Description : Key Handler --- 主循环中调用,调用周期5ms。其中长按(按键时间大于2s)需要判断抬键动作才触发。 CoverStatus --- 充电仓盖子状态。(本函数提供对应Key事件标志位,后续应用待定) * * Arguments : NONE * Returns : NONE * Notes : NONE * ******************************************************************************* */ void Key_Handler(void) { if( IRQ_FLAG7 & 0x20 ) //长按2s,无需要抬键。 { Key_Press_l_irq = 1; /*todo*/ Event_key = KEY_EVENT_L_2S; /*耳机配对*/ IRQ_FLAG7 = 0x20; #ifdef _DEBUG_KEY printf("long press\r\n"); #endif } if( IRQ_FLAG7 & 0x40 ) //长按8s,无需要抬键。 { Key_Press_ll_irq = 1; /*todo*/ Event_key = KEY_EVENT_LL_8S; IRQ_FLAG7 = 0x40; #ifdef _DEBUG_KEY printf("supper long press\r\n"); #endif } if( IRQ_FLAG7 & 0x18 ) //短按16ms-1s,需要抬键。 { Key_Press_short_irq = 1; /*todo*/ Event_key = KEY_EVENT_SHORT; IRQ_FLAG7 = 0x18; #ifdef _DEBUG_KEY printf("short press\r\n"); #endif } } #endif