IBM H8 Network Card User Manual


 
HTEB1
User manual
Issue 0.2 Page 46 07/2002
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];