root / proj / src / libs / kbc / include / mouse.h @ 378
History | View | Annotate | Download (4.28 KB)
1 |
#ifndef MOUSE_H_INCLUDED
|
---|---|
2 |
#define MOUSE_H_INCLUDED
|
3 |
|
4 |
/**
|
5 |
* @defgroup mouse mouse
|
6 |
* @ingroup kbc
|
7 |
* @brief Mouse module.
|
8 |
*
|
9 |
* @{
|
10 |
*/
|
11 |
|
12 |
/**
|
13 |
* @brief Subscribes Mouse Interrupts and disables Minix Default IH
|
14 |
* @param interrupt_bit Bit of Interrupt Vector that will be set when Mouse Interrupt is pending
|
15 |
* @param interrupt_id Mouse Interrupt ID to specify the Mouse Interrupt in other calls
|
16 |
* @return ERROR_CODE code representing the result of the operation, SUCCESS code is returned if everything is OK
|
17 |
* @see {_ERRORS_H_::errors}
|
18 |
*/
|
19 |
int (subscribe_mouse_interrupt)(uint8_t interrupt_bit, int *interrupt_id); |
20 |
|
21 |
//These have to do with mouse_ih
|
22 |
/**
|
23 |
* @brief Get previous mouse interrupt handler call exit code.
|
24 |
* @return Exit code of previous mouse IH call
|
25 |
*/
|
26 |
int (mouse_get_got_error_mouse_ih)(void); |
27 |
/**
|
28 |
* @brief Get mouse packet.
|
29 |
* @return Pointer to mouse packet
|
30 |
*/
|
31 |
const uint8_t* (mouse_get_packet_mouse_ih)(void); |
32 |
/**
|
33 |
* @brief Number of mouse bytes received (0 to 3).
|
34 |
* @return Number of bytes
|
35 |
*/
|
36 |
int (mouse_get_counter_mouse_ih)(void); |
37 |
/**
|
38 |
* @brief Set number of received mouse bytes.
|
39 |
*
|
40 |
* Usually this function is used to reset counter_mouse_ih.
|
41 |
* @param n New value of the counter
|
42 |
*/
|
43 |
void (mouse_set_counter_mouse_ih)(int n); |
44 |
|
45 |
/**
|
46 |
* @brief Parse 3 bytes and returns it as a parsed, struct packet.
|
47 |
* @param packet_bytes array of bytes to parse
|
48 |
* @param pp Pointer to packet to store the information.
|
49 |
*/
|
50 |
void (mouse_parse_packet)(const uint8_t *packet_bytes, struct packet *pp); |
51 |
|
52 |
/**
|
53 |
* @brief Polls mouse for data. Blocks execution until a valid mouse packet is obtained.
|
54 |
* @param pp pointer to packet struct in which the result will be stored
|
55 |
* @param period time (in milliseconds) the poller should wait between pollings of bytes
|
56 |
* @return ERROR_CODE code representing the result of the operation, SUCCESS code is returned if everything is OK
|
57 |
*/
|
58 |
int mouse_poll(struct packet *pp, uint16_t period); |
59 |
|
60 |
/**
|
61 |
* @brief Sets data report mode for mouse
|
62 |
* @param on zero to disable data report, any other value to enable data report
|
63 |
* @return ERROR_CODE code representing the result of the operation, SUCCESS code is returned if everything is OK
|
64 |
*/
|
65 |
int (mouse_set_data_report)(int on); |
66 |
|
67 |
/**
|
68 |
* @brief Reads data byte from mouse
|
69 |
* <summary>
|
70 |
* Polls the mouse till data is available for reading
|
71 |
* </summary>
|
72 |
* @param data Pointer to variable where byte read from mouse will be stored
|
73 |
* @param period Time that the process should wait before polling again, in microseconds
|
74 |
* @return ERROR_CODE code representing the result of the operation, SUCCESS code is returned if everything is OK
|
75 |
* @see {_ERRORS_H_::errors}
|
76 |
*/
|
77 |
int (mouse_read_data)(uint8_t *data, uint16_t period);
|
78 |
|
79 |
/**
|
80 |
* @brief Issues command to mouse
|
81 |
* <summary>
|
82 |
* Issues command to mouse, returns error after two consecutive errors reported by the acknowledgment byte
|
83 |
* </summary>
|
84 |
* @param cmd Command to be issued
|
85 |
* @return ERROR_CODE code representing the result of the operation, SUCCESS code is returned if everything is OK
|
86 |
* @see {_ERRORS_H_::errors}
|
87 |
*/
|
88 |
int (mouse_issue_cmd)(uint8_t cmd);
|
89 |
|
90 |
/**
|
91 |
* @brief Reads byte from mouse
|
92 |
* <summary>
|
93 |
* Reads byte from mouse, giving error if exceeds number of tries to read
|
94 |
* </summary>
|
95 |
* @param byte Pointer to variable where byte read from mouse will be stored
|
96 |
* @return ERROR_CODE code representing the result of the operation, SUCCESS code is returned if everything is OK
|
97 |
* @see {_ERRORS_H_::errors}
|
98 |
*/
|
99 |
int (mouse_read_byte)(uint8_t *byte);
|
100 |
|
101 |
/**
|
102 |
* @brief Polls OUT_BUF for byte coming from mouse.
|
103 |
* @param byte pointer to byte read from OUT_BUF
|
104 |
* @param period time (in milliseconds) the poller should wait between pollings of bytes
|
105 |
* @return ERROR_CODE code representing the result of the operation, SUCCESS code is returned if everything is OK
|
106 |
*/
|
107 |
int (mouse_poll_byte)(uint8_t *byte, uint16_t period);
|
108 |
|
109 |
/**
|
110 |
* @brief Converts 9-bit number to 16-bit with sign extension
|
111 |
* @param sign_bit Sign bit identifiying the signal of the number
|
112 |
* @param byte Least significant byte that will be extended
|
113 |
* @return Extended 9-bit number
|
114 |
*/
|
115 |
int16_t (sign_extend_byte)(uint8_t sign_bit, uint8_t byte); |
116 |
|
117 |
/**
|
118 |
* @}
|
119 |
*/
|
120 |
|
121 |
#endif //MOUSE_H_INCLUDED |