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