Project

General

Profile

Revision 60

changes

View differences:

kbc.h
1
#ifndef _KBC_H_
2
#define _KBC_H_
1
/**
2
 * This file concerns everything related to the KBC (KeyBoard Controller, which
3
 * actually also manages the mouse)
4
 */
3 5

  
4
/* KBC IRQ Line */
6
#ifndef _KBC_FUNC_H_
7
#define _KBC_FUNC_H_
5 8

  
6
#define KBC_IRQ     1 /* @brief KBC Controller IRQ Line */
9
/**
10
 * @brief Unsubcribes Interrupts
11
 * @param interrupt_id Interrupt ID, value via arguments on subscription of the interrupt_id
12
 * @see subscribe_kbc_interrupt, subscribe_timer_interrupt
13
 * @return Whether operation was sucessful or not
14
 */
15
int (unsubscribe_interrupt)(int *interrupt_id);
7 16

  
8
/* Delay for KBC */
9
#define DELAY           20000 /* @brief KBC Response Delay */
10
#define KBC_NUM_TRIES   10    /* @brief Number of tries to issue command before timeout */
17
/**
18
 * @brief High-level function that reads the command byte of the KBC
19
 * @param cmd Pointer to variable where command byte read from KBC will be stored
20
 * @return 0 if operation was successful, 1 otherwise
21
 */
22
int (kbc_read_cmd)(uint8_t *cmd);
11 23

  
12
/* I/O Ports Addresses */
24
/**
25
 * @brief High-level function that changes the command byte of the KBC
26
 * @param cmd New value for command byte of KBC
27
 * @return 0 if operation was successful, 1 otherwise
28
 */
29
int (kbc_change_cmd)(uint8_t cmd);
13 30

  
14
#define KBC_CMD     0x64 /* @brief Address to send commands to KBC */
15
#define KBC_CMD_ARG 0x60 /* @brief Address to write KBC Command Arguments */
16
#define STATUS_REG  0x64 /* @brief KBC Status Register address */
31
/**
32
 * @brief High-level function that restores KBC to normal state
33
 * High-level function that restores KBC to normal state, because lcf_start
34
 * changes the command byte of KBC. If this function is not used, there is a
35
 * chance that the keyboard and keyboard interrupts remain disabled.
36
 * @return 1 if operation was successful, 1 otherwise
37
 */
38
int (kbc_restore_keyboard)();
17 39

  
18
#define OUTPUT_BUF  0x60 /* @brief Address of Output Buffer of KBC */
40
/**
41
 * @brief Low-level function to issue a command to keyboard
42
 * @param cmd command to be issued
43
 * @return 0 if operation was successful, 1 otherwise
44
 */
45
int (kbc_issue_cmd)(uint8_t cmd);
19 46

  
20
/* KBC Commands */
21
#define READ_KBC_CMD    0x20 /* @brief Read KBC Command Byte */
22
#define WRITE_KBC_CMD   0x60 /* @brief Write KBC Command Byte */
23
#define KBC_SELF_TEST   0xAA /* @brief KBC Diagnostic Tests */
24
#define KBC_INT_TEST    0xAB /* @brief Tests Keyboard Clock and Data lines */
25
#define KBC_INT_DISABLE 0xAD /* @brief Disable KBC Interface */
26
#define KBC_INT_ENABLE  0xAE /* @brief Enable KBC Interface */
47
/**
48
 * @brief Low-level function for reading byte from keyboard
49
 * Low-level function for reading byte from keyboard. Waits until output buffer
50
 * is full
51
 * @param value Pointer to variable where byte read from keyboard will be stored
52
 * @return 0 if operation was successful, 1 otherwise
53
 */
54
int (kbc_read_byte)(uint8_t *byte);
27 55

  
28
/* Status Byte Masking */
29 56

  
30
#define OUT_BUF_FUL     BIT(0) /* @brief Output Buffer State */
31
#define IN_BUF_FULL     BIT(1) /* @brief Input Buffer State */
32
#define SYS_FLAG        BIT(2) /* @brief System Flag */
33
#define DATA_CMD_WRITE  BIT(3) /* @brief Identifier of type of byte in input buffer */
34
#define INH_FLAG        BIT(4) /* @brief Keyboard inihibited */
35
#define AUX_MOUSE       BIT(5) /* @brief Mouse Data */
36
#define TIME_OUT_REC    BIT(6) /* @brief Time Out Error - Invalid Data */
37
#define PARITY_ERROR    BIT(7) /* @brief Parity Error - Invalid Data */
38

  
39
/* Scancode Constants */
40

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

  
45
/* Command byte masks */
46
#define INT_KBD         BIT(0)
47
#define INT_MOU         BIT(1)
48
#define DIS_KBD         BIT(4)
49
#define DIS_MOU         BIT(5)
50

  
51 57
#endif

Also available in: Unified diff