Revision 265
message
lab3/kbc_func.h | ||
---|---|---|
1 |
#ifndef _KBC_FUNC_H_ |
|
2 |
#define _KBC_FUNC_H_ |
|
3 |
|
|
4 |
#include <stdint.h> |
|
5 |
|
|
6 |
#define GET 0 /* @brief Argument to get counter without incrementing */ |
|
7 |
#define INCREMENT 1 /* @brief Argument for incrementing counter */ |
|
8 |
|
|
9 |
/** |
|
10 |
* @brief Subscribes KBC Interrupts and disables Minix Default Keyboard IH |
|
11 |
* @param interrupt_bit Bit of Interrupt Vector that will be set when KBC Interrupt is pending |
|
12 |
* @param interrupt_id KBC Interrupt ID to specify the KBC Interrupt in other calls |
|
13 |
* @return ERROR_CODE code representing the result of the operation, SUCCESS code is returned if everything is OK |
|
14 |
* @see {_ERRORS_H_::errors} |
|
15 |
*/ |
|
16 |
int (subscribe_kbc_interrupt)(uint8_t interrupt_bit, int *interrupt_id); |
|
17 |
|
|
18 |
/** |
|
19 |
* @brief Subscribes Mouse Interrupts and disables Minix Default IH |
|
20 |
* @param interrupt_bit Bit of Interrupt Vector that will be set when Mouse Interrupt is pending |
|
21 |
* @param interrupt_id Mouse Interrupt ID to specify the Mouse Interrupt in other calls |
|
22 |
* @return ERROR_CODE code representing the result of the operation, SUCCESS code is returned if everything is OK |
|
23 |
* @see {_ERRORS_H_::errors} |
|
24 |
*/ |
|
25 |
int (subscribe_mouse_interrupt)(uint8_t interrupt_bit, int *interrupt_id); |
|
26 |
|
|
27 |
/** |
|
28 |
* @brief Unsubcribes Interrupts |
|
29 |
* @param interrupt_id Interrupt ID, value via arguments on subscription of the interrupt_id |
|
30 |
* @see subscribe_kbc_interrupt, subscribe_timer_interrupt |
|
31 |
* @return Whether operation was sucessful or not |
|
32 |
*/ |
|
33 |
int (unsubscribe_interrupt)(int *interrupt_id); |
|
34 |
|
|
35 |
/** |
|
36 |
* @brief KBC Interrupt Handler |
|
37 |
*/ |
|
38 |
void (kbc_ih)(void); |
|
39 |
|
|
40 |
/** |
|
41 |
* @brief High-level function that polls keyboard for scancode |
|
42 |
* High-level function that polls keyboard for scancode of up to 2 bytes. If |
|
43 |
* scancode has only 1 byte, the second byte is set to 0x00. |
|
44 |
* @param bytes Array of at least 2 bytes to store scancode |
|
45 |
* @param size Size of scancode in bytes |
|
46 |
* @return 0 if operation was successful, 1 otherwise |
|
47 |
*/ |
|
48 |
int (kbd_poll)(uint8_t bytes[], uint8_t *size); |
|
49 |
|
|
50 |
/** |
|
51 |
* @brief High-level function that reads the command byte of the KBC |
|
52 |
* @param cmd Pointer to variable where command byte read from KBC will be stored |
|
53 |
* @return 0 if operation was successful, 1 otherwise |
|
54 |
*/ |
|
55 |
int (kbc_read_cmd)(uint8_t *cmd); |
|
56 |
|
|
57 |
/** |
|
58 |
* @brief High-level function that changes the command byte of the KBC |
|
59 |
* @param cmd New value for command byte of KBC |
|
60 |
* @return 0 if operation was successful, 1 otherwise |
|
61 |
*/ |
|
62 |
int (kbc_change_cmd)(uint8_t cmd); |
|
63 |
|
|
64 |
/** |
|
65 |
* @brief High-level function that restores KBC to normal state |
|
66 |
* High-level function that restores KBC to normal state, because lcf_start |
|
67 |
* changes the command byte of KBC. If this function is not used, there is a |
|
68 |
* chance that the keyboard and keyboard interrupts remain disabled. |
|
69 |
* @return 1 if operation was successful, 1 otherwise |
|
70 |
*/ |
|
71 |
int (kbc_restore_kbd)(); |
|
72 |
|
|
73 |
/** |
|
74 |
* @brief Low-level function to issue a command to keyboard |
|
75 |
* @param cmd command to be issued |
|
76 |
* @return 0 if operation was successful, 1 otherwise |
|
77 |
*/ |
|
78 |
int (kbc_issue_cmd)(uint8_t cmd); |
|
79 |
|
|
80 |
/** |
|
81 |
* @brief Low-level function to issue an argument of a command |
|
82 |
* @param cmd argument to be issued |
|
83 |
* @return 0 if operation was successful, 1 otherwise |
|
84 |
*/ |
|
85 |
int (kbc_issue_arg)(uint8_t arg); |
|
86 |
|
|
87 |
/** |
|
88 |
* @brief Low-level function for reading byte from keyboard |
|
89 |
* Low-level function for reading byte from keyboard. Waits until output buffer |
|
90 |
* is full |
|
91 |
* @param value Pointer to variable where byte read from keyboard will be stored |
|
92 |
* @return 0 if operation was successful, 1 otherwise |
|
93 |
*/ |
|
94 |
int (kbc_read_byte)(uint8_t *byte); |
|
95 |
|
|
96 |
|
|
97 |
#endif |
|
0 | 98 |
Also available in: Unified diff