keyboard.c

来自「mcu_PPP.rar是在M68HC08单片机上编写的TCP/IP协议程序.实现」· C语言 代码 · 共 38 行

C
38
字号
#include <iogp20.h>
#include "Keyboard.h"

volatile BYTE Key = 0;

void KeyboardStart (void) {
	//////////////// Keyboard Initialization ////////////////
	INTKBSCR |= KB_IMASKK;
	INTKBSCR &= ~(KB_MODEK);
	DDRA = 0xF8;
	PTAPUE = 0x06; //Attach internal pullups for buttons

	INTKBIER = 0x06; //Register Key 1 and 2
	INTKBSCR &= ~(KB_ACK);
	
	INTKBSCR &= ~(KB_IMASKK); //Enable interrupts
}


#if HIWARE
interrupt 15 void KeyboardISR (void) {
#else
@interrupt void KeyboardISR (void) {
#endif

	INTKBSCR |= KB_ACK;

	if (Key) return;
	
	if (PORTA & KB_KEY1) {
		Key = KB_KEY1;
	}
	if (PORTA & KB_KEY2) {
		Key = KB_KEY2;
	}
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?