IBM H8 Network Card User Manual


 
HTEB1
User manual
Issue 0.2 Page 47 07/2002
keyReadIndex++;
if (keyReadIndex >= cKeyBufSize) keyReadIndex = 0;
return KeyCode;
}
u8 buffer[17] = " KeyCode : 0000 \0"; // msg buffer
// convert int to ASCII-HEX
void ShowCode(u16 code)
{
u8 *data, c;
data = &buffer[14]; // last digit = start address
while (code)
{
*data = '0'; // default = '0'
c = code & 0x000f; // check digit
if (c) // if > 0 chk for value
{
if (c < 10) *data = '0'+c; // 0..9
else *data = 'A'+c-10; // a..f
}
data--; // next digit
code >>= 4;
}
LCDWriteLine(1,buffer); // show result
}
void KeyTest(void)
{
u8 c;
u16 KeyCode;
PMR1 |= cKEYCLK; // P16 irq-input
PMR1 &= ~cKEYDATA; // P17 i/o-pin
IEGR1 &= ~0x04; // IRQ_2 on falling edge
IENR1 |= 0x04; // enable IRQ_2
set_interrupt_mask(0); // enable all interrupts
LCDWriteLine(0, "PC-Keyboard-Test");
LCDWriteLine(1, "press any key...");
while (1)
{
if (kbhit()) // if new key ...
{
KeyCode = GetKey(); // get codes
ShowCode(KeyCode); // display code
}
}
}
void main(void)
{
LCDInit(); // init ports and LCD
KeyTest(); // go to keyboard test
}