blob: c7c996eebf5a9acdb60af104723fd0e2234817ad [file] [log] [blame]
piotr437f5462014-02-04 17:57:25 +01001/* -*- c++ -*- */
2/*
3 * @file
4 * @author Piotr Krysik <pkrysik@stud.elka.pw.edu.pl>
5 * @section LICENSE
6 *
7 * GNU Radio is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 3, or (at your option)
10 * any later version.
11 *
12 * GNU Radio is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with GNU Radio; see the file COPYING. If not, write to
19 * the Free Software Foundation, Inc., 51 Franklin Street,
20 * Boston, MA 02110-1301, USA.
21 *
22 * @section DESCRIPTION
23 * This file contains classes which define gsm_receiver configuration
24 * and the burst_counter which is used to store internal state of the receiver
25 * when it's synchronized
26 */
27#ifdef HAVE_CONFIG_H
28#include "config.h"
29#endif
30
31#include <receiver_config.h>
32
33burst_counter & burst_counter::operator++(int)
34{
35 d_timeslot_nr++;
36 if (d_timeslot_nr == TS_PER_FRAME) {
37 d_timeslot_nr = 0;
38
39 if ((d_t2 == 25) && (d_t3 == 50)) {
40 d_t1 = (d_t1 + 1) % (1 << 11);
41 }
42
43 d_t2 = (d_t2 + 1) % 26;
44 d_t3 = (d_t3 + 1) % 51;
45 }
46
47 //update offset - this is integer for d_OSR which is multiple of four
48 d_offset_fractional += GUARD_FRACTIONAL * d_OSR;
49 d_offset_integer = floor(d_offset_fractional);
50 d_offset_fractional = d_offset_fractional - d_offset_integer;
51 return (*this);
52}
53
54void burst_counter::set(uint32_t t1, uint32_t t2, uint32_t t3, uint32_t timeslot_nr)
55{
56 d_t1 = t1;
57 d_t2 = t2;
58 d_t3 = t3;
59 d_timeslot_nr = timeslot_nr;
60 double first_sample_position = (get_frame_nr() * 8 + timeslot_nr) * TS_BITS;
61 d_offset_fractional = first_sample_position - floor(first_sample_position);
62 d_offset_integer = 0;
63}
64
65burst_type channel_configuration::get_burst_type(burst_counter burst_nr)
66{
67 uint32_t timeslot_nr = burst_nr.get_timeslot_nr();
68 multiframe_type m_type = d_timeslots_descriptions[timeslot_nr].get_type();
69 uint32_t nr;
70
71 switch (m_type) {
72 case multiframe_26:
73 nr = burst_nr.get_t2();
74 break;
75 case multiframe_51:
76 nr = burst_nr.get_t3();
77 break;
78 default:
79 nr = 0;
80 break;
81 }
82
83 return d_timeslots_descriptions[timeslot_nr].get_burst_type(nr);
84}