Project

General

Profile

Revision 334

added more docs

View differences:

kbc.h
1
#ifndef KBC_H_INCLUDED
2
#define KBC_H_INCLUDED
3

  
1 4
/**
2
 * This file concerns everything related to the KBC (KeyBoard Controller, which
3
 * actually also manages the mouse)
5
 * @defgroup    kbc kbc
6
 * @brief   KBC module.
7
 *
8
 * @{
4 9
 */
5 10

  
6
#ifndef KBC_H_INCLUDED
7
#define KBC_H_INCLUDED
8

  
9 11
/* KBC IRQ Line */
12
/** @brief KBC Controller IRQ Line */
13
#define KBC_IRQ     1
14
/** @brief Mouse IRQ Line */
15
#define MOUSE_IRQ   12
10 16

  
11
#define KBC_IRQ     1   /* @brief KBC Controller IRQ Line */
12
#define MOUSE_IRQ   12  /* @brief Mouse IRQ Line */
13

  
14 17
/* Delay for KBC */
15
#define DELAY           20000 /* @brief KBC Response Delay */
16
#define KBC_NUM_TRIES   20    /* @brief Number of tries to issue command before timeout */
18
/** @brief KBC Response Delay */
19
#define DELAY           20000
20
/** @brief Number of tries to issue command before timeout */
21
#define KBC_NUM_TRIES   20
17 22

  
18 23
/* I/O Ports Addresses */
24
/** @brief Address to send commands to KBC */
25
#define KBC_CMD     0x64
26
/** @brief Address to write KBC Command Arguments */
27
#define KBC_CMD_ARG 0x60
28
/** @brief KBC Status Register address */
29
#define STATUS_REG  0x64
30
/** @brief Address of Output Buffer of KBC */
31
#define OUTPUT_BUF  0x60
19 32

  
20
#define KBC_CMD     0x64 /* @brief Address to send commands to KBC */
21
#define KBC_CMD_ARG 0x60 /* @brief Address to write KBC Command Arguments */
22
#define STATUS_REG  0x64 /* @brief KBC Status Register address */
23

  
24
#define OUTPUT_BUF  0x60 /* @brief Address of Output Buffer of KBC */
25

  
26 33
/* KBC Commands */
27
#define READ_KBC_CMD    0x20 /* @brief Read KBC Command Byte */
28
#define WRITE_KBC_CMD   0x60 /* @brief Write KBC Command Byte */
29
#define KBC_SELF_TEST   0xAA /* @brief KBC Diagnostic Tests */
30
#define KBC_INT_TEST    0xAB /* @brief Tests Keyboard Clock and Data lines */
31
#define KBC_INT_DISABLE 0xAD /* @brief Disable KBC Interface */
32
#define KBC_INT_ENABLE  0xAE /* @brief Enable KBC Interface */
33
#define MOUSE_DISABLE   0xA7 /* @brief Disable Mouse */
34
#define MOUSE_ENABLE    0xA8 /* @brief Enable Mouse */
35
#define MOUSE_INT_TEST  0xA9 /* @brief Tests Mouse data line */
36
#define MOUSE_WRITE_B   0xD4 /* @brief Write a byte directly to the mouse */
34
/** @brief Read KBC Command Byte */
35
#define READ_KBC_CMD    0x20
36
/** @brief Write KBC Command Byte */
37
#define WRITE_KBC_CMD   0x60
38
/** @brief KBC Diagnostic Tests */
39
#define KBC_SELF_TEST   0xAA
40
/** @brief Tests Keyboard Clock and Data lines */
41
#define KBC_INT_TEST    0xAB
42
/** @brief Disable KBC Interface */
43
#define KBC_INT_DISABLE 0xAD
44
/** @brief Enable KBC Interface */
45
#define KBC_INT_ENABLE  0xAE
46
/** @brief Disable Mouse */
47
#define MOUSE_DISABLE   0xA7
48
/** @brief Enable Mouse */
49
#define MOUSE_ENABLE    0xA8
50
/** @brief Tests Mouse data line */
51
#define MOUSE_INT_TEST  0xA9
52
/** @brief Write a byte directly to the mouse */
53
#define MOUSE_WRITE_B   0xD4
37 54

  
38 55
/* Status Byte Masking */
56
/** @brief Output Buffer State */
57
#define OUT_BUF_FUL     BIT(0)
58
/** @brief Input Buffer State */
59
#define IN_BUF_FULL     BIT(1)
60
/** @brief System Flag */
61
#define SYS_FLAG        BIT(2)
62
/** @brief Identifier of type of byte in input buffer */
63
#define DATA_CMD_WRITE  BIT(3)
64
/** @brief Keyboard inihibited */
65
#define INH_FLAG        BIT(4)
66
/** @brief Mouse Data */
67
#define AUX_MOUSE       BIT(5)
68
/** @brief Time Out Error - Invalid Data */
69
#define TIME_OUT_REC    BIT(6)
70
/** @brief Parity Error - Invalid Data */
71
#define PARITY_ERROR    BIT(7)
39 72

  
40
#define OUT_BUF_FUL     BIT(0) /* @brief Output Buffer State */
41
#define IN_BUF_FULL     BIT(1) /* @brief Input Buffer State */
42
#define SYS_FLAG        BIT(2) /* @brief System Flag */
43
#define DATA_CMD_WRITE  BIT(3) /* @brief Identifier of type of byte in input buffer */
44
#define INH_FLAG        BIT(4) /* @brief Keyboard inihibited */
45
#define AUX_MOUSE       BIT(5) /* @brief Mouse Data */
46
#define TIME_OUT_REC    BIT(6) /* @brief Time Out Error - Invalid Data */
47
#define PARITY_ERROR    BIT(7) /* @brief Parity Error - Invalid Data */
48

  
49 73
/* Scancode Constants */
74
/** @brief ESC Break Code */
75
#define ESC_BREAK_CODE  0x81
76
/** @brief First byte of a two byte Scancode */
77
#define TWO_BYTE_CODE   0xE0
78
/** @brief Bit to distinguish between Make code and Break code */
79
#define BREAK_CODE_BIT  BIT(7)
50 80

  
51
#define ESC_BREAK_CODE  0x81    /* @brief ESC Break Code */
52
#define TWO_BYTE_CODE   0xE0    /* @brief First byte of a two byte Scancode */
53
#define BREAK_CODE_BIT  BIT(7)  /* @brief Bit to distinguish between Make code and Break code */
54

  
55 81
/* Command byte masks */
56
#define INT_KBD         BIT(0)  /* @brief Enable Keyboard Interrupts */
57
#define INT_MOU         BIT(1)  /* @brief Enable Mouse Interrupts */
58
#define DIS_KBD         BIT(4)  /* @brief Disable Keyboard */
59
#define DIS_MOU         BIT(5)  /* @brief Disable Mouse */
82
/** @brief Enable Keyboard Interrupts */
83
#define INT_KBD         BIT(0)
84
/** @brief Enable Mouse Interrupts */
85
#define INT_MOU         BIT(1)
86
/** @brief Disable Keyboard */
87
#define DIS_KBD         BIT(4)
88
/** @brief Disable Mouse */
89
#define DIS_MOU         BIT(5)
60 90

  
61 91
/**
62 92
 * @brief High-level function that reads the command byte of the KBC
......
74 104

  
75 105
/**
76 106
 * @brief High-level function that restores KBC to normal state
107
 *
77 108
 * High-level function that restores KBC to normal state, because lcf_start
78 109
 * changes the command byte of KBC. If this function is not used, there is a
79 110
 * chance that the keyboard and keyboard interrupts remain disabled.
......
97 128

  
98 129
/**
99 130
 * @brief Low-level function for reading byte from keyboard
131
 *
100 132
 * Low-level function for reading byte from keyboard. Waits until output buffer
101 133
 * is full
102 134
 * @param byte Pointer to variable where byte read from keyboard will be stored
......
104 136
 */
105 137
int (kbc_read_byte)(uint8_t *byte);
106 138

  
139
/**
140
 * @}
141
 */
142

  
107 143
#endif //KBC_H_INCLUDED

Also available in: Unified diff