39 lines
1.2 KiB
C
39 lines
1.2 KiB
C
|
|
|||
|
#include "key.h"
|
|||
|
/**************************************************************************
|
|||
|
Function: Key initialization
|
|||
|
Input : none
|
|||
|
Output : none
|
|||
|
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ܣ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʼ<EFBFBD><EFBFBD>
|
|||
|
<EFBFBD><EFBFBD><EFBFBD>ڲ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
<EFBFBD><EFBFBD><EFBFBD><EFBFBD> ֵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
**************************************************************************/
|
|||
|
void KEY_Init(void)
|
|||
|
{
|
|||
|
GPIO_InitTypeDef GPIO_InitStructure;
|
|||
|
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA, ENABLE); // ʹ<><CAB9>PA<50>˿<EFBFBD>ʱ<EFBFBD><CAB1>
|
|||
|
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_5; // <20>˿<EFBFBD><CBBF><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IPU; // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
GPIO_Init(GPIOA, &GPIO_InitStructure); // <20><><EFBFBD><EFBFBD><EFBFBD>趨<EFBFBD><E8B6A8><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʼ<EFBFBD><CABC>GPIOA
|
|||
|
}
|
|||
|
/**************************************************************************
|
|||
|
Function: Key scan
|
|||
|
Input : none
|
|||
|
Output : 0<EFBFBD><EFBFBD>No action<EFBFBD><EFBFBD>1<EFBFBD><EFBFBD>click<EFBFBD><EFBFBD>
|
|||
|
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ܣ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɨ<EFBFBD><EFBFBD>
|
|||
|
<EFBFBD><EFBFBD><EFBFBD>ڲ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
<EFBFBD><EFBFBD><EFBFBD><EFBFBD> ֵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>״̬ 0<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> 1<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
**************************************************************************/
|
|||
|
u8 click(void)
|
|||
|
{
|
|||
|
static u8 flag_key = 1; // <20><><EFBFBD><EFBFBD><EFBFBD>ɿ<EFBFBD><C9BF><EFBFBD>־
|
|||
|
if (flag_key && KEY == 0) // <20><><EFBFBD><EFBFBD><E2B5BD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
{
|
|||
|
flag_key = 0;
|
|||
|
return 1; // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
}
|
|||
|
else if (1 == KEY)
|
|||
|
flag_key = 1;
|
|||
|
return 0; // <20>ް<EFBFBD><DEB0><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
}
|