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