root / proj / libs / kbc / include / mouse.h @ 333
History | View | Annotate | Download (3.63 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 (mouse_get_got_error_mouse_ih)(void); |
15 |
const uint8_t* (mouse_get_packet_mouse_ih)(void); |
16 |
int (mouse_get_counter_mouse_ih)(void); |
17 |
void (mouse_set_counter_mouse_ih)(int n); |
18 |
|
19 |
/**
|
20 |
* @brief Parse 3 bytes and returns it as a parsed, struct packet.
|
21 |
* @param packet_bytes array of bytes to parse
|
22 |
* @param pp Pointer to packet to store the information.
|
23 |
*/
|
24 |
void (mouse_parse_packet)(const uint8_t *packet_bytes, struct packet *pp); |
25 |
|
26 |
/**
|
27 |
* @brief Polls mouse for data. Blocks execution until a valid mouse packet is obtained.
|
28 |
* @param pp pointer to packet struct in which the result will be stored
|
29 |
* @param period time (in milliseconds) the poller should wait between pollings of bytes
|
30 |
* @return ERROR_CODE code representing the result of the operation, SUCCESS code is returned if everything is OK
|
31 |
*/
|
32 |
int mouse_poll(struct packet *pp, uint16_t period); |
33 |
|
34 |
/**
|
35 |
* @brief Sets data report mode for mouse
|
36 |
* @param on zero to disable data report, any other value to enable data report
|
37 |
* @return ERROR_CODE code representing the result of the operation, SUCCESS code is returned if everything is OK
|
38 |
*/
|
39 |
int (mouse_set_data_report)(int on); |
40 |
|
41 |
/**
|
42 |
* @brief Reads data byte from mouse
|
43 |
* <summary>
|
44 |
* Polls the mouse till data is available for reading
|
45 |
* </summary>
|
46 |
* @param data Pointer to variable where byte read from mouse will be stored
|
47 |
* @return ERROR_CODE code representing the result of the operation, SUCCESS code is returned if everything is OK
|
48 |
* @see {_ERRORS_H_::errors}
|
49 |
*/
|
50 |
int (mouse_read_data)(uint8_t *data, uint16_t period);
|
51 |
|
52 |
/**
|
53 |
* @brief Issues command to mouse
|
54 |
* <summary>
|
55 |
* Issues command to mouse, returns error after two consecutive errors reported by the acknowledgment byte
|
56 |
* </summary>
|
57 |
* @param cmd Command to be issued
|
58 |
* @return ERROR_CODE code representing the result of the operation, SUCCESS code is returned if everything is OK
|
59 |
* @see {_ERRORS_H_::errors}
|
60 |
*/
|
61 |
int (mouse_issue_cmd)(uint8_t cmd);
|
62 |
|
63 |
/**
|
64 |
* @brief Reads byte from mouse
|
65 |
* <summary>
|
66 |
* Reads byte from mouse, giving error if exceeds number of tries to read
|
67 |
* </summary>
|
68 |
* @param byte Pointer to variable where byte read from mouse will be stored
|
69 |
* @return ERROR_CODE code representing the result of the operation, SUCCESS code is returned if everything is OK
|
70 |
* @see {_ERRORS_H_::errors}
|
71 |
*/
|
72 |
int (mouse_read_byte)(uint8_t *byte);
|
73 |
|
74 |
/**
|
75 |
* @brief Polls OUT_BUF for byte coming from mouse.
|
76 |
* @param byte pointer to byte read from OUT_BUF
|
77 |
* @param period time (in milliseconds) the poller should wait between pollings of bytes
|
78 |
* @return ERROR_CODE code representing the result of the operation, SUCCESS code is returned if everything is OK
|
79 |
*/
|
80 |
int (mouse_poll_byte)(uint8_t *byte, uint16_t period);
|
81 |
|
82 |
/**
|
83 |
* @brief Converts 9-bit number to 16-bit with sign extension
|
84 |
* @param sign_bit Sign bit identifiying the signal of the number
|
85 |
* @param byte Least significant byte that will be extended
|
86 |
* @return Extended 9-bit number
|
87 |
*/
|
88 |
int16_t (sign_extend_byte)(uint8_t sign_bit, uint8_t byte); |
89 |
|
90 |
#endif //MOUSE_H_INCLUDED |