/*如下為鍵盤驅(qū)動的頭文檔*/
/////////////////////////////////////////////////////////////////
char keyhit( void ); //擊鍵否
unsigned char Keyscan( void ); //取鍵值
////////////////////////////////////////////////////////////////
二、盡量使用宏定義#define
static unsigned char sts;//按鍵狀態(tài)變量
static unsigned char Nowkeycode;//此時的鍵碼
static unsigned char Prekeycode;//上一次的鍵碼
static unsigned char Keydowntime;//矩形鍵盤按下去抖時間變量
static unsigned char Keyuptime;//矩形鍵盤釋放去抖時間變量
static unsigned char Onoffdowntime;//關(guān)機(jī)鍵按下去抖時間變量
static unsigned char Onoffuptime;//關(guān)機(jī)鍵釋放去抖時間變量
static unsigned char onoff_10ms; //判斷關(guān)機(jī)鍵中斷次數(shù)變量,累計150次大約為3S,因為前后進(jìn)了兩個10ms中斷
const unsigned char a=1;//定義a=1,編譯器不允許修改a的值
作用:保護(hù)不希望被修改的參數(shù)
const unsigned char Key_code[KEYNUM]={0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08,
0x09,0x0A,0x0B,0x0C,0x0D,0x0E,0x0F,0x10,
0x11,0x12,0x13,0x14,0x15,0x16,0x17,0x18,
0x19,0x1A,0x1B,0x1C,0x1D,0x1E,0x1F,0x20,
0x21,0x22,0x23,0x24,0x25,0x26,0x27,0x28,
0x29,0x2A,0x2B,0x2C,0x2D,0x2E,0x2F,0x30,
0x31,0x32,0x33,0x34,0x35,0x36,0x37,0x38,
0x39,0x3A,0x3B,0x3C,0x3D,0x3E,0x3F,0x40,
0x41
};//鍵碼
const unsigned char Line_out[LINENUM]={0xFE,0xFD,0xFB,0xf7,0xEF,0xDF,0xBF,0x7F};//行輸出編碼
const unsigned char Row_in[ROWNUM]={0xFE,0xFD,0xFB,0xf7,0xEF,0xDF,0xBF,0x7F};//列輸入編碼
static int i=0;
int main(void)
{
...
while (1)
{
if (i)
dosomething();
}
}
/* Interrupt service routine. */
void ISR_2(void)
{
i=1;
}
樹莓派Pico:僅4美元的MCU
嵌入式Linux開發(fā)板裸機(jī)程序燒寫方法總結(jié)
國產(chǎn)16位MCU的痛點,可以用這款物美價廉產(chǎn)品
免責(zé)聲明:本文內(nèi)容由21ic獲得授權(quán)后發(fā)布,版權(quán)歸原作者所有,本平臺僅提供信息存儲服務(wù)。文章僅代表作者個人觀點,不代表本平臺立場,如有問題,請聯(lián)系我們,謝謝!