📄 keypad.c
字号:
// SFR description needs to be included
#include<REG922.h>
#include "keypad.h"
#include <absacc.h>
#include "string.h"
#include "intrins.h"
/***********************************************************************
DESC: Initializes the keypad
RETURNS: Nothing
CAUTION: EA must be set to 1 after calling this function
************************************************************************/
void keypad_init(void)
{
// define pattern
KBPATN = 0x10;
// define P0 pins that trigger interrupt
KBMASK = 0x10;
// pattern must not match
KBCON = 0x00;
// set isr priority to 0
IP1 &= 0xFD;
IP1H &= 0xFD;
// enable keypad interrupt
EKBI = 1;
}
/***********************************************************************
DESC: Keypad Interrupt Service Routine
RETURNS: Nothing
CAUTION: keypad_init must be called first
EA must be set to 1
************************************************************************/
void keypad_isr(void) interrupt 7 using 1
{
// clear interrupt flag
KBCON &= 0xFE;
LED=0;
//BEEP=1;Delay100ms66(1);BEEP=0; LED=1;
//while(!POW_ON);
// AUXR1=AUXR1| 0x08; //REST
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -