Project

General

Profile

Statistics
| Revision:

root / proj / libs / kbc / include / mouse.h @ 344

History | View | Annotate | Download (4.19 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 339 up20180642
/**
23
 * @brief Get previous mouse interrupt handler call exit code.
24
 * @return  Exit code of previous mouse IH call
25
 */
26 322 up20180642
int (mouse_get_got_error_mouse_ih)(void);
27 339 up20180642
/**
28
 * @brief Get mouse packet.
29
 * @return  Pointer to mouse packet
30
 */
31 322 up20180642
const uint8_t* (mouse_get_packet_mouse_ih)(void);
32 339 up20180642
/**
33
 * @brief Number of mouse bytes received (0 to 3).
34
 * @return  Number of bytes
35
 */
36 322 up20180642
int (mouse_get_counter_mouse_ih)(void);
37 339 up20180642
/**
38
 * @brief Set number of received mouse bytes.
39
 *
40
 * Usually this function is used to reset counter_mouse_ih.
41
 * @param   n   New value of the counter
42
 */
43 323 up20180642
void (mouse_set_counter_mouse_ih)(int n);
44 322 up20180642
45 150 up20180655
/**
46
 * @brief   Parse 3 bytes and returns it as a parsed, struct packet.
47
 * @param   packet_bytes    array of bytes to parse
48 250 up20180655
 * @param   pp              Pointer to packet to store the information.
49 150 up20180655
 */
50 250 up20180655
void (mouse_parse_packet)(const uint8_t *packet_bytes, struct packet *pp);
51 150 up20180655
52
/**
53
 * @brief Polls mouse for data. Blocks execution until a valid mouse packet is obtained.
54
 * @param   pp      pointer to packet struct in which the result will be stored
55
 * @param   period  time (in milliseconds) the poller should wait between pollings of bytes
56
 * @return ERROR_CODE code representing the result of the operation, SUCCESS code is returned if everything is OK
57
 */
58
int mouse_poll(struct packet *pp, uint16_t period);
59
60
/**
61
 * @brief Sets data report mode for mouse
62
 * @param   on  zero to disable data report, any other value to enable data report
63
 * @return  ERROR_CODE code representing the result of the operation, SUCCESS code is returned if everything is OK
64
 */
65
int (mouse_set_data_report)(int on);
66
67
/**
68
 * @brief Reads data byte from mouse
69
 * <summary>
70
 * Polls the mouse till data is available for reading
71
 * </summary>
72
 * @param data Pointer to variable where byte read from mouse will be stored
73
 * @return ERROR_CODE code representing the result of the operation, SUCCESS code is returned if everything is OK
74
 * @see {_ERRORS_H_::errors}
75
 */
76
int (mouse_read_data)(uint8_t *data, uint16_t period);
77
78
/**
79
 * @brief Issues command to mouse
80
 * <summary>
81
 * Issues command to mouse, returns error after two consecutive errors reported by the acknowledgment byte
82
 * </summary>
83
 * @param cmd Command to be issued
84
 * @return ERROR_CODE code representing the result of the operation, SUCCESS code is returned if everything is OK
85
 * @see {_ERRORS_H_::errors}
86
 */
87 323 up20180642
int (mouse_issue_cmd)(uint8_t cmd);
88 150 up20180655
89
/**
90
 * @brief Reads byte from mouse
91
 * <summary>
92
 * Reads byte from mouse, giving error if exceeds number of tries to read
93
 * </summary>
94
 * @param byte Pointer to variable where byte read from mouse will be stored
95
 * @return ERROR_CODE code representing the result of the operation, SUCCESS code is returned if everything is OK
96
 * @see {_ERRORS_H_::errors}
97
 */
98
int (mouse_read_byte)(uint8_t *byte);
99
100
/**
101
 * @brief Polls OUT_BUF for byte coming from mouse.
102
 * @param   byte    pointer to byte read from OUT_BUF
103
 * @param   period  time (in milliseconds) the poller should wait between pollings of bytes
104
 * @return ERROR_CODE code representing the result of the operation, SUCCESS code is returned if everything is OK
105
 */
106
int (mouse_poll_byte)(uint8_t *byte, uint16_t period);
107
108
/**
109
 * @brief Converts 9-bit number to 16-bit with sign extension
110
 * @param sign_bit  Sign bit identifiying the signal of the number
111
 * @param byte      Least significant byte that will be extended
112
 * @return Extended 9-bit number
113
 */
114
int16_t (sign_extend_byte)(uint8_t sign_bit, uint8_t byte);
115
116 334 up20180642
/**
117
 * @}
118
 */
119
120 150 up20180655
#endif //MOUSE_H_INCLUDED