PS/2 Core For Altera DE-Series Boards
PS/2 Core For Altera DE-Series Boards
PS/2 Core For Altera DE-Series Boards
DE-Series Boards
1 Core Overview
The PS/2 Serial Port on Altera DE2/DE1 boards is intended for connecting a keyboard or a mouse to the board.
The PS/2 Core provides a connection to the PS/2 Serial Port and presents an easy-to-use communication interface to
PS/2 peripherals.
2 Functional Description
The PS/2 Core handles the timing of the PS/2 Serial Data Transmission Protocol. A device driver can communicate
with it by reading from and writing to its data and control registers.
Device drivers control and communicate with the PS/2 Core through two 32-bit registers. Communication with the
PS/2 peripheral is done by writing or reading the registers through the Avalon Slave Port. Table 1 shows the details
for the registers.
Notes on Table 1:
(1) Reserved. Read values are undefined. Write zero.
The PS/2 Core is packaged with C-language functions accessible through the the hardware abstraction layer (HAL)
as listed below. These functions implement common operations that users need for the PS/2 Core.
#include "altera_up_avalon_ps2.h"
In addition, some sample functions for specific communication with the keyboard or mouse are also provided.
They serve as a good starting point if the user wishes to develop more features with the PS/2 Port. To use the
keyboard or mouse communication functions, the corresponding header files, altera_up_ps2_keyboard.h
and altera_up_ps2_mouse.h, have to be included. These functions are described below.
Prototype:
typedef enum {
PS2_MOUSE = 0;
PS2_KEYBOARD = 1;
PS2_UNKNOWN = 2;
} PS2_DEVICE;
Include: <altera_up_avalon_ps2.h>
Fields: PS2_MOUSE — Indicate that the device is a PS/2 Mouse.
PS2_KEYBOARD — Indicate that the device is a PS/2 Keyboard.
PS2_UNKNOWN — The program cannot determine what type the device
is.
Prototype:
typedef enum {
KB_ASCII_MAKE_CODE = 1;
KB_BINARY_MAKE_CODE = 2;
KB_LONG_BINARY_MAKE_CODE = 3;
KB_BREAK_CODE = 4;
KB_LONG_BREAK_CODE = 5;
KB_INVALID_CODE = 6;
} KB_CODE_TYPE;
Include: <altera_up_ps2_keyboard.h>
Fields: KB_ASCII_MAKE_CODE — Make code that corresponds to an ASCII
character. For example, the ASCII make code for key [ A ] is 1C.
KB_BINARY_MAKE_CODE — Make code that corresponds to a non-
ASCII character. For example, the binary (non-ASCII) make code for
key [Left Alt] is 11.
KB_LONG_BINARY_MAKE_CODE — Make code that has two bytes
(the first byte is E0). For example, the long binary make code for key
[Right Alt] is "E0 11".
KB_BREAK_CODE — Break code that has two bytes (the first byte is
F0). For example, the break code for key [ A ] is "F0 1C".
KB_LONG_BREAK_CODE — Long break code that has three bytes
(with the first two bytes "E0 F0"). For example, the long break code
for key [Right Alt] is "E0 F0 11".
KB_INVALID_CODE — Scan codes that the decoding FSM is unable
to decode.
Description: The enum type for the type of keyboard code received.