Project

General

Profile

Statistics
| Revision:

root / lab2 / i8254.h @ 19

History | View | Annotate | Download (2.37 KB)

1 4 up20180655
#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
#define TIMER_FREQ 1193182 /**< @brief clock frequency for timer in PC and AT */
13 18 up20180655
#define TIMER_MIN_FREQ 19 /**< @brief mininum frequency for timer */
14 4 up20180655
#define TIMER0_IRQ 0 /**< @brief Timer 0 IRQ line */
15
16 18 up20180655
17 4 up20180655
/* I/O port addresses */
18
19
#define TIMER_0    0x40 /**< @brief Timer 0 count register */
20
#define TIMER_1    0x41 /**< @brief Timer 1 count register */
21
#define TIMER_2    0x42 /**< @brief Timer 2 count register */
22
#define TIMER_CTRL 0x43 /**< @brief Control register */
23
24
#define SPEAKER_CTRL 0x61 /**< @brief Register for speaker control  */
25
26
/* Timer control */
27
28
/* Timer selection: bits 7 and 6 */
29
30
#define TIMER_SEL0   0x00              /**< @brief Control Word for Timer 0 */
31
#define TIMER_SEL1   BIT(6)            /**< @brief Control Word for Timer 1 */
32
#define TIMER_SEL2   BIT(7)            /**< @brief Control Word for Timer 2 */
33
#define TIMER_RB_CMD (BIT(7) | BIT(6)) /**< @brief Read Back Command */
34
35
/* Register selection: bits 5 and 4 */
36
37
#define TIMER_LSB     BIT(4)                  /**< @brief Initialize Counter LSB only */
38
#define TIMER_MSB     BIT(5)                  /**< @brief Initialize Counter MSB only */
39
#define TIMER_LSB_MSB (TIMER_LSB | TIMER_MSB) /**< @brief Initialize LSB first and MSB afterwards */
40 10 up20180655
#define TIMER_INMODE_MASK 0x30      //0011 0000
41 6 up20180642
#define TIMER_INMODE_POS  4
42 4 up20180655
43
/* Operating mode: bits 3, 2 and 1 */
44
45
#define TIMER_SQR_WAVE (BIT(2) | BIT(1)) /**< @brief Mode 3: square wave generator */
46
#define TIMER_RATE_GEN BIT(2)            /**< @brief Mode 2: rate generator */
47 10 up20180655
#define TIMER_MODE_MASK 0x0E             /**< @brief Mask for mode */
48 6 up20180642
#define TIMER_MODE_POS  1                /**< @brief Position of smallest bit from mode */
49 17 up20180642
#define TIMER_MODE_2ALT 0x6              /**< @brief Alternative notation for mode 2 */
50
#define TIMER_MODE_3ALT 0x7              /**< @brief Alternative notation for mode 3 */
51 16 up20180642
#define TIMER_MODE_RED2 0x03             /**< @brief Reduce 3-bit mode to 2-bit mode */
52 4 up20180655
53 17 up20180642
54 4 up20180655
/* Counting mode: bit 0 */
55
56
#define TIMER_BCD 0x01 /**< @brief Count in BCD */
57
#define TIMER_BIN 0x00 /**< @brief Count in binary */
58
59
/* READ-BACK COMMAND FORMAT */
60
61
#define TIMER_RB_COUNT_  BIT(5)
62
#define TIMER_RB_STATUS_ BIT(4)
63
#define TIMER_RB_SEL(n)  BIT((n) + 1)
64
65
/**@}*/
66
67
#endif /* _LCOM_I8254_H */