diff --git a/src/algorithms/acquisition/libs/gps_fpga_acquisition_8sc.cc b/src/algorithms/acquisition/libs/gps_fpga_acquisition_8sc.cc index 214dc3d93..d195064ff 100644 --- a/src/algorithms/acquisition/libs/gps_fpga_acquisition_8sc.cc +++ b/src/algorithms/acquisition/libs/gps_fpga_acquisition_8sc.cc @@ -73,51 +73,51 @@ #define MAX_PHASE_STEP_RAD 0.999999999534339 // 1 - pow(2,-31); - bool gps_fpga_acquisition_8sc::init(unsigned int fft_size, unsigned int nsamples_total, long freq, unsigned int doppler_max, unsigned int doppler_step, int num_doppler_bins, long fs_in, unsigned select_queue) - { - float phase_step_rad_fpga; +bool gps_fpga_acquisition_8sc::init(unsigned int fft_size, unsigned int nsamples_total, long freq, unsigned int doppler_max, unsigned int doppler_step, int num_doppler_bins, long fs_in, unsigned select_queue) +{ + float phase_step_rad_fpga; - d_phase_step_rad_vector = new float[num_doppler_bins]; + d_phase_step_rad_vector = new float[num_doppler_bins]; - for (int doppler_index = 0; doppler_index < num_doppler_bins; doppler_index++) - { - int doppler = -static_cast(doppler_max) + doppler_step * doppler_index; - float phase_step_rad = GPS_TWO_PI * (freq + doppler) / static_cast(fs_in); - // The doppler step can never be outside the range -pi to +pi, otherwise there would be aliasing - // The FPGA expects phase_step_rad between -1 (-pi) to +1 (+pi) - // The FPGA also expects the phase to be negative since it produces cos(x) -j*sin(x) - // while the gnss-sdr software (volk_gnsssdr_s32f_sincos_32fc) generates cos(x) + j*sin(x) - phase_step_rad_fpga = phase_step_rad/(GPS_TWO_PI/2); - // avoid saturation of the fixed point representation in the fpga - // (only the positive value can saturate due to the 2's complement representation) - if (phase_step_rad_fpga == 1.0) - { - phase_step_rad_fpga = MAX_PHASE_STEP_RAD; - } - d_phase_step_rad_vector[doppler_index] = phase_step_rad_fpga; + for (int doppler_index = 0; doppler_index < num_doppler_bins; doppler_index++) + { + int doppler = -static_cast(doppler_max) + doppler_step * doppler_index; + float phase_step_rad = GPS_TWO_PI * (freq + doppler) / static_cast(fs_in); + // The doppler step can never be outside the range -pi to +pi, otherwise there would be aliasing + // The FPGA expects phase_step_rad between -1 (-pi) to +1 (+pi) + // The FPGA also expects the phase to be negative since it produces cos(x) -j*sin(x) + // while the gnss-sdr software (volk_gnsssdr_s32f_sincos_32fc) generates cos(x) + j*sin(x) + phase_step_rad_fpga = phase_step_rad/(GPS_TWO_PI/2); + // avoid saturation of the fixed point representation in the fpga + // (only the positive value can saturate due to the 2's complement representation) + if (phase_step_rad_fpga == 1.0) + { + phase_step_rad_fpga = MAX_PHASE_STEP_RAD; + } + d_phase_step_rad_vector[doppler_index] = phase_step_rad_fpga; - } + } - // sanity check : check test register - unsigned writeval = 0x55AA; - unsigned readval; - readval = gps_fpga_acquisition_8sc::fpga_acquisition_test_register(writeval); - if (writeval != readval) - { - printf("test register fail\n"); - LOG(WARNING) << "Acquisition test register sanity check failed"; - } - else - { - printf("test register success\n"); - LOG(INFO) << "Acquisition test register sanity check success !"; - } + // sanity check : check test register + unsigned writeval = 0x55AA; + unsigned readval; + readval = gps_fpga_acquisition_8sc::fpga_acquisition_test_register(writeval); + if (writeval != readval) + { + printf("test register fail\n"); + LOG(WARNING) << "Acquisition test register sanity check failed"; + } + else + { + printf("test register success\n"); + LOG(INFO) << "Acquisition test register sanity check success !"; + } - d_nsamples = fft_size; - d_nsamples_total = nsamples_total; - d_select_queue = select_queue; + d_nsamples = fft_size; + d_nsamples_total = nsamples_total; + d_select_queue = select_queue; - gps_fpga_acquisition_8sc::configure_acquisition(); + gps_fpga_acquisition_8sc::configure_acquisition(); return true; } @@ -126,28 +126,28 @@ bool gps_fpga_acquisition_8sc::set_local_code(gr_complex* fft_codes) { - unsigned int i; - float max = 0; - d_fft_codes = new lv_16sc_t[d_nsamples_total]; + unsigned int i; + float max = 0; + d_fft_codes = new lv_16sc_t[d_nsamples_total]; - for (i=0;i max) - { - max = abs(fft_codes[i].real()); - } - if(abs(fft_codes[i].imag()) > max) - { - max = abs(fft_codes[i].imag()); - } - } + for (i=0;i max) + { + max = std::abs(fft_codes[i].real()); + } + if(std::abs(fft_codes[i].imag()) > max) + { + max = std::abs(fft_codes[i].imag()); + } + } - for (i=0;i