blob: 964c1cf997df38b2f4fa3c390eb6b15eea42c194 [file] [log] [blame]
piotr437f5462014-02-04 17:57:25 +01001#ifndef INCLUDED_GSM_CONSTANTS_H
2#define INCLUDED_GSM_CONSTANTS_H
3
4#define GSM_SYMBOL_RATE (1625000.0/6.0) //symbols per second
5#define GSM_SYMBOL_PERIOD (1.0/GSM_SYMBOL_RATE) //seconds per symbol
6
7//Burst timing
8#define TAIL_BITS 3
9#define GUARD_BITS 8
10#define GUARD_FRACTIONAL 0.25 //fractional part of guard period
11#define GUARD_PERIOD GUARD_BITS + GUARD_FRACTIONAL
12#define DATA_BITS 57 //size of 1 data block in normal burst
13#define STEALING_BIT 1
14#define N_TRAIN_BITS 26
15#define N_SYNC_BITS 64
16#define USEFUL_BITS 142 //(2*(DATA_BITS+STEALING_BIT) + N_TRAIN_BITS )
17#define FCCH_BITS USEFUL_BITS
18#define BURST_SIZE (USEFUL_BITS+2*TAIL_BITS)
19
20#define SCH_DATA_LEN 39
21#define TS_BITS (TAIL_BITS+USEFUL_BITS+TAIL_BITS+GUARD_BITS) //a full TS (156 bits)
22#define TS_PER_FRAME 8
23#define FRAME_BITS (TS_PER_FRAME * TS_BITS + 2) // 156.25 * 8
24#define FCCH_POS TAIL_BITS
25#define SYNC_POS 39
26#define TRAIN_POS ( TAIL_BITS + (DATA_BITS+STEALING_BIT) + 5) //first 5 bits of a training sequence
27 //aren't used for channel impulse response estimation
28#define TRAIN_BEGINNING 5
29#define SAFETY_MARGIN 6 //
30
31#define FCCH_HITS_NEEDED (USEFUL_BITS - 4)
32#define FCCH_MAX_MISSES 1
33#define FCCH_MAX_FREQ_OFFSET 100
34
35#define CHAN_IMP_RESP_LENGTH 5
36
piotr7c82b172014-02-08 14:15:27 +010037#define MAX_SCH_ERRORS 10 //maximum number of subsequent sch errors after which gsm receiver goes to find_next_fcch state
piotr437f5462014-02-04 17:57:25 +010038
39typedef enum {empty, fcch_burst, sch_burst, normal_burst, rach_burst, dummy, dummy_or_normal} burst_type;
40typedef enum {unknown, multiframe_26, multiframe_51} multiframe_type;
41
42static const unsigned char SYNC_BITS[] = {
43 1, 0, 1, 1, 1, 0, 0, 1, 0, 1, 1, 0, 0, 0, 1, 0,
44 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1,
45 0, 0, 1, 0, 1, 1, 0, 1, 0, 1, 0, 0, 0, 1, 0, 1,
46 0, 1, 1, 1, 0, 1, 1, 0, 0, 0, 0, 1, 1, 0, 1, 1
47};
48
49const unsigned FCCH_FRAMES[] = {0, 10, 20, 30, 40};
50const unsigned SCH_FRAMES[] = {1, 11, 21, 31, 41};
51
52const unsigned BCCH_FRAMES[] = {2, 3, 4, 5}; //!!the receiver shouldn't care about logical
53 //!!channels so this will be removed from this header
54const unsigned TEST_CCH_FRAMES[] = {2, 3, 4, 5, 6, 7, 8, 9, 12, 13, 14, 15, 16, 17, 18, 19, 22, 23, 24, 25, 26, 27, 28, 29, 32, 33, 34, 35, 36, 37, 38, 39, 42, 43, 44, 45, 46, 47, 48, 49};
55const unsigned TRAFFIC_CHANNEL_F[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24};
56const unsigned TEST51[] = {0, 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};
57
58
59#define TSC0 0
60#define TSC1 1
61#define TSC2 2
62#define TSC3 3
63#define TSC4 4
64#define TSC5 5
65#define TSC6 6
66#define TSC7 7
67#define TS_DUMMY 8
68
69#define TRAIN_SEQ_NUM 9
70
71#define TIMESLOT0 0
72#define TIMESLOT1 1
73#define TIMESLOT2 2
74#define TIMESLOT3 3
75#define TIMESLOT4 4
76#define TIMESLOT5 5
77#define TIMESLOT6 6
78#define TIMESLOT7 7
79
80
81static const unsigned char train_seq[TRAIN_SEQ_NUM][N_TRAIN_BITS] = {
82 {0, 0, 1, 0, 0, 1, 0, 1, 1, 1, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 1, 0, 1, 1, 1},
83 {0, 0, 1, 0, 1, 1, 0, 1, 1, 1, 0, 1, 1, 1, 1, 0, 0, 0, 1, 0, 0, 1, 0, 1, 1, 1},
84 {0, 1, 0, 0, 0, 0, 1, 1, 1, 0, 1, 1, 1, 0, 1, 0, 0, 1, 0, 0, 0, 0, 1, 1, 1, 0},
85 {0, 1, 0, 0, 0, 1, 1, 1, 1, 0, 1, 1, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 1, 1, 1, 0},
86 {0, 0, 0, 1, 1, 0, 1, 0, 1, 1, 1, 0, 0, 1, 0, 0, 0, 0, 0, 1, 1, 0, 1, 0, 1, 1},
87 {0, 1, 0, 0, 1, 1, 1, 0, 1, 0, 1, 1, 0, 0, 0, 0, 0, 1, 0, 0, 1, 1, 1, 0, 1, 0},
88 {1, 0, 1, 0, 0, 1, 1, 1, 1, 1, 0, 1, 1, 0, 0, 0, 1, 0, 1, 0, 0, 1, 1, 1, 1, 1},
89 {1, 1, 1, 0, 1, 1, 1, 1, 0, 0, 0, 1, 0, 0, 1, 0, 1, 1, 1, 0, 1, 1, 1, 1, 0, 0},
90 {0, 1, 1, 1, 0, 0, 0, 1, 0, 1, 1, 1, 0, 0, 0, 1, 0, 1, 1, 1, 0, 0, 0, 1, 0, 1} // DUMMY
91};
92
93
94//Dummy burst 0xFB 76 0A 4E 09 10 1F 1C 5C 5C 57 4A 33 39 E9 F1 2F A8
95static const unsigned char dummy_burst[] = {
96 0, 0, 0,
97 1, 1, 1, 1, 1, 0, 1, 1, 0, 1,
98 1, 1, 0, 1, 1, 0, 0, 0, 0, 0,
99 1, 0, 1, 0, 0, 1, 0, 0, 1, 1,
100 1, 0, 0, 0, 0, 0, 1, 0, 0, 1,
101 0, 0, 0, 1, 0, 0, 0, 0, 0, 0,
102 0, 1, 1, 1, 1, 1, 0, 0,
103
104 0, 1, 1, 1, 0, 0, 0, 1, 0, 1,
105 1, 1, 0, 0, 0, 1, 0, 1, 1, 1,
106 0, 0, 0, 1, 0, 1,
107
108 0, 1, 1, 1, 0, 1, 0, 0, 1, 0,
109 1, 0, 0, 0, 1, 1, 0, 0, 1, 1,
110 0, 0, 1, 1, 1, 0, 0, 1, 1, 1,
111 1, 0, 1, 0, 0, 1, 1, 1, 1, 1,
112 0, 0, 0, 1, 0, 0, 1, 0, 1, 1,
113 1, 1, 1, 0, 1, 0, 1, 0,
114 0, 0, 0
115};
116
117
118/*
119 * The frequency correction burst is used for frequency synchronization
120 * of the mobile. This is broadcast in TS0 together with the SCH and
121 * BCCH.
122 *
123 * Modulating the bits below causes a spike at 62.5kHz above (below for
124 * COMPACT) the center frequency. One can use this spike with a narrow
125 * band filter to accurately determine the center of the channel.
126 */
127static const unsigned char fc_fb[] = {
128 0, 0, 0, //I don't use this tables,
129 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, //I copied this here from burst_types.h because
130 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, //the description is very informative - p.krysik
131 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
132 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
133 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
134 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
135 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
136 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
137 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
138 0, 0, 0
139};
140
141static const unsigned char fc_compact_fb[] = {
142 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0,
143 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0,
144 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0,
145 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0,
146 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0,
147 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0,
148 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0,
149 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0,
150 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0
151};
152
153
154#endif /* INCLUDED_GSM_CONSTANTS_H */