keypad.c

来自「矿工定位系统单端」· C语言 代码 · 共 48 行

C
48
字号
// 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 + =
减小字号Ctrl + -
显示快捷键?