void TIM2_IRQHandler(void)
{
// if ( TIM_GetITStatus(TIM2 , TIM_IT_Update) != RESET )
// {
// TIM_ClearITPendingBit(TIM2 , TIM_FLAG_Update);
// Time_Press++;
// }
if (TIM_GetITStatus(TIM2, TIM_IT_Update) != RESET)
{
if(Key_Press == 1) //·¢éú°′?ü°′??ê??t
{
if(GPIO_ReadInputDataBit(GPIOC,GPIO_Pin_13) == 0 ) //°′?ü3?D?°′??
{
if(Time_Press <= 800)
{
Time_Press++;
}
else //°′?ü°′??μ?2000ms?í?D??3¤°′ê??t3éᢣ?éú3é3¤°′±ê??
{
Time_Press = 0;
Key_Press_Short = 0; //??3y?ì°′±ê??
Key_Press_Long = 1; //3¤°′±ê??????
Key_Press = 0; //??°′?ü°′??±ê??
}
}
else //°′?üì§?e
{
if(Time_Press > 20) //°′??ê±??′óóú50mséú3éμ¥?÷±ê??
{
Time_Press = 0;
Key_Press_Short = 1;
Key_Press_Long = 0;
Key_Press = 0;
Time_Press_Short_Flag++;
Time_Press_Short_Flag%=4;
if((Time_Press_Double >100) && (Time_Press_Double <500)) //?àà?é?′?μ¥?÷ê±???ú100-500ms????£??òè??a·¢éúá??÷ê??t
{
Key_Press_Double = 1;
Key_Press_Short = 0;
Time_Press_Short_Flag = Time_Press_Short_Flag - 1;
}
Time_Press_Double_Flag = 1;
printf("SF is %d\n",Time_Press_Short_Flag);
}
else
{
Time_Press=0;
Key_Press_Short = 0;
Key_Press_Long = 0;
Key_Press = 0;
}
}
}
if(Time_Press_Double_Flag)
Time_Press_Double++;
if(Time_Press_Double > 500)
{
Time_Press_Double = 0;
Time_Press_Double_Flag = 0;
}
}
TIM_ClearITPendingBit(TIM2 , TIM_FLAG_Update);
}
|