Subversion Repositories pentevo

Rev

Blame | Last modification | View Log | Download | RSS feed | ?url?

  1. #ifndef PS2_H
  2. #define PS2_H
  3.  
  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.  */
  18.  
  19. /**
  20.  * Decode received data.
  21.  * @return decoded data.
  22.  * @param count - counter.
  23.  * @param shifter - received bits.
  24.  */
  25. UBYTE ps2_decode(UBYTE count, UWORD shifter);
  26.  
  27. /**
  28.  * Encode (prepare) sended data.
  29.  * @return encoded data.
  30.  * @param data - data to send.
  31.  */
  32. UWORD ps2_encode(UBYTE data);
  33.  
  34. /** Timeout value for PS/2 keyboard. */
  35. #define PS2KEYBOARD_TIMEOUT 20
  36.  
  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.  
  51. /** Received PS/2 keyboard data register. */
  52. extern volatile UWORD ps2keyboard_shifter;
  53. /** Counter of current PS/2 keyboard data bit. */
  54. extern volatile UBYTE ps2keyboard_count;
  55. /** Timeout register for detecting PS/2 keyboard timeouts. */
  56. extern volatile UBYTE ps2keyboard_timeout;
  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;
  61.  
  62. /**
  63.  * Send command to PS/2 keboard.
  64.  * @param cmd [in] - command.
  65.  */
  66. void ps2keyboard_send_cmd(UBYTE cmd);
  67.  
  68. /** PS/2 keyboard task. */
  69. void ps2keyboard_task(void);
  70.  
  71. /**
  72.  * Parsing PS/2 keboard recived bytes .
  73.  * @param recbyte [in] - received byte.
  74.  */
  75. void ps2keyboard_parse(UBYTE recbyte);
  76.  
  77. /** Timeout for waiting response from mouse. */
  78. #define PS2MOUSE_TIMEOUT 20
  79. /** Received/sended PS/2 mouse data register. */
  80. extern volatile UWORD ps2mouse_shifter;
  81. /** Counter of current PS/2 mouse data bit. */
  82. extern volatile UBYTE ps2mouse_count;
  83. /** Timeout register for detecting PS/2 mouse timeouts. */
  84. extern volatile UBYTE ps2mouse_timeout;
  85. /** Index of PS/2 mouse initialization step (@see ps2mouse_init_sequence). */
  86. extern volatile UBYTE ps2mouse_initstep;
  87. /** Counter of PS/2 mouse response bytes. */
  88. extern volatile UBYTE ps2mouse_resp_count;
  89.  
  90. /** PS/2 mouse task. */
  91. void ps2mouse_task(void);
  92.  
  93. #endif //PS2_H
  94.  
  95.