Project

General

Profile

Revision 38

few changes to polling

View differences:

kbc.c
79 79
    return 0;
80 80
}
81 81

  
82
int (kbd_read_byte)(uint8_t *value){
82
int (kbd_issue_cmd)(uint8_t cmd){
83 83
    uint8_t stat;
84
    while(1){
84
    for(int i = 0; i < 10; ++i){
85 85
        if(util_sys_inb(STATUS_REG, &stat)) return 1;
86
        if((stat&OUT_BUF_FUL) && ((stat&AUX_MOUSE)^AUX_MOUSE)){
86
        if((stat&IN_BUF_FULL) == 0){
87
            if(sys_outb(KBC_CMD, cmd)) return 1;
88
            return 0;
89
        }
90
        tickdelay(micros_to_ticks(DELAY));
91
    }
92
    return 1;
93
}
94

  
95
int (kbd_read_byte)(uint8_t *byte){
96
    uint8_t stat;
97
    while(true){
98
        if(util_sys_inb(STATUS_REG, &stat)) return 1;
99
        if((stat&OUT_BUF_FUL) && (stat&AUX_MOUSE)==0){
87 100
            if(stat & (PARITY_ERROR | TIME_OUT_REC)) return 1;
88
            else return util_sys_inb(OUTPUT_BUF, value);
101
            if(util_sys_inb(OUTPUT_BUF, byte)) return 1;
102
            else return 0;
89 103
        }
90 104
        tickdelay(micros_to_ticks(DELAY));
91 105
    }
92 106
}
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