Designer Reference Manual
USB08 Evaluation Board
116
Source Code Files
MOTOROLA
Source Code Files
U08KEY.C
//============================================================================
// File: U08KEY.C
// Func: Key Input Functions for USB08
// Ver.: 1.00
// Auth: (C)2000,2001 by Oliver Thamm, MCT Elektronikladen GbR
// http://hc08web.de/usb08
// Rem.: View/Edit this File with TAB-Size=4
//============================================================================
#include "hc08jb8.h"
#include "u08key.h"
//-- Definitions -------------------------------------------------------------
// Specification of *active* Key Inputs:
// PTA[4,5,6] = %01110000 = 0x70
// First Key connected to Port Bit 4
#define KEY_MASK 0x70
#define KEY_FIRST 4
//-- Variables ---------------------------------------------------------------
// Var used to track the Key Status
unsigned char KeyState;
//----------------------------------------------------------------------------
void initKey() {
POCR |= 0x01;
// enable PTA Pullups
PTA |= KEY_MASK;
// write 1 to Output Latches
DDRA |= KEY_MASK;
// output H-Level Pulse
DDRA &= ~KEY_MASK;
// back to Input
KBIER = KEY_MASK;
// enable Interrupts
KBSCR = 0x04;
// reset ACKK (just in case)
KeyState = 0;
// reset internal Status Var
}
//----------------------------------------------------------------------------
char getKey(unsigned char x) {
x += KEY_FIRST-1;
// calculate Bit Position
x = 1 << x;
// create Bit Mask
if(KeyState & x)
// test the relevant Status Bit
return 1;
return 0;
}
//----------------------------------------------------------------------------
@interrupt void isrKey() {
KeyState ^= ~(PTA | ~KEY_MASK);
KBSCR = 0x04;
// reset ACKK (for noise safety only)
}
//============================================================================
Содержание MC68HC908JB8
Страница 2: ...blank ...
Страница 6: ...Designer Reference Manual USB08 Evaluation Board 6 List of Sections MOTOROLA List of Sections ...
Страница 16: ...Designer Reference Manual USB08 Evaluation Board 16 List of Tables MOTOROLA List of Tables ...
Страница 42: ...Designer Reference Manual USB08 Evaluation Board 42 Hardware Description MOTOROLA Hardware Description ...
Страница 88: ...Designer Reference Manual USB08 Evaluation Board 88 USB08 Descriptors MOTOROLA USB08 Descriptors ...
Страница 243: ...blank ...