Revision 57
working
lab4/Makefile | ||
---|---|---|
2 | 2 |
PROG=lab4 |
3 | 3 |
|
4 | 4 |
# source code files to be compiled |
5 |
SRCS = lab4.c mouse_func.c utils.c |
|
5 |
SRCS = lab4.c mouse_func.c utils.c kbc_func.c
|
|
6 | 6 |
|
7 | 7 |
# additional compilation flags |
8 | 8 |
# "-Wall -Wextra -Werror -I . -std=c11 -Wno-unused-parameter" are already set |
lab4/lab4.c | ||
---|---|---|
4 | 4 |
#include <stdio.h> |
5 | 5 |
|
6 | 6 |
#include "mouse_func.h" |
7 |
#include "kbc_func.h" |
|
7 | 8 |
|
8 | 9 |
int main(int argc, char *argv[]) { |
9 | 10 |
// sets the language of LCF messages (can be either EN-US or PT-PT) |
... | ... | |
80 | 81 |
} |
81 | 82 |
|
82 | 83 |
if (unsubscribe_interrupt(&mouse_id)) return 1; |
84 |
if(kbc_restore_kbd()) return 1; |
|
83 | 85 |
|
84 | 86 |
return 0; |
85 | 87 |
} |
lab4/mouse_func.c | ||
---|---|---|
12 | 12 |
return SUCCESS; |
13 | 13 |
} |
14 | 14 |
|
15 |
int (unsubscribe_interrupt)(int *interrupt_id) { |
|
16 |
if (interrupt_id == NULL) return NULL_PTR; |
|
17 |
if (sys_irqrmpolicy(interrupt_id)) return UNSBCR_ERROR; |
|
18 |
return SUCCESS; |
|
19 |
} |
|
20 |
|
|
21 |
int got_error = 0; |
|
15 |
int got_error_mouse_ih = 0; |
|
22 | 16 |
uint8_t packet[3]; |
23 | 17 |
int counter = 0; |
24 | 18 |
|
25 | 19 |
void (mouse_ih)(void) { |
26 | 20 |
uint8_t status = 0; |
27 |
got_error = 0; |
|
21 |
got_error_mouse_ih = 0;
|
|
28 | 22 |
|
29 | 23 |
if (util_sys_inb(STATUS_REG, &status)) { |
30 |
got_error = 1; |
|
24 |
got_error_mouse_ih = 1;
|
|
31 | 25 |
return; |
32 | 26 |
} |
33 | 27 |
|
34 | 28 |
if (status & (TIME_OUT_REC | PARITY_ERROR)) { |
35 |
got_error = 1; |
|
29 |
got_error_mouse_ih = 1;
|
|
36 | 30 |
return; |
37 | 31 |
} |
38 | 32 |
|
39 | 33 |
uint8_t byte = 0; |
40 | 34 |
|
41 | 35 |
if (util_sys_inb(OUTPUT_BUF, &byte)) { |
42 |
got_error = 1; |
|
36 |
got_error_mouse_ih = 1;
|
|
43 | 37 |
return; |
44 | 38 |
} |
45 | 39 |
|
... | ... | |
57 | 51 |
pp.rb = pp.bytes[0] & RIGHT_BUTTON; |
58 | 52 |
pp.mb = pp.bytes[0] & MIDDLE_BUTTON; |
59 | 53 |
pp.lb = pp.bytes[0] & LEFT_BUTTON; |
60 |
//pp.delta_x = |
|
54 |
pp.delta_x = pp.bytes[1]; |
|
55 |
pp.delta_y = pp.bytes[2]; |
|
56 |
pp.x_ov = pp.bytes[0] & X_OVERFLOW; |
|
57 |
pp.y_ov = pp.bytes[0] & Y_OVERFLOW; |
|
61 | 58 |
return pp; |
62 | 59 |
} |
lab4/mouse_func.h | ||
---|---|---|
12 | 12 |
*/ |
13 | 13 |
int (subscribe_mouse_interrupt)(uint8_t interrupt_bit, int *interrupt_id); |
14 | 14 |
|
15 |
/** |
|
16 |
* @brief Unsubcribes Interrupts |
|
17 |
* @param interrupt_id Interrupt ID, value via arguments on subscription of the interrupt_id |
|
18 |
* @see subscribe_kbc_interrupt, subscribe_timer_interrupt |
|
19 |
* @return ERROR_CODE code representing the result of the operation, SUCCESS code is returned if everything is OK |
|
20 |
* @see {_ERRORS_H_::errors} |
|
21 |
*/ |
|
22 |
int (unsubscribe_interrupt)(int *interrupt_id); |
|
23 |
|
|
24 | 15 |
struct packet (mouse_parse_packet)(const uint8_t *packet_bytes); |
25 | 16 |
|
26 | 17 |
#endif /* end of include guard: _MOUSE_FUNC_H_ */ |
Also available in: Unified diff