Statistiques
| Branche: | Révision:

root / TL16C754_training.X / TL16C_CFG.h @ master

Historique | Voir | Annoter | Télécharger (1,694 ko)

1 d2006889 Enzo Niro
// TL16C setup depending on clock frequency used
2
3
#ifndef TL16C_CFG_H
4
#define        TL16C_CFG_H
5
6
#include <xc.h> // include processor files - each processor file is guarded. 
7
8
//////////////////////////////////
9
//TL16C Setup
10
11
//#define TL16C_8MHZ_CLK
12
#define TL16C_16MHZ_CLK
13
//#define TL16C_24MHZ_CLK
14
15
//////////////////////////////////
16
17
18
enum uartType_index {
19
    UART_A = 0,
20
    UART_B,
21
    UART_C,
22
    UART_D,
23
};
24
25
enum dataWord_index {
26
    DATA_5BITS = 0,
27
    DATA_6BITS,
28
    DATA_7BITS,
29
    DATA_8BITS,
30
};
31
32
enum speedBus_index {
33
    BAUDS_9600 = 0,
34
    BAUDS_19200,
35
    BAUDS_38400,
36
};
37
38
enum stopBit_index {
39
    ONE_STOPBIT = 0,
40
    TWO_STOPBIT,
41
};
42
43
enum parity_index {
44
    NO_PARITY = 0,
45
    ODD_PARITY,
46
    EVEN_PARITY,
47
};
48
49
50
51
52
53
#define DLAB_ERF_EN_BIT  0x80
54
55
//Parity param.s
56
#define PARITY_NONE      0
57
#define PARITY_ODD       1
58
#define PARITY_EVEN      3
59
//Stop bit param.s
60
#define STOPBIT_ONE      0
61
#define STOPBIT_TWO      1
62
//Word data bit param.s
63
#define WORD_5BITS       0
64
#define WORD_6BITS       1
65
#define WORD_7BITS       2
66
#define WORD_8BITS       3
67
68
///////////////////////////
69
//Divisor Latch values
70
71
72
73
74
//According to 8MHz
75
#ifdef TL16C_8MHZ_CLK
76
77
#define DL_9600_BAUDS    52
78
#define DL_19200_BAUDS   26
79
#define DL_38400_BAUDS   13
80
81
#else
82
#ifdef TL16C_16MHZ_CLK
83
84
#define DL_9600_BAUDS    104
85
#define DL_19200_BAUDS   52
86
#define DL_38400_BAUDS   26
87
88
#else
89
#ifdef TL16C_24MHZ_CLK
90
91
#define DL_9600_BAUDS    156
92
#define DL_19200_BAUDS   78
93
#define DL_38400_BAUDS   39
94
95
#else
96
#error "Please choose a configuration for baud speed"
97
#define DL_9600_BAUDS    0x0
98
#define DL_19200_BAUDS   0x0
99
#define DL_38400_BAUDS   0x0
100
#define CPU_FREQ_SET     0x0
101
102
#endif //24MHZ
103
#endif //16MHZ
104
#endif //8MHZ
105
106
#endif        /* XC_HEADER_TEMPLATE_H */