Project

General

Profile

Revision 77

fixed test_packets

View differences:

mouse.c
61 61
}
62 62

  
63 63
int (mouse_set_data_report)(int on){
64
    if(on) return mouse_issue_cmd(ENABLE_DATA_REP);
65
    else   return mouse_issue_cmd(   DIS_DATA_REP);
64
    int ret = 0;
65
    if(on){
66
        if((ret = mouse_issue_cmd(ENABLE_DATA_REP))) return ret;
67
    }
68
    else{
69
        if((ret = mouse_issue_cmd(   DIS_DATA_REP))) return ret;
70
    }
71
    return ret;
66 72
}
67 73

  
68 74
int (mouse_read_data)(uint8_t *data) {
......
75 81
int (mouse_issue_cmd)(uint32_t cmd) {
76 82
    int ret;
77 83
    uint8_t ack = 0;
78
    for(unsigned i = 0; i < KBC_NUM_TRIES; ++i) {
79
        if ((ret = kbc_issue_cmd(MOUSE_WRITE_B))) return ret;
80
        if ((ret = kbc_issue_arg(cmd))) return ret;
81
        if ((ret = mouse_read_byte(&ack))) return ret;
82
        if (ack == ACK_OK) return SUCCESS;
83
        if (ack == ACK_ERROR) return INVALID_COMMAND;
84
        tickdelay(micros_to_ticks(DELAY));
85
    }
86
    return TIMEOUT_ERROR;
84
    if ((ret = kbc_issue_cmd(MOUSE_WRITE_B))) return ret;
85
    if ((ret = kbc_issue_arg(cmd))) return ret;
86
    if ((ret = mouse_read_ack(&ack))) return ret;
87
    if (ack == ACK_OK) return SUCCESS;
88
    if (ack == ACK_ERROR) return INVALID_COMMAND;
89
    return OTHER_ERROR;
87 90
}
88 91

  
89 92
int (mouse_read_byte)(uint8_t *byte) {
......
101 104
    return TIMEOUT_ERROR;
102 105
}
103 106

  
107
int (mouse_read_ack)(uint8_t *byte) {
108
    int ret = 0;
109
    uint8_t stat;
110
    //for(int i = 0; i < KBC_NUM_TRIES; ++i){
111
        if((ret = util_sys_inb(STATUS_REG, &stat))) return ret;
112
        //if((stat&OUT_BUF_FUL) && (stat&AUX_MOUSE)) {
113
            if(stat & (PARITY_ERROR | TIME_OUT_REC)) return OTHER_ERROR;
114
            if((ret = util_sys_inb(OUTPUT_BUF, byte))) return ret;
115
            else return SUCCESS;
116
        //}
117
        //tickdelay(micros_to_ticks(DELAY));
118
    //}
119
    //return TIMEOUT_ERROR;
120
}
121

  
104 122
int16_t (sign_extend_byte)(uint8_t sign_bit, uint8_t byte) {
105 123
    return (int16_t)(((0xFF * sign_bit)<<8) | byte);
106 124
}

Also available in: Unified diff