Lab3

i8254.h

00001 #ifndef _LCOM_I8254_H_
00002 #define _LCOM_I8254_H_
00003 
00010 #define TIMER_FREQ  1193182    
00012 #define BIT(n) (0x01<<(n))
00013 
00014 #define TIMER0_IRQ              0    
00016 /* I/O port addresses */
00017 
00018 #define TIMER_0                 0x40 
00019 #define TIMER_1                 0x41 
00020 #define TIMER_2                 0x42 
00021 #define TIMER_CTRL              0x43 
00023 #define SPEAKER_CTRL            0x61 
00025 /* Timer control */
00026 
00027 /* Timer selection: bits 7 and 6 */
00028 
00029 #define TIMER_SEL0              0x00     
00030 #define TIMER_SEL1              BIT(6)   
00031 #define TIMER_SEL2              BIT(7)   
00032 #define TIMER_RB_CMD            (BIT(7)|BIT(6))  
00034 /* Register selection: bits 5 and 4 */
00035 
00036 #define TIMER_LSB               BIT(4)  
00037 #define TIMER_MSB               BIT(5)  
00038 #define TIMER_LSB_MSB           (TIMER_LSB | TIMER_MSB) 
00040 /* Operating mode: bits 3, 2 and 1 */
00041 
00042 #define TIMER_SQR_WAVE          (BIT(2)|BIT(1)) 
00043 #define TIMER_RATE_GEN          BIT(2)          
00045 /* Counting mode: bit 0 */
00046 
00047 #define TIMER_BCD                       0x01   
00048 #define TIMER_BIN                       0x00   
00050 /* READ-BACK COMMAND FORMAT */
00051 
00052 #define TIMER_RB_COUNT_         BIT(5)
00053 #define TIMER_RB_STATUS_        BIT(4)
00054 #define TIMER_RB_SEL(n)         BIT((n)+1)
00055 
00056 
00059 #endif /* _LCOM_I8254_H */