Revision 82
dont need to send READ_DATA command every time i want to read a byte; one READ_DATA is enough for 3 bytes (a full packet)
lab4/mouse.c | ||
---|---|---|
62 | 62 |
int mouse_poll(struct packet *pp, uint16_t period){ |
63 | 63 |
int ret = 0; |
64 | 64 |
|
65 |
int counter = 0; |
|
66 | 65 |
uint8_t packet[3]; |
67 | 66 |
uint8_t byte; |
68 |
while(counter < 3){ |
|
69 |
if((ret = mouse_read_data(&byte, period))) return ret; |
|
70 |
if((byte & FIRST_BYTE_ID) || counter){ |
|
71 |
packet[counter] = byte; |
|
72 |
counter++; |
|
73 |
} |
|
67 |
if ((ret = mouse_issue_cmd(READ_DATA))) return ret; |
|
68 |
for(unsigned i = 0; i < 3; ++i){ |
|
69 |
if((ret = mouse_poll_byte(&byte, period))) return ret; |
|
70 |
packet[i] = byte; |
|
74 | 71 |
} |
75 | 72 |
*pp = mouse_parse_packet(packet); |
76 | 73 |
return SUCCESS; |
... | ... | |
138 | 135 |
uint8_t stat; |
139 | 136 |
while(true){ |
140 | 137 |
if((ret = util_sys_inb(STATUS_REG, &stat))) return ret; |
141 |
//printf("%x\n",stat); |
|
142 | 138 |
if((stat&OUT_BUF_FUL) && (stat&AUX_MOUSE)) { |
143 | 139 |
if(stat & (PARITY_ERROR | TIME_OUT_REC)) return OTHER_ERROR; |
144 | 140 |
if((ret = util_sys_inb(OUTPUT_BUF, byte))) return ret; |
Also available in: Unified diff