Revision 40
fixed something
lab3/kbc.c | ||
---|---|---|
68 | 68 |
uint8_t c; |
69 | 69 |
if(kbc_read_byte(&c)) return 1; |
70 | 70 |
if(c == TWO_BYTE_CODE){ |
71 |
if(kbc_read_byte(&bytes[0])) return 1;
|
|
72 |
bytes[1] = c;
|
|
71 |
if(kbc_read_byte(&bytes[1])) return 1;
|
|
72 |
bytes[0] = c;
|
|
73 | 73 |
*size = 2; |
74 | 74 |
}else{ |
75 | 75 |
bytes[1] = 0; |
... | ... | |
93 | 93 |
|
94 | 94 |
int (kbc_issue_cmd)(uint8_t cmd){ |
95 | 95 |
uint8_t stat; |
96 |
while(1){
|
|
96 |
for(int i = 0; i < KBC_NUM_TRIES; ++i){
|
|
97 | 97 |
if(util_sys_inb(STATUS_REG, &stat)) return 1; |
98 | 98 |
if((stat&IN_BUF_FULL) == 0){ |
99 | 99 |
if(sys_outb(KBC_CMD, cmd)) return 1; |
lab3/kbc.h | ||
---|---|---|
6 | 6 |
#define KBC_IRQ 1 /* @brief KBC Controller IRQ Line */ |
7 | 7 |
|
8 | 8 |
/* Delay for KBC */ |
9 |
#define DELAY 20000 /* @brief KBC Response Delay */ |
|
9 |
#define DELAY 20000 /* @brief KBC Response Delay */ |
|
10 |
#define KBC_NUM_TRIES 10 /* @brief Number of tries to issue command before timeout */ |
|
10 | 11 |
|
11 | 12 |
/* I/O Ports Addresses */ |
12 | 13 |
|
lab3/lab3.c | ||
---|---|---|
100 | 100 |
uint8_t cmd = 0; |
101 | 101 |
if(kbc_read_cmd(&cmd)) return 1; |
102 | 102 |
cmd = (cmd | INT_KBD) & (~DIS_KBD); |
103 |
|
|
104 | 103 |
if(kbc_change_cmd(cmd)) return 1; |
105 | 104 |
|
106 | 105 |
return 0; |
Also available in: Unified diff