Revision 70
implemented remote, working on fixing issues
mouse.c | ||
---|---|---|
66 | 66 |
printf("ACK: %x\n", ack); |
67 | 67 |
return SUCCESS; |
68 | 68 |
} |
69 |
|
|
70 |
int (mouse_read_data)(uint8_t *data) { |
|
71 |
int ret; |
|
72 |
if ((ret = mouse_issue_cmd(READ_DATA))) return ret; |
|
73 |
if ((ret = mouse_read_byte(data))) return ret; |
|
74 |
return SUCCESS; |
|
75 |
} |
|
76 |
|
|
77 |
int (mouse_issue_cmd)(uint32_t cmd) { |
|
78 |
int ret; |
|
79 |
uint8_t ack = 0; |
|
80 |
while (ack != ACK_ERROR) { |
|
81 |
if ((ret = kbc_issue_cmd(MOUSE_WRITE_B))) return ret; |
|
82 |
if ((ret = kbc_issue_arg(cmd))) return ret; |
|
83 |
if ((ret = mouse_read_byte(&ack))) return ret; |
|
84 |
if (ack == ACK_OK) return SUCCESS; |
|
85 |
tickdelay(micros_to_ticks(DELAY)); |
|
86 |
} |
|
87 |
return INVALID_COMMAND; |
|
88 |
} |
|
89 |
|
|
90 |
int (mouse_read_byte)(uint8_t *byte) { |
|
91 |
int ret = 0; |
|
92 |
uint8_t stat; |
|
93 |
for(int i = 0; i < KBC_NUM_TRIES; ++i){ |
|
94 |
if((ret = util_sys_inb(STATUS_REG, &stat))) return ret; |
|
95 |
if((stat&OUT_BUF_FUL) && (stat&AUX_MOUSE)) { |
|
96 |
if(stat & (PARITY_ERROR | TIME_OUT_REC)) return OTHER_ERROR; |
|
97 |
if((ret = util_sys_inb(OUTPUT_BUF, byte))) return ret; |
|
98 |
else return SUCCESS; |
|
99 |
} |
|
100 |
tickdelay(micros_to_ticks(DELAY)); |
|
101 |
} |
|
102 |
return TIMEOUT_ERROR; |
|
103 |
} |
Also available in: Unified diff