1
0
mirror of https://github.com/gnss-sdr/gnss-sdr synced 2024-12-14 12:10:34 +00:00

code cleaning

This commit is contained in:
Carles Fernandez 2015-03-17 00:22:20 +01:00
parent 078260d83f
commit cb1fd9e727
6 changed files with 79 additions and 106 deletions

View File

@ -34,14 +34,11 @@
#include <string>
void
galileo_e1_code_gen_int(int* _dest, char _Signal[3], signed int _prn,
unsigned int _chip_shift)
void galileo_e1_code_gen_int(int* _dest, char _Signal[3], signed int _prn, unsigned int _chip_shift)
{
std::string _galileo_signal = _Signal;
signed int prn = _prn - 1;
int index = 0;
//int* dest = _dest;
/* A simple error check */
if ((_prn < 1) || (_prn > 50))
@ -53,8 +50,7 @@ galileo_e1_code_gen_int(int* _dest, char _Signal[3], signed int _prn,
{
for (size_t i = 0; i < Galileo_E1_B_PRIMARY_CODE[prn].length(); i++)
{
hex_to_binary_converter(&_dest[index],
Galileo_E1_B_PRIMARY_CODE[prn].at(i));
hex_to_binary_converter(&_dest[index], Galileo_E1_B_PRIMARY_CODE[prn].at(i));
index = index + 4;
}
@ -63,8 +59,7 @@ galileo_e1_code_gen_int(int* _dest, char _Signal[3], signed int _prn,
{
for (size_t i = 0; i < Galileo_E1_C_PRIMARY_CODE[prn].length(); i++)
{
hex_to_binary_converter(&_dest[index],
Galileo_E1_C_PRIMARY_CODE[prn].at(i));
hex_to_binary_converter(&_dest[index], Galileo_E1_C_PRIMARY_CODE[prn].at(i));
index = index + 4;
}
}
@ -76,29 +71,26 @@ galileo_e1_code_gen_int(int* _dest, char _Signal[3], signed int _prn,
void
galileo_e1_sinboc_11_gen(std::complex<float>* _dest, int* _prn,
unsigned int _length_out)
void galileo_e1_sinboc_11_gen(std::complex<float>* _dest, int* _prn, unsigned int _length_out)
{
const unsigned int _length_in = Galileo_E1_B_CODE_LENGTH_CHIPS;
unsigned int _period = (unsigned int) (_length_out / _length_in);
for (unsigned int i = 0; i < _length_in; i++)
{
for (unsigned int j = 0; j < (_period / 2); j++)
_dest[i * _period + j] = std::complex<float>((float) _prn[i],
0.0);
{
_dest[i * _period + j] = std::complex<float>((float) _prn[i], 0.0);
}
for (unsigned int j = (_period / 2); j < _period; j++)
_dest[i * _period + j] = std::complex<float>((float) (-_prn[i]),
0.0);
{
_dest[i * _period + j] = std::complex<float>((float) (- _prn[i]), 0.0);
}
}
}
void
galileo_e1_sinboc_61_gen(std::complex<float>* _dest, int* _prn,
unsigned int _length_out)
void galileo_e1_sinboc_61_gen(std::complex<float>* _dest, int* _prn, unsigned int _length_out)
{
const unsigned int _length_in = Galileo_E1_B_CODE_LENGTH_CHIPS;
unsigned int _period = (unsigned int) (_length_out / _length_in);
@ -106,18 +98,19 @@ galileo_e1_sinboc_61_gen(std::complex<float>* _dest, int* _prn,
for (unsigned int i = 0; i < _length_in; i++)
{
for (unsigned int j = 0; j < _period; j += 2)
_dest[i * _period + j] = std::complex<float>((float) _prn[i],
0.0);
{
_dest[i * _period + j] = std::complex<float>((float) _prn[i], 0.0);
}
for (unsigned int j = 1; j < _period; j += 2)
_dest[i * _period + j] = std::complex<float>((float) (-_prn[i]),
0.0);
{
_dest[i * _period + j] = std::complex<float>((float) (- _prn[i]), 0.0);
}
}
}
void
galileo_e1_gen(std::complex<float>* _dest, int* _prn, char _Signal[3])
void galileo_e1_gen(std::complex<float>* _dest, int* _prn, char _Signal[3])
{
std::string _galileo_signal = _Signal;
const unsigned int _codeLength = 12 * Galileo_E1_B_CODE_LENGTH_CHIPS;
@ -150,14 +143,11 @@ galileo_e1_gen(std::complex<float>* _dest, int* _prn, char _Signal[3])
void
galileo_e1_code_gen_complex_sampled(std::complex<float>* _dest, char _Signal[3],
void galileo_e1_code_gen_complex_sampled(std::complex<float>* _dest, char _Signal[3],
bool _cboc, unsigned int _prn, signed int _fs, unsigned int _chip_shift,
bool _secondary_flag)
{
// This function is based on the GNU software GPS for MATLAB in Kay Borre's book
std::string _galileo_signal = _Signal;
unsigned int _samplesPerCode;
const int _codeFreqBasis = Galileo_E1_CODE_CHIP_RATE_HZ; //Hz
@ -183,8 +173,7 @@ galileo_e1_code_gen_complex_sampled(std::complex<float>* _dest, char _Signal[3],
}
else
{
galileo_e1_sinboc_11_gen(_signal_E1, primary_code_E1_chips,
_codeLength); //generate sinboc(1,1) 2 samples per chip
galileo_e1_sinboc_11_gen(_signal_E1, primary_code_E1_chips, _codeLength); //generate sinboc(1,1) 2 samples per chip
}
if (_fs != _samplesPerChip * _codeFreqBasis)
@ -230,10 +219,8 @@ galileo_e1_code_gen_complex_sampled(std::complex<float>* _dest, char _Signal[3],
}
void
galileo_e1_code_gen_complex_sampled(std::complex<float>* _dest, char _Signal[3],
void galileo_e1_code_gen_complex_sampled(std::complex<float>* _dest, char _Signal[3],
bool _cboc, unsigned int _prn, signed int _fs, unsigned int _chip_shift)
{
galileo_e1_code_gen_complex_sampled(_dest, _Signal, _cboc, _prn,
_fs, _chip_shift, false);
galileo_e1_code_gen_complex_sampled(_dest, _Signal, _cboc, _prn, _fs, _chip_shift, false);
}

View File

@ -46,8 +46,7 @@ void galileo_e5_a_code_gen_complex_primary(std::complex<float>* _dest, signed in
{
for (size_t i = 0; i < Galileo_E5a_Q_PRIMARY_CODE[prn].length() - 1; i++)
{
hex_to_binary_converter(a,
Galileo_E5a_Q_PRIMARY_CODE[prn].at(i));
hex_to_binary_converter(a, Galileo_E5a_Q_PRIMARY_CODE[prn].at(i));
_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]));
@ -55,8 +54,7 @@ void galileo_e5_a_code_gen_complex_primary(std::complex<float>* _dest, signed in
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));
hex_to_binary_converter(a, Galileo_E5a_Q_PRIMARY_CODE[prn].at(Galileo_E5a_Q_PRIMARY_CODE[prn].length() - 1));
_dest[index] = std::complex<float>(float(0.0), a[0]);
_dest[index + 1] = std::complex<float>(float(0.0), a[1]);
}
@ -64,8 +62,7 @@ void galileo_e5_a_code_gen_complex_primary(std::complex<float>* _dest, signed in
{
for (size_t i = 0; i < Galileo_E5a_I_PRIMARY_CODE[prn].length() - 1; i++)
{
hex_to_binary_converter(a,
Galileo_E5a_I_PRIMARY_CODE[prn].at(i));
hex_to_binary_converter(a, Galileo_E5a_I_PRIMARY_CODE[prn].at(i));
_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);
@ -73,8 +70,7 @@ void galileo_e5_a_code_gen_complex_primary(std::complex<float>* _dest, signed in
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(a, Galileo_E5a_I_PRIMARY_CODE[prn].at(Galileo_E5a_I_PRIMARY_CODE[prn].length() - 1));
_dest[index] = std::complex<float>(float(a[0]), 0.0);
_dest[index + 1] = std::complex<float>(float(a[1]), 0.0);
}
@ -83,10 +79,8 @@ void galileo_e5_a_code_gen_complex_primary(std::complex<float>* _dest, signed in
int b[4];
for (size_t i = 0; i < Galileo_E5a_I_PRIMARY_CODE[prn].length() - 1; i++)
{
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));
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]));
@ -94,10 +88,8 @@ void galileo_e5_a_code_gen_complex_primary(std::complex<float>* _dest, signed in
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));
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));
_dest[index] = std::complex<float>(float(a[0]), float(b[0]));
_dest[index + 1] = std::complex<float>(float(a[1]), float(b[1]));
}
@ -107,13 +99,11 @@ void galileo_e5_a_code_gen_complex_sampled(std::complex<float>* _dest, char _Sig
unsigned int _prn, signed int _fs, unsigned int _chip_shift)
{
// This function is based on the GNU software GPS for MATLAB in the Kay Borre book
unsigned int _samplesPerCode;
unsigned int delay;
unsigned int _codeLength = Galileo_E5a_CODE_LENGTH_CHIPS;
const int _codeFreqBasis = Galileo_E5a_CODE_CHIP_RATE_HZ; //Hz
std::complex<float>* _code;
_code = new std::complex<float>[_codeLength];
@ -121,16 +111,13 @@ void galileo_e5_a_code_gen_complex_sampled(std::complex<float>* _dest, char _Sig
_samplesPerCode = round(_fs / (_codeFreqBasis / _codeLength));
delay = ((_codeLength - _chip_shift)
% _codeLength) * _samplesPerCode / _codeLength;
delay = ((_codeLength - _chip_shift) % _codeLength) * _samplesPerCode / _codeLength;
if (_fs != _codeFreqBasis)
{
std::complex<float>* _resampled_signal;
if (posix_memalign((void**)&_resampled_signal, 16, _samplesPerCode * sizeof(gr_complex)) == 0){};
resampler(_code, _resampled_signal, _codeFreqBasis, _fs,
_codeLength, _samplesPerCode); //resamples code to fs
resampler(_code, _resampled_signal, _codeFreqBasis, _fs, _codeLength, _samplesPerCode); //resamples code to fs
delete[] _code;
_code = _resampled_signal;
}
@ -141,5 +128,4 @@ void galileo_e5_a_code_gen_complex_sampled(std::complex<float>* _dest, char _Sig
}
free(_code);
}