Lab2
 All Functions Groups
i8254.h
1 #ifndef _LCOM_I8254_H_
2 #define _LCOM_I8254_H_
3 
10 #define TIMER_FREQ 1193182
12 #define BIT(n) (0x01<<(n))
13 
14 #define TIMER0_IRQ 0
16 /* I/O port addresses */
17 
18 #define TIMER_0 0x40
19 #define TIMER_1 0x41
20 #define TIMER_2 0x42
21 #define TIMER_CTRL 0x43
23 #define SPEAKER_CTRL 0x61
25 /* Timer control */
26 
27 /* Timer selection: bits 7 and 6 */
28 
29 #define TIMER_SEL0 0x00
30 #define TIMER_SEL1 BIT(6)
31 #define TIMER_SEL2 BIT(7)
32 #define TIMER_RB_CMD (BIT(7)|BIT(6))
34 /* Register selection: bits 5 and 4 */
35 
36 #define TIMER_LSB BIT(4)
37 #define TIMER_MSB BIT(5)
38 #define TIMER_LSB_MSB (TIMER_LSB | TIMER_MSB)
40 /* Operating mode: bits 3, 2 and 1 */
41 
42 #define TIMER_SQR_WAVE (BIT(2)|BIT(1))
43 #define TIMER_RATE_GEN BIT(2)
45 /* Counting mode: bit 0 */
46 
47 #define TIMER_BCD 0x01
48 #define TIMER_BIN 0x00
50 /* READ-BACK COMMAND FORMAT */
51 
52 #define TIMER_RB_COUNT_ BIT(5)
53 #define TIMER_RB_STATUS_ BIT(4)
54 #define TIMER_RB_SEL(n) BIT((n)+1)
55 
56 
59 #endif /* _LCOM_I8254_H */