Revision 50
Fixed polling minor issue; refactor code
kbc_func.c | ||
---|---|---|
37 | 37 |
return; |
38 | 38 |
} |
39 | 39 |
|
40 |
if ((status & OUT_BUF_FUL) == 0 || (status & AUX_MOUSE) != 0) { |
|
41 |
got_error = 1; |
|
42 |
return; |
|
43 |
} |
|
44 |
|
|
40 | 45 |
uint8_t byte = 0; |
41 | 46 |
|
42 | 47 |
if (util_sys_inb(OUTPUT_BUF, &byte)) { |
... | ... | |
73 | 78 |
|
74 | 79 |
int (kbc_change_cmd)(uint8_t cmd){ |
75 | 80 |
if(kbc_issue_cmd(WRITE_KBC_CMD)) return 1; |
76 |
if(sys_outb(KBC_CMD_ARG, cmd)) return 1;
|
|
81 |
if(kbc_issue_arg(cmd)) return 1;
|
|
77 | 82 |
return 0; |
78 | 83 |
} |
79 | 84 |
|
... | ... | |
98 | 103 |
return 1; |
99 | 104 |
} |
100 | 105 |
|
106 |
int (kbc_issue_arg)(uint8_t arg){ |
|
107 |
uint8_t stat; |
|
108 |
for(int i = 0; i < KBC_NUM_TRIES; ++i){ |
|
109 |
if(util_sys_inb(STATUS_REG, &stat)) return 1; |
|
110 |
if((stat&IN_BUF_FULL) == 0){ |
|
111 |
if(sys_outb(KBC_CMD_ARG, arg)) return 1; |
|
112 |
return 0; |
|
113 |
} |
|
114 |
tickdelay(micros_to_ticks(DELAY)); |
|
115 |
} |
|
116 |
return 1; |
|
117 |
} |
|
118 |
|
|
101 | 119 |
int (kbc_read_byte)(uint8_t *byte){ |
102 | 120 |
uint8_t stat; |
103 | 121 |
while(true){ |
Also available in: Unified diff