Revision 72
packet now working fine
lab4/kbc.c | ||
---|---|---|
68 | 68 |
uint8_t stat; |
69 | 69 |
for(int i = 0; i < KBC_NUM_TRIES; ++i){ |
70 | 70 |
if((ret = util_sys_inb(STATUS_REG, &stat))) return ret;//printf("kbc.c,L71\n"); |
71 |
printf("%x %d %d\n", stat, (stat&OUT_BUF_FUL), (stat&AUX_MOUSE)); |
|
71 | 72 |
if((stat&OUT_BUF_FUL) && (stat&AUX_MOUSE)==0){//printf("kbc.c,L72\n"); |
72 | 73 |
if(stat & (PARITY_ERROR | TIME_OUT_REC)) return OTHER_ERROR;//printf("kbc.c,L73\n"); |
73 | 74 |
if((ret = util_sys_inb(OUTPUT_BUF, byte))) return ret; |
... | ... | |
75 | 76 |
} |
76 | 77 |
tickdelay(micros_to_ticks(DELAY)); |
77 | 78 |
} |
79 |
printf("Timing out\n"); |
|
78 | 80 |
return TIMEOUT_ERROR; |
79 | 81 |
} |
lab4/lab4.c | ||
---|---|---|
44 | 44 |
int mouse_id = 0; |
45 | 45 |
int mouse_irq = BIT(mouse_irq_bit); |
46 | 46 |
if (subscribe_mouse_interrupt(mouse_irq_bit, &mouse_id)) return 1; |
47 |
if(mouse_enable_data_reporting()) return 1;
|
|
47 |
if (mouse_issue_cmd(ENABLE_DATA_REP)) return 1;
|
|
48 | 48 |
/// cycle |
49 | 49 |
int good = 1; |
50 | 50 |
uint32_t cnt_now = 0; |
... | ... | |
76 | 76 |
} |
77 | 77 |
|
78 | 78 |
if (unsubscribe_interrupt(&mouse_id)) return 1; |
79 |
int ret = mouse_set_data_report(false);
|
|
80 |
printf("%d\n", ret); |
|
79 |
if (mouse_issue_cmd(DIS_DATA_REP)) return 1;
|
|
80 |
|
|
81 | 81 |
return 0; |
82 | 82 |
} |
83 | 83 |
|
lab4/mouse.c | ||
---|---|---|
58 | 58 |
|
59 | 59 |
int (mouse_set_data_report)(int on){ |
60 | 60 |
int ret = 0; |
61 |
printf("L61\n"); |
|
62 |
if((ret = kbc_issue_cmd(MOUSE_WRITE_B))) return ret; printf("L62\n"); |
|
63 |
if((ret = kbc_issue_arg(DIS_DATA_REP))) return ret; printf("L63\n"); |
|
61 |
if((ret = kbc_issue_cmd(MOUSE_WRITE_B))) return ret; |
|
62 |
if((ret = kbc_issue_arg(DIS_DATA_REP))) return ret; |
|
64 | 63 |
uint8_t ack = 0; |
65 |
if((ret = kbc_read_byte(&ack))) return ret;printf("L65\n"); |
|
64 |
printf("L64\n"); |
|
65 |
if((ret = kbc_read_byte(&ack))) return ret; |
|
66 |
printf("L66\n"); |
|
66 | 67 |
printf("ACK: %x\n", ack); |
67 | 68 |
return SUCCESS; |
68 | 69 |
} |
... | ... | |
77 | 78 |
int (mouse_issue_cmd)(uint32_t cmd) { |
78 | 79 |
int ret; |
79 | 80 |
uint8_t ack = 0; |
80 |
while (ack != ACK_ERROR) {
|
|
81 |
for(unsigned i = 0; i < KBC_NUM_TRIES; ++i) {
|
|
81 | 82 |
if ((ret = kbc_issue_cmd(MOUSE_WRITE_B))) return ret; |
82 | 83 |
if ((ret = kbc_issue_arg(cmd))) return ret; |
83 | 84 |
if ((ret = mouse_read_byte(&ack))) return ret; |
84 | 85 |
if (ack == ACK_OK) return SUCCESS; |
86 |
if (ack == ACK_ERROR) return INVALID_COMMAND; |
|
85 | 87 |
tickdelay(micros_to_ticks(DELAY)); |
86 | 88 |
} |
87 |
return INVALID_COMMAND;
|
|
89 |
return TIMEOUT_ERROR;
|
|
88 | 90 |
} |
89 | 91 |
|
90 | 92 |
int (mouse_read_byte)(uint8_t *byte) { |
Also available in: Unified diff