U08Key.c - Motorola USB08 Reference Manual

Universal serial bus evaluation board using the mc68hc908jb8
Table of Contents

Advertisement

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;
PTA
|= KEY_MASK;
DDRA |= KEY_MASK;
DDRA &= ~KEY_MASK;
KBIER = KEY_MASK;
KBSCR = 0x04;
KeyState = 0;
}
//----------------------------------------------------------------------------
char getKey(unsigned char x) {
x += KEY_FIRST-1;
x = 1 << x;
if(KeyState & x)
return 1;
return 0;
}
//----------------------------------------------------------------------------
@interrupt void isrKey() {
KeyState ^= ~(PTA | ~KEY_MASK);
KBSCR = 0x04;
}
//============================================================================
Designer Reference Manual
116
// enable PTA Pullups
// write 1 to Output Latches
// output H-Level Pulse
// back to Input
// enable Interrupts
// reset ACKK (just in case)
// reset internal Status Var
// calculate Bit Position
// create Bit Mask
// test the relevant Status Bit
// reset ACKK (for noise safety only)
Source Code Files
USB08 Evaluation Board
MOTOROLA

Advertisement

Table of Contents
loading

This manual is also suitable for:

Mc68hc908jb8

Table of Contents