blob: c8b85c7f13ae72809ce7798275718dd4c293b127 [file] [log] [blame]
piotr437f5462014-02-04 17:57:25 +01001/* -*- c++ -*- */
2/*
3 * @file
ptrkrysik529895b2014-12-02 18:07:38 +01004 * @author Piotr Krysik <ptrkrysik@gmail.com>
piotr437f5462014-02-04 17:57:25 +01005 * @section LICENSE
6 *
ptrkrysik529895b2014-12-02 18:07:38 +01007 * Gr-gsm is free software; you can redistribute it and/or modify
piotr437f5462014-02-04 17:57:25 +01008 * 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 *
ptrkrysik529895b2014-12-02 18:07:38 +010012 * Gr-gsm is distributed in the hope that it will be useful,
piotr437f5462014-02-04 17:57:25 +010013 * 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
ptrkrysik529895b2014-12-02 18:07:38 +010018 * along with gr-gsm; see the file COPYING. If not, write to
piotr437f5462014-02-04 17:57:25 +010019 * the Free Software Foundation, Inc., 51 Franklin Street,
20 * Boston, MA 02110-1301, USA.
piotr437f5462014-02-04 17:57:25 +010021 */
22#ifdef HAVE_CONFIG_H
23#include "config.h"
24#endif
25
26#include <receiver_config.h>
27
28burst_counter & burst_counter::operator++(int)
29{
30 d_timeslot_nr++;
31 if (d_timeslot_nr == TS_PER_FRAME) {
32 d_timeslot_nr = 0;
33
34 if ((d_t2 == 25) && (d_t3 == 50)) {
35 d_t1 = (d_t1 + 1) % (1 << 11);
36 }
37
38 d_t2 = (d_t2 + 1) % 26;
39 d_t3 = (d_t3 + 1) % 51;
40 }
41
42 //update offset - this is integer for d_OSR which is multiple of four
43 d_offset_fractional += GUARD_FRACTIONAL * d_OSR;
44 d_offset_integer = floor(d_offset_fractional);
45 d_offset_fractional = d_offset_fractional - d_offset_integer;
46 return (*this);
47}
48
49void burst_counter::set(uint32_t t1, uint32_t t2, uint32_t t3, uint32_t timeslot_nr)
50{
51 d_t1 = t1;
52 d_t2 = t2;
53 d_t3 = t3;
54 d_timeslot_nr = timeslot_nr;
55 double first_sample_position = (get_frame_nr() * 8 + timeslot_nr) * TS_BITS;
56 d_offset_fractional = first_sample_position - floor(first_sample_position);
57 d_offset_integer = 0;
58}
59
60burst_type channel_configuration::get_burst_type(burst_counter burst_nr)
61{
62 uint32_t timeslot_nr = burst_nr.get_timeslot_nr();
63 multiframe_type m_type = d_timeslots_descriptions[timeslot_nr].get_type();
64 uint32_t nr;
65
66 switch (m_type) {
67 case multiframe_26:
68 nr = burst_nr.get_t2();
69 break;
70 case multiframe_51:
71 nr = burst_nr.get_t3();
72 break;
73 default:
74 nr = 0;
75 break;
76 }
77
78 return d_timeslots_descriptions[timeslot_nr].get_burst_type(nr);
79}