Project

General

Profile

Revision 36

implemented keyboard polling

View differences:

kbc.c
62 62
    if (increment) return ++counter;
63 63
    return counter;
64 64
}
65

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

  
82
int (kbd_read_byte)(uint8_t *value){
83
    uint8_t stat;
84
    while(1){
85
        if(util_sys_inb(STATUS_REG, &stat)) return 1;
86
        if((stat&OUT_BUF_FUL) && ((stat&AUX_MOUSE)^AUX_MOUSE)){
87
            if(stat & (PARITY_ERROR | TIME_OUT_REC)) return 1;
88
            else return util_sys_inb(OUTPUT_BUF, value);
89
        }
90
        tickdelay(micros_to_ticks(DELAY));
91
    }
92
}

Also available in: Unified diff