User manual
mikroPascal PRO for dsPIC30/33 and PIC24
MikroElektronika
428
Ps2_Cong
Ps2_Key_Read
Prototype
procedure Ps2_Cong();
Description Initializes the MCU for work with the PS/2 keyboard.
Parameters None.
Returns Nothing.
Requires Global variables:
- PS2_Data: Data signal line
- PS2_Clock: Clock signal line
- PS2_Data_Direction: Direction of the Data pin
- PS2_Clock_Direction: Direction of the Clock pin
must be dened before using this function.
Example
// PS2 pinout denition
var PS2_Data : sbit at RB0_bit;
var PS2_Clock : sbit at RB1_bit;
var PS2_Data_Direction : sbit at TRISB0_bit;
var PS2_Clock_Direction : sbit at TRISB1_bit;
// End of PS2 pinout denition// Init PS/2 Keyboard
Notes None.
Prototype
function Ps2_Key_Read(var value : byte; var special : byte; var pressed :
byte) : word;
Description The function retrieves information on key pressed.
Parameters - value: holds the value of the key pressed. For characters, numerals, punctuation marks, and space
value will store the appropriate ASCII code. Routine “recognizes” the function of Shift and Caps Lock,
and behaves appropriately. For special function keys see Special Function Keys Table.
- special: is a ag for special function keys (F1, Enter, Esc, etc). If key pressed is one of these,
special will be set to 1, otherwise 0.
- pressed: is set to 1 if the key is pressed, and 0 if it is released.
Returns - 1 if reading of a key from the keyboard was successful
- 0 if no key was pressed
Requires PS/2 keyboard needs to be initialized. See Ps2_Cong routine.
Example
var value, special, pressed : word;
...
// Press Enter to continue:
repeat {
if (Ps2_Key_Read(value, special, pressed)) then
if ((value = 13) and (special = 1)) then break;
until (0=1);
Notes None.