program ps2_test
dim keydata, special, down as byte
main:
CMCON = $07 ' Disable analog comparators (comment this for P18)
INTCON = 0 ' Disable all interrupts
Ps2_Init(PORTA) ' Init PS/2 Keyboard on PORTA
Delay_ms(100) ' Wait for keyboard to finish
do
if Ps2_Key_Read(keydata, special, down) = 1 then
if (down = 1) and (keydata = 16) then ' Backspace
' ...do something with a backspace...
else
if (down = 1) and (keydata = 13) then ' Enter
Usart_Write(13)
else
if (down = 1) and (special = 0) and (keydata <> 1) then
Usart_Write(keydata)
end if
end if
end if
end if
Delay_ms(10) ' debounce
loop until FALSE
end.