GNU Radio's GPS Package
gps_despread_impl.h
Go to the documentation of this file.
1 /* -*- c++ -*- */
2 /*
3  * Copyright 2014 Samu Laaja.
4  *
5  * This is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation; either version 3, or (at your option)
8  * any later version.
9  *
10  * This software is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this software; see the file COPYING. If not, write to
17  * the Free Software Foundation, Inc., 51 Franklin Street,
18  * Boston, MA 02110-1301, USA.
19  */
20 
21 #ifndef INCLUDED_GPS_GPS_DESPREAD_IMPL_H
22 #define INCLUDED_GPS_GPS_DESPREAD_IMPL_H
23 
24 #define DEBUG_OUT
25 #define MAX_SEARCH_THREADS 4
26 
27 
28 #define FREQ_SAMPLING_RATE 4
29 
30 #include <gps/gps_despread.h>
31 #include <gnuradio/fft/fft.h>
32 #include <stdio.h>
33 
34 
35 typedef enum
36 {
40 } fsm_state;
41 
42 typedef struct
43 {
44  // inputs
45  gr_complex *data;
46  gr_complex *code_LUT;
47  int osr;
48  int data_len;
50 
51  // outputs
53  float best_freq;
54  float snr;
55 
56  int done;
57  int running;
58 
60 
61 namespace gr {
62  namespace gps {
63 
65  {
66  private:
67 
68  // code generator
69  gr_complex code_LUT[1023][32];
70  int code_selection;
71  int code_counter;
72  int increment_counter;
73 
74  int osr_int;
75 
76  int delay_selection;
77 
78  // search
79  int freq_search_Nsteps;
80 
81  search_data_t search_data;
82  pthread_t search_thread;
83  int search_acq_counter;
84 
85  int search_avg_selection;
86 
87  // doppler correction
88  float nco_freq;
89  float nco_freq_fixed;
90  float nco_phase;
91 
92  // code tracking
93  gr_complex track_integrator[5];
94  int track_counter;
95  int track_mode;
96  int lockdet_counter; // PLL lock detection
97 
98  // freq tracking
99  gr_complex freq_corr_integrator[FREQ_SAMPLING_RATE];
100  gr_complex freq_corr_integrator_d[FREQ_SAMPLING_RATE];
101  gr_complex freq_corr_integrator_filtered[FREQ_SAMPLING_RATE];
102  gr_complex freq_corr_integrator_filtered_d;
103  int fix_done;
104 
105  int freq_Nsamples; // number of frequency samples per code period
106 
107  float phase_error;
108  float lf_int;
109  float lf_zero_d;
110  float lf_pole_d;
111  float freqerror_trunc_d;
112 
113  fsm_state fsm;
114 
115  void generate_codes();
116 
117  void track(const gr_complex *, gr_complex *, int, int &);
118  void update_pll(float);
119 
120  public:
121  gps_despread_impl(int, int);
123 
124  void set_code(int);
125  int code(void) const;
126 
127  void set_osr(int);
128  int osr(void) const;
129 
130  void set_freq(float);
131 
132  void set_delay(int);
133  int delay(void) const;
134 
135  void start_search();
136 
137  void forecast(int, gr_vector_int &);
138  // Where all the action really happens
139  int general_work(int, gr_vector_int &, gr_vector_const_void_star &, gr_vector_void_star &);
140  };
141 
142  } // namespace gps
143 } // namespace gr
144 
145 #endif /* INCLUDED_GPS_GPS_DESPREAD_IMPL_H */
146 
Definition: gps_despread_impl.h:39
gr_complex * code_LUT
Definition: gps_despread_impl.h:46
int data_len
Definition: gps_despread_impl.h:48
Definition: gps_despread_impl.h:64
int osr
Definition: gps_despread_impl.h:47
float best_freq
Definition: gps_despread_impl.h:53
int running
Definition: gps_despread_impl.h:57
Definition: gps_despread_impl.h:42
Definition: gps_despread_impl.h:38
int best_delay
Definition: gps_despread_impl.h:52
<+description of block+>
Definition: gps_despread.h:36
int freq_search_Nsteps
Definition: gps_despread_impl.h:49
Definition: gps_despread_impl.h:37
int general_work(int, gr_vector_int &, gr_vector_const_void_star &, gr_vector_void_star &)
int delay(void) const
gr_complex * data
Definition: gps_despread_impl.h:45
void forecast(int, gr_vector_int &)
float snr
Definition: gps_despread_impl.h:54
#define FREQ_SAMPLING_RATE
Definition: gps_despread_impl.h:28
int done
Definition: gps_despread_impl.h:56
fsm_state
Definition: gps_despread_impl.h:35