root / lab4 / mouse.h @ 265
History | View | Annotate | Download (3.51 KB)
1 | 68 | up20180642 | #ifndef MOUSE_H_INCLUDED
|
---|---|---|---|
2 | #define MOUSE_H_INCLUDED
|
||
3 | 53 | up20180655 | |
4 | 58 | up20180642 | #include <stdint.h> |
5 | 53 | up20180655 | |
6 | 58 | up20180642 | /**
|
7 | * @brief Subscribes Mouse Interrupts and disables Minix Default IH
|
||
8 | * @param interrupt_bit Bit of Interrupt Vector that will be set when Mouse Interrupt is pending
|
||
9 | * @param interrupt_id Mouse Interrupt ID to specify the Mouse Interrupt in other calls
|
||
10 | * @return ERROR_CODE code representing the result of the operation, SUCCESS code is returned if everything is OK
|
||
11 | * @see {_ERRORS_H_::errors}
|
||
12 | */
|
||
13 | int (subscribe_mouse_interrupt)(uint8_t interrupt_bit, int *interrupt_id); |
||
14 | 53 | up20180655 | |
15 | 81 | up20180642 | //These have to do with mouse_ih
|
16 | 80 | up20180642 | int got_error_mouse_ih;
|
17 | uint8_t packet_mouse_ih[3];
|
||
18 | int counter_mouse_ih;
|
||
19 | |||
20 | 81 | up20180642 | /**
|
21 | * @brief Parse 3 bytes and returns it as a parsed, struct packet.
|
||
22 | * @param packet_bytes array of bytes to parse
|
||
23 | * @return parsed struct packet
|
||
24 | */
|
||
25 | 58 | up20180642 | struct packet (mouse_parse_packet)(const uint8_t *packet_bytes); |
26 | 53 | up20180655 | |
27 | 81 | up20180642 | /**
|
28 | * @brief Polls mouse for data. Blocks execution until a valid mouse packet is obtained.
|
||
29 | * @param pp pointer to packet struct in which the result will be stored
|
||
30 | * @param period time (in milliseconds) the poller should wait between pollings of bytes
|
||
31 | * @return ERROR_CODE code representing the result of the operation, SUCCESS code is returned if everything is OK
|
||
32 | */
|
||
33 | 80 | up20180642 | int mouse_poll(struct packet *pp, uint16_t period); |
34 | |||
35 | /**
|
||
36 | 81 | up20180642 | * @brief Sets data report mode for mouse
|
37 | * @param on zero to disable data report, any other value to enable data report
|
||
38 | * @return ERROR_CODE code representing the result of the operation, SUCCESS code is returned if everything is OK
|
||
39 | 80 | up20180642 | */
|
40 | 58 | up20180642 | int (mouse_set_data_report)(int on); |
41 | |||
42 | 70 | up20180655 | /**
|
43 | * @brief Reads data byte from mouse
|
||
44 | * <summary>
|
||
45 | * Polls the mouse till data is available for reading
|
||
46 | * </summary>
|
||
47 | * @param data Pointer to variable where byte read from mouse will be stored
|
||
48 | * @return ERROR_CODE code representing the result of the operation, SUCCESS code is returned if everything is OK
|
||
49 | * @see {_ERRORS_H_::errors}
|
||
50 | */
|
||
51 | 80 | up20180642 | int (mouse_read_data)(uint8_t *data, uint16_t period);
|
52 | 70 | up20180655 | |
53 | /**
|
||
54 | * @brief Issues command to mouse
|
||
55 | * <summary>
|
||
56 | * Issues command to mouse, returns error after two consecutive errors reported by the acknowledgment byte
|
||
57 | * </summary>
|
||
58 | * @param cmd Command to be issued
|
||
59 | * @return ERROR_CODE code representing the result of the operation, SUCCESS code is returned if everything is OK
|
||
60 | * @see {_ERRORS_H_::errors}
|
||
61 | */
|
||
62 | int (mouse_issue_cmd)(uint32_t cmd);
|
||
63 | |||
64 | /**
|
||
65 | * @brief Reads byte from mouse
|
||
66 | * <summary>
|
||
67 | * Reads byte from mouse, giving error if exceeds number of tries to read
|
||
68 | 71 | up20180655 | * </summary>
|
69 | 70 | up20180655 | * @param byte Pointer to variable where byte read from mouse will be stored
|
70 | * @return ERROR_CODE code representing the result of the operation, SUCCESS code is returned if everything is OK
|
||
71 | * @see {_ERRORS_H_::errors}
|
||
72 | */
|
||
73 | int (mouse_read_byte)(uint8_t *byte);
|
||
74 | |||
75 | 81 | up20180642 | /**
|
76 | * @brief Polls OUT_BUF for byte coming from mouse.
|
||
77 | * @param byte pointer to byte read from OUT_BUF
|
||
78 | * @param period time (in milliseconds) the poller should wait between pollings of bytes
|
||
79 | * @return ERROR_CODE code representing the result of the operation, SUCCESS code is returned if everything is OK
|
||
80 | */
|
||
81 | 80 | up20180642 | int (mouse_poll_byte)(uint8_t *byte, uint16_t period);
|
82 | |||
83 | 71 | up20180655 | /**
|
84 | * @brief Converts 9-bit number to 16-bit with sign extension
|
||
85 | * @param sign_bit Sign bit identifiying the signal of the number
|
||
86 | * @param byte Least significant byte that will be extended
|
||
87 | * @return Extended 9-bit number
|
||
88 | */
|
||
89 | int16_t (sign_extend_byte)(uint8_t sign_bit, uint8_t byte); |
||
90 | |||
91 | 68 | up20180642 | #endif //MOUSE_H_INCLUDED |