Project

General

Profile

Statistics
| Revision:

root / lab4 / mouse.h @ 80

History | View | Annotate | Download (2.42 KB)

1
#ifndef MOUSE_H_INCLUDED
2
#define MOUSE_H_INCLUDED
3

    
4
#include <stdint.h>
5

    
6
/**
7
 * @brief Subscribes Mouse Interrupts and disables Minix Default IH
8
 * @param interrupt_bit Bit of Interrupt Vector that will be set when Mouse Interrupt is pending
9
 * @param interrupt_id Mouse Interrupt ID to specify the Mouse Interrupt in other calls
10
 * @return ERROR_CODE code representing the result of the operation, SUCCESS code is returned if everything is OK
11
 * @see {_ERRORS_H_::errors}
12
 */
13
int (subscribe_mouse_interrupt)(uint8_t interrupt_bit, int *interrupt_id);
14

    
15
int got_error_mouse_ih;
16
uint8_t packet_mouse_ih[3];
17
int counter_mouse_ih;
18

    
19
struct packet (mouse_parse_packet)(const uint8_t *packet_bytes);
20

    
21
int mouse_poll(struct packet *pp, uint16_t period);
22

    
23
/**
24
 *
25
 */
26
int (mouse_set_data_report)(int on);
27

    
28
/**
29
 * @brief Reads data byte from mouse
30
 * <summary>
31
 * Polls the mouse till data is available for reading
32
 * </summary>
33
 * @param data Pointer to variable where byte read from mouse will be stored
34
 * @return ERROR_CODE code representing the result of the operation, SUCCESS code is returned if everything is OK
35
 * @see {_ERRORS_H_::errors}
36
 */
37
int (mouse_read_data)(uint8_t *data, uint16_t period);
38

    
39
/**
40
 * @brief Issues command to mouse
41
 * <summary>
42
 * Issues command to mouse, returns error after two consecutive errors reported by the acknowledgment byte
43
 * </summary>
44
 * @param cmd Command to be issued
45
 * @return ERROR_CODE code representing the result of the operation, SUCCESS code is returned if everything is OK
46
 * @see {_ERRORS_H_::errors}
47
 */
48
int (mouse_issue_cmd)(uint32_t cmd);
49

    
50
/**
51
 * @brief Reads byte from mouse
52
 * <summary>
53
 * Reads byte from mouse, giving error if exceeds number of tries to read
54
 * </summary>
55
 * @param byte Pointer to variable where byte read from mouse will be stored
56
 * @return ERROR_CODE code representing the result of the operation, SUCCESS code is returned if everything is OK
57
 * @see {_ERRORS_H_::errors}
58
 */
59
int (mouse_read_byte)(uint8_t *byte);
60

    
61
int (mouse_read_ack)(uint8_t *byte);
62

    
63
int (mouse_poll_byte)(uint8_t *byte, uint16_t period);
64

    
65
/**
66
 * @brief Converts 9-bit number to 16-bit with sign extension
67
 * @param sign_bit  Sign bit identifiying the signal of the number
68
 * @param byte      Least significant byte that will be extended
69
 * @return Extended 9-bit number
70
 */
71
int16_t (sign_extend_byte)(uint8_t sign_bit, uint8_t byte);
72

    
73
#endif //MOUSE_H_INCLUDED