23 #ifndef INCLUDED_GSM_CONSTANTS_H
24 #define INCLUDED_GSM_CONSTANTS_H
26 #define GSM_SYMBOL_RATE (1625000.0/6.0) //symbols per second
27 #define GSM_SYMBOL_PERIOD (1.0/GSM_SYMBOL_RATE) //seconds per symbol
32 #define GUARD_FRACTIONAL 0.25 //fractional part of guard period
33 #define GUARD_PERIOD GUARD_BITS + GUARD_FRACTIONAL
34 #define DATA_BITS 57 //size of 1 data block in normal burst
35 #define STEALING_BIT 1
36 #define N_TRAIN_BITS 26
37 #define N_SYNC_BITS 64
38 #define USEFUL_BITS 142 //(2*(DATA_BITS+STEALING_BIT) + N_TRAIN_BITS )
39 #define FCCH_BITS USEFUL_BITS
40 #define BURST_SIZE (USEFUL_BITS+2*TAIL_BITS)
41 #define ACCESS_BURST_SIZE 88
42 #define PROCESSED_CHUNK BURST_SIZE+2*GUARD_PERIOD
44 #define SCH_DATA_LEN 39
45 #define TS_BITS (TAIL_BITS+USEFUL_BITS+TAIL_BITS+GUARD_BITS) //a full TS (156 bits)
46 #define TS_PER_FRAME 8
47 #define FRAME_BITS (TS_PER_FRAME * TS_BITS + 2) // 156.25 * 8
48 #define FCCH_POS TAIL_BITS
50 #define TRAIN_POS ( TAIL_BITS + (DATA_BITS+STEALING_BIT) + 5) //first 5 bits of a training sequence
52 #define TRAIN_BEGINNING 5
53 #define SAFETY_MARGIN 6 //
55 #define FCCH_HITS_NEEDED (USEFUL_BITS - 4)
56 #define FCCH_MAX_MISSES 1
57 #define FCCH_MAX_FREQ_OFFSET 100
59 #define CHAN_IMP_RESP_LENGTH 5
61 #define MAX_SCH_ERRORS 10 //maximum number of subsequent sch errors after which gsm receiver goes to find_next_fcch state
67 1, 0, 1, 1, 1, 0, 0, 1, 0, 1, 1, 0, 0, 0, 1, 0,
68 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1,
69 0, 0, 1, 0, 1, 1, 0, 1, 0, 1, 0, 0, 0, 1, 0, 1,
70 0, 1, 1, 1, 0, 1, 1, 0, 0, 0, 0, 1, 1, 0, 1, 1
78 const 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};
79 const 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};
80 const 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};
93 #define TRAIN_SEQ_NUM 9
106 {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},
107 {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},
108 {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},
109 {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},
110 {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},
111 {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},
112 {1, 0, 1, 0, 0, 1, 1, 1, 1, 1, 0, 1, 1, 0, 0, 0, 1, 0, 1, 0, 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