blob: 01d089b12e1f018dbdb25e74656cf9c8ebdc2494 [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)
piotr7f3f3662014-07-08 16:47:53 +020019#define PROCESSED_CHUNK BURST_SIZE+2*GUARD_PERIOD
piotr437f5462014-02-04 17:57:25 +010020
21#define SCH_DATA_LEN 39
22#define TS_BITS (TAIL_BITS+USEFUL_BITS+TAIL_BITS+GUARD_BITS) //a full TS (156 bits)
23#define TS_PER_FRAME 8
24#define FRAME_BITS (TS_PER_FRAME * TS_BITS + 2) // 156.25 * 8
25#define FCCH_POS TAIL_BITS
26#define SYNC_POS 39
27#define TRAIN_POS ( TAIL_BITS + (DATA_BITS+STEALING_BIT) + 5) //first 5 bits of a training sequence
28 //aren't used for channel impulse response estimation
29#define TRAIN_BEGINNING 5
30#define SAFETY_MARGIN 6 //
31
32#define FCCH_HITS_NEEDED (USEFUL_BITS - 4)
33#define FCCH_MAX_MISSES 1
34#define FCCH_MAX_FREQ_OFFSET 100
35
36#define CHAN_IMP_RESP_LENGTH 5
37
piotr7c82b172014-02-08 14:15:27 +010038#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 +010039
ptrkrysik58213792014-10-30 09:05:15 +010040typedef enum {empty, fcch_burst, sch_burst, normal_burst, rach_burst, dummy, dummy_or_normal, normal_or_noise} burst_type;
piotr437f5462014-02-04 17:57:25 +010041typedef enum {unknown, multiframe_26, multiframe_51} multiframe_type;
42
43static const unsigned char SYNC_BITS[] = {
44 1, 0, 1, 1, 1, 0, 0, 1, 0, 1, 1, 0, 0, 0, 1, 0,
45 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1,
46 0, 0, 1, 0, 1, 1, 0, 1, 0, 1, 0, 0, 0, 1, 0, 1,
47 0, 1, 1, 1, 0, 1, 1, 0, 0, 0, 0, 1, 1, 0, 1, 1
48};
49
50const unsigned FCCH_FRAMES[] = {0, 10, 20, 30, 40};
51const unsigned SCH_FRAMES[] = {1, 11, 21, 31, 41};
52
53const unsigned BCCH_FRAMES[] = {2, 3, 4, 5}; //!!the receiver shouldn't care about logical
54 //!!channels so this will be removed from this header
55const 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};
56const 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};
57const 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};
58
59
60#define TSC0 0
61#define TSC1 1
62#define TSC2 2
63#define TSC3 3
64#define TSC4 4
65#define TSC5 5
66#define TSC6 6
67#define TSC7 7
68#define TS_DUMMY 8
69
70#define TRAIN_SEQ_NUM 9
71
72#define TIMESLOT0 0
73#define TIMESLOT1 1
74#define TIMESLOT2 2
75#define TIMESLOT3 3
76#define TIMESLOT4 4
77#define TIMESLOT5 5
78#define TIMESLOT6 6
79#define TIMESLOT7 7
80
81
82static const unsigned char train_seq[TRAIN_SEQ_NUM][N_TRAIN_BITS] = {
83 {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},
84 {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},
85 {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},
86 {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},
87 {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},
88 {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},
89 {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},
90 {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},
91 {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
92};
93
94
95//Dummy burst 0xFB 76 0A 4E 09 10 1F 1C 5C 5C 57 4A 33 39 E9 F1 2F A8
96static const unsigned char dummy_burst[] = {
97 0, 0, 0,
98 1, 1, 1, 1, 1, 0, 1, 1, 0, 1,
99 1, 1, 0, 1, 1, 0, 0, 0, 0, 0,
100 1, 0, 1, 0, 0, 1, 0, 0, 1, 1,
101 1, 0, 0, 0, 0, 0, 1, 0, 0, 1,
102 0, 0, 0, 1, 0, 0, 0, 0, 0, 0,
103 0, 1, 1, 1, 1, 1, 0, 0,
104
105 0, 1, 1, 1, 0, 0, 0, 1, 0, 1,
106 1, 1, 0, 0, 0, 1, 0, 1, 1, 1,
107 0, 0, 0, 1, 0, 1,
108
109 0, 1, 1, 1, 0, 1, 0, 0, 1, 0,
110 1, 0, 0, 0, 1, 1, 0, 0, 1, 1,
111 0, 0, 1, 1, 1, 0, 0, 1, 1, 1,
112 1, 0, 1, 0, 0, 1, 1, 1, 1, 1,
113 0, 0, 0, 1, 0, 0, 1, 0, 1, 1,
114 1, 1, 1, 0, 1, 0, 1, 0,
115 0, 0, 0
116};
117
118
119/*
120 * The frequency correction burst is used for frequency synchronization
121 * of the mobile. This is broadcast in TS0 together with the SCH and
122 * BCCH.
123 *
124 * Modulating the bits below causes a spike at 62.5kHz above (below for
125 * COMPACT) the center frequency. One can use this spike with a narrow
126 * band filter to accurately determine the center of the channel.
127 */
128static const unsigned char fc_fb[] = {
129 0, 0, 0, //I don't use this tables,
130 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
131 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, //the description is very informative - p.krysik
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, 0, 0,
138 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
139 0, 0, 0
140};
141
142static const unsigned char fc_compact_fb[] = {
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, 1, 0,
151 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0
152};
153
154
155#endif /* INCLUDED_GSM_CONSTANTS_H */