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