Project

General

Profile

Revision 87

fixed stuff

View differences:

lab4.c
44 44
    uint8_t mouse_irq_bit = 12;
45 45
    int mouse_id = 0;
46 46
    int mouse_irq = BIT(mouse_irq_bit);
47
    if ((ret = mouse_set_data_report(true))) return ret;
48
    //if ((ret = mouse_enable_data_reporting())) return ret;
49 47

  
50
    if (subscribe_mouse_interrupt(mouse_irq_bit, &mouse_id)) return 1;
48
    if (subscribe_mouse_interrupt(mouse_irq_bit, &mouse_id)) return 1; // subscribes mouse interrupts in exclusive mode
49
    if (sys_irqdisable(&mouse_id)) return 1; // temporarily disables our interrupts notifications
50
    if ((ret = mouse_set_data_report(true))) return ret; // enables mouse data reporting
51
    if (sys_irqenable(&mouse_id)) return 1; // re-enables our interrupts notifications
52

  
51 53
    /// cycle
52
    int good = cnt != 0;
54
    int good = (cnt != 0);
53 55
    uint32_t cnt_now = 0;
54 56
    while (good) {
55 57
        /* Get a request message. */
......
77 79
            /* no standart message expected: do nothing */
78 80
        }
79 81
    }
80
    if (unsubscribe_interrupt(&mouse_id)) return 1;
81
    if (mouse_set_data_report(false)) return 1;
82
    if (sys_irqdisable(&mouse_id)) return 1; // temporarily disables our interrupts notifications
83
    if (mouse_set_data_report(false)) return 1; // enables mouse data reporting
84
    if (sys_irqenable(&mouse_id)) return 1; // re-enables our interrupts notifications
85
    if (unsubscribe_interrupt(&mouse_id)) return 1; // unsubscribes interrupts
82 86
    return 0;
83 87
}
84 88

  
......
93 97
        mouse_print_packet(&pp);
94 98
        tickdelay(micros_to_ticks(period*1000));
95 99
    }
96
    /*
97
    while (good) {
98

  
99
        if ((ret = mouse_read_data(&data))) return ret;
100

  
101
        if ((data & FIRST_BYTE_ID) || sz) {
102
            packet[sz] = data;
103
            sz++;
104
        }
105
        if (sz == 3) {
106
            struct packet pp = mouse_parse_packet(packet);
107
            mouse_print_packet(&pp);
108
            packetCounter++;
109
            sz = 0;
110
            if (packetCounter == cnt) good = 0;
111
        }
112
        tickdelay(micros_to_ticks(period*1e3));
113
    }
114
    */
115 100
    // Set Stream mode
116 101
    if ((ret = mouse_issue_cmd(SET_STREAM_MD))) return ret;
117 102
    // Disable data reporting
......
139 124
    uint8_t mouse_irq_bit = 12;
140 125
    int mouse_id = 0;
141 126
    int mouse_irq = BIT(mouse_irq_bit);
142
    if (mouse_set_data_report(true)) return 1;
143 127

  
144
    if (subscribe_mouse_interrupt(mouse_irq_bit, &mouse_id)) return 1;
128
    if (subscribe_mouse_interrupt(mouse_irq_bit, &mouse_id)) return 1; // subscribes mouse interrupts in exclusive mode
129
    if (sys_irqdisable(&mouse_id)) return 1; // temporarily disables our interrupts notifications
130
    if (mouse_set_data_report(true)) return 1; // enables mouse data reporting
131
    if (sys_irqenable(&mouse_id)) return 1; // re-enables our interrupts notifications
132

  
145 133
    /// cycle
146 134
    int good = 1;
147 135
    while (good) {
......
176 164
        }
177 165
    }
178 166

  
179
    if (unsubscribe_interrupt(&mouse_id)) return 1;
180
    if (mouse_set_data_report(false)) return 1;
167
    if (sys_irqdisable(&mouse_id)) return 1; // temporarily disables our interrupts notifications
168
    if (mouse_set_data_report(false)) return 1; // enables mouse data reporting
169
    if (sys_irqenable(&mouse_id)) return 1; // re-enables our interrupts notifications
170
    if (unsubscribe_interrupt(&mouse_id)) return 1; // unsubscribes interrupts
181 171

  
182 172
    if (unsubscribe_interrupt(&timer_id)) return 1;
183 173

  
......
193 183
    uint8_t mouse_irq_bit = 12;
194 184
    int mouse_id = 0;
195 185
    int mouse_irq = BIT(mouse_irq_bit);
196
    if ((ret = mouse_set_data_report(true))) return ret;
197 186

  
198
    if (subscribe_mouse_interrupt(mouse_irq_bit, &mouse_id)) return 1;
187
    if (subscribe_mouse_interrupt(mouse_irq_bit, &mouse_id)) return 1; // subscribes mouse interrupts in exclusive mode
188
    if (sys_irqdisable(&mouse_id)) return 1; // temporarily disables our interrupts notifications
189
    if ((ret = mouse_set_data_report(true))) return ret; // enables mouse data reporting
190
    if (sys_irqenable(&mouse_id)) return 1; // re-enables our interrupts notifications
191

  
199 192
    /// cycle
200 193
    int good = 1;
201 194

  
......
235 228
            /* no standart message expected: do nothing */
236 229
        }
237 230
    }
238
    if (unsubscribe_interrupt(&mouse_id)) return 1;
239
    if (mouse_set_data_report(false)) return 1;
240 231

  
232
    if (sys_irqdisable(&mouse_id)) return 1; // temporarily disables our interrupts notifications
233
    if (mouse_set_data_report(false)) return 1; // enables mouse data reporting
234
    if (sys_irqenable(&mouse_id)) return 1; // re-enables our interrupts notifications
235
    if (unsubscribe_interrupt(&mouse_id)) return 1; // unsubscribes interrupts
236

  
241 237
    return 0;
242 238
}

Also available in: Unified diff