root / lab2 / i8254.h
History | View | Annotate | Download (1.89 KB)
1 | 1 | up20180614 | #ifndef _LCOM_I8254_H_
|
---|---|---|---|
2 | #define _LCOM_I8254_H_
|
||
3 | |||
4 | #include <lcom/lcf.h> |
||
5 | |||
6 | /** @defgroup i8254 i8254
|
||
7 | * @{
|
||
8 | *
|
||
9 | * Constants for programming the i8254 Timer. Needs to be completed.
|
||
10 | */
|
||
11 | |||
12 | |||
13 | |||
14 | /*IRQ's*/
|
||
15 | |||
16 | #define IRQ_TIMER 0 |
||
17 | #define DEFAULT_FREQ 60 |
||
18 | |||
19 | |||
20 | #define TIMER_FREQ 1193182 /**< @brief clock frequency for timer in PC and AT */ |
||
21 | #define MIN_FREQ 19 |
||
22 | #define TIMER0_IRQ 0 /**< @brief Timer 0 IRQ line */ |
||
23 | |||
24 | /* I/O port addresses */
|
||
25 | |||
26 | #define TIMER_0 0x40 /**< @brief Timer 0 count register */ |
||
27 | #define TIMER_1 0x41 /**< @brief Timer 1 count register */ |
||
28 | #define TIMER_2 0x42 /**< @brief Timer 2 count register */ |
||
29 | #define TIMER_CTRL 0x43 /**< @brief Control register */ |
||
30 | |||
31 | #define SPEAKER_CTRL 0x61 /**< @brief Register for speaker control */ |
||
32 | |||
33 | /* Timer control */
|
||
34 | |||
35 | /* Timer selection: bits 7 and 6 */
|
||
36 | |||
37 | #define TIMER_SEL0 0x00 /**< @brief Control Word for Timer 0 */ |
||
38 | #define TIMER_SEL1 BIT(6) /**< @brief Control Word for Timer 1 */ |
||
39 | #define TIMER_SEL2 BIT(7) /**< @brief Control Word for Timer 2 */ |
||
40 | #define TIMER_RB_CMD (BIT(7) | BIT(6)) /**< @brief Read Back Command */ |
||
41 | |||
42 | /* Register selection: bits 5 and 4 */
|
||
43 | |||
44 | #define TIMER_LSB BIT(4) /**< @brief Initialize Counter LSB only */ |
||
45 | #define TIMER_MSB BIT(5) /**< @brief Initialize Counter MSB only */ |
||
46 | #define TIMER_LSB_MSB (TIMER_LSB | TIMER_MSB) /**< @brief Initialize LSB first and MSB afterwards */ |
||
47 | |||
48 | /* Operating mode: bits 3, 2 and 1 */
|
||
49 | |||
50 | #define TIMER_SQR_WAVE (BIT(2) | BIT(1)) /**< @brief Mode 3: square wave generator */ |
||
51 | #define TIMER_RATE_GEN BIT(2) /**< @brief Mode 2: rate generator */ |
||
52 | |||
53 | /* Counting mode: bit 0 */
|
||
54 | |||
55 | #define TIMER_BCD 0x01 /**< @brief Count in BCD */ |
||
56 | #define TIMER_BIN 0x00 /**< @brief Count in binary */ |
||
57 | |||
58 | /* READ-BACK COMMAND FORMAT */
|
||
59 | |||
60 | #define TIMER_RB_COUNT_ BIT(5) |
||
61 | #define TIMER_RB_STATUS_ BIT(4) |
||
62 | #define TIMER_RB_SEL(n) BIT((n) + 1) |
||
63 | |||
64 | /**@}*/
|
||
65 | |||
66 | #endif /* _LCOM_I8254_H */ |