Rev 520 | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
6 | lvd | 1 | #ifndef PS2_H |
2 | #define PS2_H |
||
3 | |||
127 | chrv | 4 | /** |
5 | * @file |
||
6 | * @brief PS/2 mouse and keyboard support. |
||
7 | * @author http://www.nedopc.com |
||
8 | * |
||
9 | * PS/2 keyboard support (read only). |
||
10 | * |
||
11 | * PS/2 mouse support (read/write). |
||
12 | * ZX Kempston mouse interface emulation. |
||
13 | * |
||
14 | * Support PS/2 mouses: |
||
15 | * - "microsoft" mouses with wheel (4bytes data); |
||
16 | * - classic mouses (3bytes data). |
||
17 | */ |
||
6 | lvd | 18 | |
60 | chrv | 19 | /** |
20 | * Decode received data. |
||
21 | * @return decoded data. |
||
127 | chrv | 22 | * @param count - counter. |
23 | * @param shifter - received bits. |
||
60 | chrv | 24 | */ |
25 | UBYTE ps2_decode(UBYTE count, UWORD shifter); |
||
127 | chrv | 26 | |
60 | chrv | 27 | /** |
28 | * Encode (prepare) sended data. |
||
29 | * @return encoded data. |
||
127 | chrv | 30 | * @param data - data to send. |
60 | chrv | 31 | */ |
32 | UWORD ps2_encode(UBYTE data); |
||
6 | lvd | 33 | |
127 | chrv | 34 | /** Timeout value for PS/2 keyboard. */ |
35 | #define PS2KEYBOARD_TIMEOUT 20 |
||
6 | lvd | 36 | |
149 | chrv | 37 | /** Command to reset PS2 keyboard. */ |
38 | #define PS2KEYBOARD_CMD_RESET 0xFF |
||
39 | /** Command to enable PS2 keyboard. */ |
||
40 | #define PS2KEYBOARD_CMD_ENABLE 0xF4 |
||
41 | /** Command to set leds on PS2 keyboard. */ |
||
42 | #define PS2KEYBOARD_CMD_SETLED 0xED |
||
43 | |||
44 | /** "Caps Lock" led bit in set leds command on PS2 keyboard. */ |
||
45 | #define PS2KEYBOARD_LED_CAPSLOCK 0x04 |
||
46 | /** "Num Lock" led bit in set leds command on PS2 keyboard. */ |
||
47 | #define PS2KEYBOARD_LED_NUMLOCK 0x02 |
||
48 | /** "Scroll Lock" led bit in set leds command on PS2 keyboard. */ |
||
49 | #define PS2KEYBOARD_LED_SCROLLOCK 0x01 |
||
50 | |||
127 | chrv | 51 | /** Received PS/2 keyboard data register. */ |
60 | chrv | 52 | extern volatile UWORD ps2keyboard_shifter; |
127 | chrv | 53 | /** Counter of current PS/2 keyboard data bit. */ |
60 | chrv | 54 | extern volatile UBYTE ps2keyboard_count; |
127 | chrv | 55 | /** Timeout register for detecting PS/2 keyboard timeouts. */ |
60 | chrv | 56 | extern volatile UBYTE ps2keyboard_timeout; |
149 | chrv | 57 | /** Counter of stages PS/2 keyboard command. */ |
58 | extern volatile UBYTE ps2keyboard_cmd_count; |
||
59 | /** Current PS/2 keyboard command (0 - none). */ |
||
60 | extern volatile UBYTE ps2keyboard_cmd; |
||
6 | lvd | 61 | |
494 | chrv | 62 | /** Reset PS2 keyboard log. */ |
63 | void ps2keyboard_reset_log(void); |
||
64 | |||
149 | chrv | 65 | /** |
494 | chrv | 66 | * Get data from PS2 keyboard log. |
67 | * @return data byte (0 - log empty, 0xFF - log overload). |
||
68 | */ |
||
69 | UBYTE ps2keyboard_from_log(void); |
||
70 | |||
71 | /** |
||
149 | chrv | 72 | * Send command to PS/2 keboard. |
73 | * @param cmd [in] - command. |
||
74 | */ |
||
75 | void ps2keyboard_send_cmd(UBYTE cmd); |
||
76 | |||
127 | chrv | 77 | /** PS/2 keyboard task. */ |
78 | void ps2keyboard_task(void); |
||
6 | lvd | 79 | |
127 | chrv | 80 | /** |
81 | * Parsing PS/2 keboard recived bytes . |
||
82 | * @param recbyte [in] - received byte. |
||
83 | */ |
||
84 | void ps2keyboard_parse(UBYTE recbyte); |
||
6 | lvd | 85 | |
75 | chrv | 86 | /** Timeout for waiting response from mouse. */ |
60 | chrv | 87 | #define PS2MOUSE_TIMEOUT 20 |
127 | chrv | 88 | /** Received/sended PS/2 mouse data register. */ |
75 | chrv | 89 | extern volatile UWORD ps2mouse_shifter; |
127 | chrv | 90 | /** Counter of current PS/2 mouse data bit. */ |
75 | chrv | 91 | extern volatile UBYTE ps2mouse_count; |
127 | chrv | 92 | /** Timeout register for detecting PS/2 mouse timeouts. */ |
60 | chrv | 93 | extern volatile UBYTE ps2mouse_timeout; |
127 | chrv | 94 | /** Index of PS/2 mouse initialization step (@see ps2mouse_init_sequence). */ |
60 | chrv | 95 | extern volatile UBYTE ps2mouse_initstep; |
127 | chrv | 96 | /** Counter of PS/2 mouse response bytes. */ |
60 | chrv | 97 | extern volatile UBYTE ps2mouse_resp_count; |
299 | chrv | 98 | /** Current PS/2 keyboard command (0 - none). */ |
99 | extern volatile UBYTE ps2mouse_cmd; |
||
60 | chrv | 100 | |
299 | chrv | 101 | /** Command to reset PS2 mouse. */ |
102 | #define PS2MOUSE_CMD_RESET 0xFF |
||
103 | /** Command get type of PS2 mouse. */ |
||
104 | #define PS2MOUSE_CMD_GET_TYPE 0xF2 |
||
105 | /** Command to set resolution PS2 mouse. */ |
||
106 | #define PS2MOUSE_CMD_SET_RESOLUTION 0xE8 |
||
107 | |||
127 | chrv | 108 | /** PS/2 mouse task. */ |
60 | chrv | 109 | void ps2mouse_task(void); |
110 | |||
299 | chrv | 111 | /** |
112 | * Set PS/2 mouse resolution. |
||
113 | * If left and right mouse buttons and some keyboard button pressed then resolution set. |
||
114 | * @param code [in] - control codes: |
||
115 | * <B>0x7C</B> (keypad '*') - set default resolution; |
||
116 | * <B>0x79</B> (keypad '+') - inc resolution; |
||
117 | * <B>0x7B</B> (keypad '-') - dec resolution. |
||
118 | */ |
||
119 | void ps2mouse_set_resolution(UBYTE code); |
||
120 | |||
60 | chrv | 121 | #endif //PS2_H |
122 |