Mikroelektronika MIKROE-738 Datenbogen
![Mikroelektronika](https://files.manualsbrain.com/attachments/e0529b3b58069a916ad7bb89f7e9f5f0eda73421/common/fit/150/50/1b07b99aa3112e022a916b06db07f1f4f211e91d41878452d87c7638b1bf/brand_logo.gif)
mikroC PRO for PIC32
MikroElektronika
397
Ps2_Config
Ps2_Key_Read
Prototype
void Ps2_Config();
Description Initializes the MCU for work with the PS/2 keyboard.
Parameters None.
Returns
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 defined before using this function.
Example
// PS2 pinout definition
sbit PS2_Data at RB0_bit;
sbit PS2_Clock at RB1_bit;
sbit PS2_Data_Direction at TRISB0_bit;
sbit PS2_Clock_Direction at TRISB1_bit;
// End of PS2 pinout definition
...
Ps2_Config(); // Init PS/2 Keyboard
Notes
None.
Prototype
unsigned int Ps2_Key_Read(unsigned short *value, unsigned short *special,
unsigned short *pressed);
Description The function retrieves information on key pressed.
Parameters -
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 flag 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_Config routine.
Example
unsigned short keydata = 0, special = 0, down = 0;
...
// Press Enter to continue:
do {
if (Ps2_Key_Read(&keydata, &special, &down)) {
if (down && (keydata == 16)) break;
}
} while (1);
Notes
None.