root / lab3 / kbc_func.h @ 45
History | View | Annotate | Download (2.75 KB)
1 | 30 | up20180655 | #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 Whether operation was sucessful or not
|
||
14 | */
|
||
15 | int (subscribe_kbc_interrupt)(uint8_t interrupt_bit, int *interrupt_id); |
||
16 | |||
17 | /**
|
||
18 | 44 | up20180642 | * @brief Unsubcribes Interrupts
|
19 | * @param interrupt_id Interrupt ID, value via arguments on subscription of the interrupt_id
|
||
20 | * @see subscribe_kbc_interrupt, subscribe_timer_interrupt
|
||
21 | 30 | up20180655 | * @return Whether operation was sucessful or not
|
22 | */
|
||
23 | 44 | up20180642 | int (unsubscribe_interrupt)(int *interrupt_id); |
24 | 30 | up20180655 | |
25 | /**
|
||
26 | * @brief KBC Interrupt Handler
|
||
27 | */
|
||
28 | void (kbc_ih)(void); |
||
29 | |||
30 | /**
|
||
31 | 36 | up20180642 | * @brief High-level function that polls keyboard for scancode
|
32 | * High-level function that polls keyboard for scancode of up to 2 bytes. If
|
||
33 | * scancode has only 1 byte, the second byte is set to 0x00.
|
||
34 | * @param bytes Array of at least 2 bytes to store scancode
|
||
35 | * @param size Size of scancode in bytes
|
||
36 | * @return 0 if operation was successful, 1 otherwise
|
||
37 | */
|
||
38 | int (kbd_poll)(uint8_t bytes[], uint8_t *size);
|
||
39 | |||
40 | 39 | up20180642 | /**
|
41 | * @brief High-level function that reads the command byte of the KBC
|
||
42 | * @param cmd Pointer to variable where command byte read from KBC will be stored
|
||
43 | * @return 0 if operation was successful, 1 otherwise
|
||
44 | */
|
||
45 | int (kbc_read_cmd)(uint8_t *cmd);
|
||
46 | 38 | up20180642 | |
47 | 36 | up20180642 | /**
|
48 | 39 | up20180642 | * @brief High-level function that changes the command byte of the KBC
|
49 | * @param cmd New value for command byte of KBC
|
||
50 | * @return 0 if operation was successful, 1 otherwise
|
||
51 | */
|
||
52 | int (kbc_change_cmd)(uint8_t cmd);
|
||
53 | |||
54 | /**
|
||
55 | 43 | up20180642 | * @brief High-level function that restores KBC to normal state
|
56 | * High-level function that restores KBC to normal state, because lcf_start
|
||
57 | * changes the command byte of KBC. If this function is not used, there is a
|
||
58 | * chance that the keyboard and keyboard interrupts remain disabled.
|
||
59 | * @return 1 if operation was successful, 1 otherwise
|
||
60 | */
|
||
61 | int (kbc_restore_kbd)();
|
||
62 | |||
63 | /**
|
||
64 | 39 | up20180642 | * @brief Low-level function to issue a command to keyboard
|
65 | * @param cmd command to be issued
|
||
66 | * @return 0 if operation was successful, 1 otherwise
|
||
67 | */
|
||
68 | int (kbc_issue_cmd)(uint8_t cmd);
|
||
69 | |||
70 | /**
|
||
71 | 36 | up20180642 | * @brief Low-level function for reading byte from keyboard
|
72 | * Low-level function for reading byte from keyboard. Waits until output buffer
|
||
73 | * is full
|
||
74 | * @param value Pointer to variable where byte read from keyboard will be stored
|
||
75 | * @return 0 if operation was successful, 1 otherwise
|
||
76 | */
|
||
77 | 39 | up20180642 | int (kbc_read_byte)(uint8_t *byte);
|
78 | 36 | up20180642 | |
79 | 38 | up20180642 | |
80 | 30 | up20180655 | #endif |