Project

General

Profile

Revision 39

fixed frozen keyboard

View differences:

kbc.c
66 66
int (kbd_poll)(uint8_t bytes[], uint8_t *size){
67 67
    if(bytes == NULL || size == NULL) return 1;
68 68
    uint8_t c;
69
    if(kbd_read_byte(&c)) return 1;
69
    if(kbc_read_byte(&c)) return 1;
70 70
    if(c == TWO_BYTE_CODE){
71
        if(kbd_read_byte(&bytes[0])) return 1;
71
        if(kbc_read_byte(&bytes[0])) return 1;
72 72
        bytes[1] = c;
73 73
        *size = 2;
74 74
    }else{
......
79 79
    return 0;
80 80
}
81 81

  
82
int (kbd_issue_cmd)(uint8_t cmd){
82
int (kbc_read_cmd)(uint8_t *cmd){
83
    if(kbc_issue_cmd(READ_KBC_CMD)) return 1;
84
    if(kbc_read_byte(cmd)) return 1;
85
    return 0;
86
}
87

  
88
int (kbc_change_cmd)(uint8_t cmd){
89
    if(kbc_issue_cmd(WRITE_KBC_CMD)) return 1;
90
    if(sys_outb(KBC_CMD_ARG, cmd)) return 1;
91
    return 0;
92
}
93

  
94
int (kbc_issue_cmd)(uint8_t cmd){
83 95
    uint8_t stat;
84
    for(int i = 0; i < 10; ++i){
96
    while(1){
85 97
        if(util_sys_inb(STATUS_REG, &stat)) return 1;
86 98
        if((stat&IN_BUF_FULL) == 0){
87 99
            if(sys_outb(KBC_CMD, cmd)) return 1;
......
92 104
    return 1;
93 105
}
94 106

  
95
int (kbd_read_byte)(uint8_t *byte){
107
int (kbc_read_byte)(uint8_t *byte){
96 108
    uint8_t stat;
97 109
    while(true){
98 110
        if(util_sys_inb(STATUS_REG, &stat)) return 1;
......
104 116
        tickdelay(micros_to_ticks(DELAY));
105 117
    }
106 118
}
107

  
108
int (kbd_read_cmd)(uint8_t *cmd){
109
    if(kbd_issue_cmd(0x20)) return 1;
110
    if(kbd_read_byte(cmd)) return 1;
111
    return 0;
112
}

Also available in: Unified diff