Revision 81
added documentation
lab4/mouse.c | ||
---|---|---|
138 | 138 |
uint8_t stat; |
139 | 139 |
while(true){ |
140 | 140 |
if((ret = util_sys_inb(STATUS_REG, &stat))) return ret; |
141 |
//printf("%x\n",stat); |
|
141 | 142 |
if((stat&OUT_BUF_FUL) && (stat&AUX_MOUSE)) { |
142 | 143 |
if(stat & (PARITY_ERROR | TIME_OUT_REC)) return OTHER_ERROR; |
143 | 144 |
if((ret = util_sys_inb(OUTPUT_BUF, byte))) return ret; |
lab4/mouse.h | ||
---|---|---|
12 | 12 |
*/ |
13 | 13 |
int (subscribe_mouse_interrupt)(uint8_t interrupt_bit, int *interrupt_id); |
14 | 14 |
|
15 |
//These have to do with mouse_ih |
|
15 | 16 |
int got_error_mouse_ih; |
16 | 17 |
uint8_t packet_mouse_ih[3]; |
17 | 18 |
int counter_mouse_ih; |
18 | 19 |
|
20 |
/** |
|
21 |
* @brief Parse 3 bytes and returns it as a parsed, struct packet. |
|
22 |
* @param packet_bytes array of bytes to parse |
|
23 |
* @return parsed struct packet |
|
24 |
*/ |
|
19 | 25 |
struct packet (mouse_parse_packet)(const uint8_t *packet_bytes); |
20 | 26 |
|
27 |
/** |
|
28 |
* @brief Polls mouse for data. Blocks execution until a valid mouse packet is obtained. |
|
29 |
* @param pp pointer to packet struct in which the result will be stored |
|
30 |
* @param period time (in milliseconds) the poller should wait between pollings of bytes |
|
31 |
* @return ERROR_CODE code representing the result of the operation, SUCCESS code is returned if everything is OK |
|
32 |
*/ |
|
21 | 33 |
int mouse_poll(struct packet *pp, uint16_t period); |
22 | 34 |
|
23 | 35 |
/** |
24 |
* |
|
36 |
* @brief Sets data report mode for mouse |
|
37 |
* @param on zero to disable data report, any other value to enable data report |
|
38 |
* @return ERROR_CODE code representing the result of the operation, SUCCESS code is returned if everything is OK |
|
25 | 39 |
*/ |
26 | 40 |
int (mouse_set_data_report)(int on); |
27 | 41 |
|
... | ... | |
58 | 72 |
*/ |
59 | 73 |
int (mouse_read_byte)(uint8_t *byte); |
60 | 74 |
|
75 |
/** |
|
76 |
* @brief Same as @ref mouse_read_byte, except it does not wait for output buffer |
|
77 |
* to be full, since ACK is considered to arrive instantaneously somehow. |
|
78 |
* @param byte pointer to byte where ACK will be stored |
|
79 |
* @return ERROR_CODE code representing the result of the operation, SUCCESS code is returned if everything is OK |
|
80 |
*/ |
|
61 | 81 |
int (mouse_read_ack)(uint8_t *byte); |
62 | 82 |
|
83 |
/** |
|
84 |
* @brief Polls OUT_BUF for byte coming from mouse. |
|
85 |
* @param byte pointer to byte read from OUT_BUF |
|
86 |
* @param period time (in milliseconds) the poller should wait between pollings of bytes |
|
87 |
* @return ERROR_CODE code representing the result of the operation, SUCCESS code is returned if everything is OK |
|
88 |
*/ |
|
63 | 89 |
int (mouse_poll_byte)(uint8_t *byte, uint16_t period); |
64 | 90 |
|
65 | 91 |
/** |
Also available in: Unified diff