1
0
mirror of https://github.com/gnss-sdr/gnss-sdr synced 2024-12-16 05:00:35 +00:00
gnss-sdr/src/algorithms/libs/galileo_e5_signal_processing.cc

138 lines
6.2 KiB
C++
Raw Normal View History

2014-05-21 07:42:26 +00:00
/*!
* \file galileo_e5_signal_processing.cc
2014-05-21 07:42:26 +00:00
* \brief This library implements various functions for Galileo E5 signals such
* as replica code generation
* \author Marc Sales, 2014. marcsales92(at)gmail.com
*
2014-05-21 07:42:26 +00:00
* Detailed description of the file here if needed.
*
* -------------------------------------------------------------------------
*
* Copyright (C) 2010-2018 (see AUTHORS file for a list of contributors)
2014-05-21 07:42:26 +00:00
*
* GNSS-SDR is a software defined Global Navigation
* Satellite Systems receiver
*
* This file is part of GNSS-SDR.
*
* GNSS-SDR is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
2015-01-08 18:49:59 +00:00
* (at your option) any later version.
2014-05-21 07:42:26 +00:00
*
* GNSS-SDR is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with GNSS-SDR. If not, see <https://www.gnu.org/licenses/>.
2014-05-21 07:42:26 +00:00
*
* -------------------------------------------------------------------------
*/
#include "galileo_e5_signal_processing.h"
2016-01-10 21:21:31 +00:00
#include "Galileo_E5a.h"
#include "gnss_signal_processing.h"
#include <gnuradio/gr_complex.h>
#include <array>
#include <memory>
2016-01-10 21:21:31 +00:00
2019-06-29 11:57:00 +00:00
void galileo_e5_a_code_gen_complex_primary(gsl::span<std::complex<float>> _dest, int32_t _prn, const std::array<char, 3>& _Signal)
{
uint32_t prn = _prn - 1;
uint32_t index = 0;
std::array<int32_t, 4> a{};
if ((_prn < 1) || (_prn > 50))
2016-05-02 21:46:30 +00:00
{
return;
}
2015-03-16 23:22:20 +00:00
if (_Signal[0] == '5' && _Signal[1] == 'Q')
2016-05-02 21:46:30 +00:00
{
for (size_t i = 0; i < GALILEO_E5A_Q_PRIMARY_CODE[prn].length() - 1; i++)
2016-05-02 21:46:30 +00:00
{
hex_to_binary_converter(a, GALILEO_E5A_Q_PRIMARY_CODE[prn].at(i));
2016-05-02 21:46:30 +00:00
_dest[index] = std::complex<float>(0.0, float(a[0]));
_dest[index + 1] = std::complex<float>(0.0, float(a[1]));
_dest[index + 2] = std::complex<float>(0.0, float(a[2]));
_dest[index + 3] = std::complex<float>(0.0, float(a[3]));
index = index + 4;
}
// last 2 bits are filled up zeros
hex_to_binary_converter(a, GALILEO_E5A_Q_PRIMARY_CODE[prn].at(GALILEO_E5A_Q_PRIMARY_CODE[prn].length() - 1));
2016-05-02 21:46:30 +00:00
_dest[index] = std::complex<float>(float(0.0), a[0]);
_dest[index + 1] = std::complex<float>(float(0.0), a[1]);
}
2015-03-16 23:22:20 +00:00
else if (_Signal[0] == '5' && _Signal[1] == 'I')
2016-05-02 21:46:30 +00:00
{
for (size_t i = 0; i < GALILEO_E5A_I_PRIMARY_CODE[prn].length() - 1; i++)
2016-05-02 21:46:30 +00:00
{
hex_to_binary_converter(a, GALILEO_E5A_I_PRIMARY_CODE[prn].at(i));
2016-05-02 21:46:30 +00:00
_dest[index] = std::complex<float>(float(a[0]), 0.0);
_dest[index + 1] = std::complex<float>(float(a[1]), 0.0);
_dest[index + 2] = std::complex<float>(float(a[2]), 0.0);
_dest[index + 3] = std::complex<float>(float(a[3]), 0.0);
index = index + 4;
}
// last 2 bits are filled up zeros
hex_to_binary_converter(a, GALILEO_E5A_I_PRIMARY_CODE[prn].at(GALILEO_E5A_I_PRIMARY_CODE[prn].length() - 1));
2016-05-02 21:46:30 +00:00
_dest[index] = std::complex<float>(float(a[0]), 0.0);
_dest[index + 1] = std::complex<float>(float(a[1]), 0.0);
}
2015-03-16 23:22:20 +00:00
else if (_Signal[0] == '5' && _Signal[1] == 'X')
2016-05-02 21:46:30 +00:00
{
std::array<int32_t, 4> b{};
for (size_t i = 0; i < GALILEO_E5A_I_PRIMARY_CODE[prn].length() - 1; i++)
2016-05-02 21:46:30 +00:00
{
hex_to_binary_converter(a, GALILEO_E5A_I_PRIMARY_CODE[prn].at(i));
hex_to_binary_converter(b, GALILEO_E5A_Q_PRIMARY_CODE[prn].at(i));
_dest[index] = std::complex<float>(float(a[0]), float(b[0]));
_dest[index + 1] = std::complex<float>(float(a[1]), float(b[1]));
_dest[index + 2] = std::complex<float>(float(a[2]), float(b[2]));
_dest[index + 3] = std::complex<float>(float(a[3]), float(b[3]));
2016-05-02 21:46:30 +00:00
index = index + 4;
}
// last 2 bits are filled up zeros
hex_to_binary_converter(a, GALILEO_E5A_I_PRIMARY_CODE[prn].at(GALILEO_E5A_I_PRIMARY_CODE[prn].length() - 1));
hex_to_binary_converter(b, GALILEO_E5A_Q_PRIMARY_CODE[prn].at(GALILEO_E5A_Q_PRIMARY_CODE[prn].length() - 1));
2016-05-02 21:46:30 +00:00
_dest[index] = std::complex<float>(float(a[0]), float(b[0]));
_dest[index + 1] = std::complex<float>(float(a[1]), float(b[1]));
}
}
2019-06-29 11:57:00 +00:00
void galileo_e5_a_code_gen_complex_sampled(gsl::span<std::complex<float>> _dest, const std::array<char, 3>& _Signal,
uint32_t _prn, int32_t _fs, uint32_t _chip_shift)
{
uint32_t _samplesPerCode;
uint32_t delay;
const uint32_t _codeLength = GALILEO_E5A_CODE_LENGTH_CHIPS;
const int32_t _codeFreqBasis = GALILEO_E5A_CODE_CHIP_RATE_HZ;
std::unique_ptr<std::complex<float>> _code{new std::complex<float>[_codeLength]};
2019-06-29 10:55:39 +00:00
gsl::span<std::complex<float>> _code_span(_code, _codeLength);
galileo_e5_a_code_gen_complex_primary(_code_span, _prn, _Signal);
_samplesPerCode = static_cast<uint32_t>(static_cast<double>(_fs) / (static_cast<double>(_codeFreqBasis) / static_cast<double>(_codeLength)));
2014-08-05 00:01:37 +00:00
2015-03-16 23:22:20 +00:00
delay = ((_codeLength - _chip_shift) % _codeLength) * _samplesPerCode / _codeLength;
if (_fs != _codeFreqBasis)
{
std::unique_ptr<std::complex<float>> _resampled_signal{new std::complex<float>[_samplesPerCode]};
2019-06-29 10:55:39 +00:00
resampler(_code_span, gsl::span<std::complex<float>>(_resampled_signal, _samplesPerCode), _codeFreqBasis, _fs); // resamples code to fs
_code = std::move(_resampled_signal);
}
2019-06-29 15:29:51 +00:00
uint32_t size_code = _codeLength;
if (_fs != _codeFreqBasis)
{
size_code = _samplesPerCode;
}
gsl::span<std::complex<float>> _code_span_aux(_code, size_code);
for (uint32_t i = 0; i < _samplesPerCode; i++)
{
2019-06-29 15:29:51 +00:00
_dest[(i + delay) % _samplesPerCode] = _code_span_aux[i];
}
}