IBM H8 user manual Mask =

Page 46

HTEB1

User manual

if (data & mask) pcnt++; mask >>= 1;

}

if ((pcnt & 0x01) ^ (data & 0x0100)) return TRUE; return FALSE;

}

interrupt [IRQ_2] void IRQ_2_Isr(void)

// irq on key_clk

{

 

 

static u8 cnt;

 

 

static u16 val;

 

 

if (outact)

/* do some output? */

{

 

 

if (outval & 0x0001) PDR1 = cKEYDATA;

 

else PDR1 &= ~cKEYDATA;

 

 

outval >>= 1;

 

 

if (!outval)

 

 

{

 

 

PDR1 = cKEYDATA;

 

// set out=HIGH (1)

PCR1 &= ~cKEYDATA;

 

// set portpin as input (0)

outact=0;

 

 

}

 

 

}

 

 

else

 

// process input data

{

 

 

val >>= 1;

if (PDR1 & cKEYDATA) val = 0x0200; cnt++;

if (cnt>=11)

{

if (OddParStopCheck(val)==TRUE)

{

KeyCodeBuf[keyWriteIndex] = val; keyWriteIndex++;

if (keyWriteIndex >= cKeyBufSize) keyWriteIndex = 0; cnt = 0;

val = 0;

}

 

 

}

 

 

}

 

 

IRR1 &= ~0x04;

// clear IRQ-Flag

}

 

 

void SendKeyBoard(u8 data)

// send data to keyboard

{

 

 

u8 pcnt = 0;

 

 

u8 mask = 0x80;

 

 

outval = data 0x0600;

// stopbit + clkbit(internal)

while (mask)

// calculate odd parity

{

 

 

if (mask & data) pcnt++;

 

 

mask >>= 1;

 

 

}

 

 

if (!(pcnt & 0x01)) outval = 0x0100;

// set parity bit

PDR1 &= ~cKEYDATA;

// set data=LOW

PCR1 = cKEYDATA;

 

// set as output(1)

outact = 1;

// start output action

}

 

 

u8 kbhit(void)

{

if (keyReadIndex != keyWriteIndex) return TRUE; else return FALSE;

}

u16 GetKey(void)

{

u16 KeyCode;

KeyCode = KeyCodeBuf[keyReadIndex];

Issue 0.2

Page 46

07/2002

Image 46
Contents Hitachi H8/Tiny 3664F Preface Table of Contents System Development Kit content Hardware descriptionFeatures Board overview Board overviewJumpers and switches JP4, D/A CONOrientation Operation Connectors X1 SubD9, Pin Operation RemarkX3 LCD-CON SV1 SV2 SV3 SV4 PIN Installing the HTEB1 Start-Up instructionsTest program Software Installation Creating a program using IAR-EWH8 Development EnvironmentHTEB1 HTEB1 HTEB1 HTEB1 HTEB1 HTEB1 HTEB1 Download the code using FDT HTEB1 HTEB1 HTEB1 HTEB1 HTEB1 HTEB1 HTEB1 Workflow Examples Key’s and LED’s LEDSPEEDINIT4PMR1 &= ~KEYALL RunningLightInit Init keys and LEDs TimerAInit LCD Clearlcdrs Setlcdrw Lcddatactrl = Lcdin Setlcden HTEB1 SCI IsscitxfreeInit sci with 9600Baud, 8N1 A/D + PWM Lcddatactrl = Lcdin Setlcden Calculate av of last 15 values AT-Keyboard-Interface Setlcdrw Lcddatactrl = Lcdin Setlcden Mask = Msg buffer Tables Scan-Codes MFII-Keyboard Numeric Keypad Main Scan-Code Keypad Function Scan-Code Examples DatasheetsPrograms DemoAppendix B Schematic Appendix C Board layout HTEB1 HTEB1 HTEB1