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