mirror of
https://github.com/gnss-sdr/gnss-sdr
synced 2025-01-06 07:20:34 +00:00
Remove some warnings
This commit is contained in:
parent
9fef3fbfe9
commit
74f08ede2f
@ -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<int>(doppler_max) + doppler_step * doppler_index;
|
||||
float phase_step_rad = GPS_TWO_PI * (freq + doppler) / static_cast<float>(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<int>(doppler_max) + doppler_step * doppler_index;
|
||||
float phase_step_rad = GPS_TWO_PI * (freq + doppler) / static_cast<float>(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<d_nsamples_total;i++)
|
||||
{
|
||||
if(abs(fft_codes[i].real()) > max)
|
||||
{
|
||||
max = abs(fft_codes[i].real());
|
||||
}
|
||||
if(abs(fft_codes[i].imag()) > max)
|
||||
{
|
||||
max = abs(fft_codes[i].imag());
|
||||
}
|
||||
}
|
||||
for (i=0;i<d_nsamples_total;i++)
|
||||
{
|
||||
if(std::abs(fft_codes[i].real()) > 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<d_nsamples_total;i++)
|
||||
{
|
||||
d_fft_codes[i] = lv_16sc_t((int) (fft_codes[i].real()*(pow(2,7) - 1)/max), (int) (fft_codes[i].imag()*(pow(2,7) - 1)/max));
|
||||
}
|
||||
for (i=0;i<d_nsamples_total;i++)
|
||||
{
|
||||
d_fft_codes[i] = lv_16sc_t((int) (fft_codes[i].real()*(pow(2,7) - 1)/max), (int) (fft_codes[i].imag()*(pow(2,7) - 1)/max));
|
||||
}
|
||||
|
||||
gps_fpga_acquisition_8sc::fpga_configure_acquisition_local_code(d_fft_codes);
|
||||
gps_fpga_acquisition_8sc::fpga_configure_acquisition_local_code(d_fft_codes);
|
||||
|
||||
return true;
|
||||
}
|
||||
@ -156,8 +156,6 @@ bool gps_fpga_acquisition_8sc::set_local_code(gr_complex* fft_codes)
|
||||
|
||||
gps_fpga_acquisition_8sc::gps_fpga_acquisition_8sc()
|
||||
{
|
||||
|
||||
|
||||
if ((d_fd = open(d_device_io_name, O_RDWR | O_SYNC )) == -1)
|
||||
{
|
||||
LOG(WARNING) << "Cannot open deviceio" << d_device_io_name;
|
||||
@ -168,17 +166,16 @@ gps_fpga_acquisition_8sc::gps_fpga_acquisition_8sc()
|
||||
{
|
||||
LOG(WARNING) << "Cannot map the FPGA acquisition module into user memory";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
gps_fpga_acquisition_8sc::~gps_fpga_acquisition_8sc()
|
||||
{
|
||||
|
||||
if (munmap((void*)d_map_base, PAGE_SIZE) == -1)
|
||||
{
|
||||
printf("Failed to unmap memory uio\n");
|
||||
}
|
||||
if (munmap((void*)d_map_base, PAGE_SIZE) == -1)
|
||||
{
|
||||
printf("Failed to unmap memory uio\n");
|
||||
}
|
||||
|
||||
close(d_fd);
|
||||
|
||||
@ -187,16 +184,16 @@ gps_fpga_acquisition_8sc::~gps_fpga_acquisition_8sc()
|
||||
|
||||
bool gps_fpga_acquisition_8sc::free()
|
||||
{
|
||||
if (d_fft_codes != nullptr)
|
||||
{
|
||||
delete [] d_fft_codes;
|
||||
d_fft_codes = nullptr;
|
||||
}
|
||||
if (d_phase_step_rad_vector != nullptr)
|
||||
{
|
||||
delete [] d_phase_step_rad_vector;
|
||||
d_phase_step_rad_vector = nullptr;
|
||||
}
|
||||
if (d_fft_codes != nullptr)
|
||||
{
|
||||
delete [] d_fft_codes;
|
||||
d_fft_codes = nullptr;
|
||||
}
|
||||
if (d_phase_step_rad_vector != nullptr)
|
||||
{
|
||||
delete [] d_phase_step_rad_vector;
|
||||
d_phase_step_rad_vector = nullptr;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
@ -204,43 +201,43 @@ bool gps_fpga_acquisition_8sc::free()
|
||||
|
||||
unsigned gps_fpga_acquisition_8sc::fpga_acquisition_test_register(unsigned writeval)
|
||||
{
|
||||
|
||||
unsigned readval;
|
||||
// write value to test register
|
||||
d_map_base[15] = writeval;
|
||||
// read value from test register
|
||||
readval = d_map_base[15];
|
||||
// return read value
|
||||
return readval;
|
||||
unsigned readval;
|
||||
// write value to test register
|
||||
d_map_base[15] = writeval;
|
||||
// read value from test register
|
||||
readval = d_map_base[15];
|
||||
// return read value
|
||||
return readval;
|
||||
}
|
||||
|
||||
|
||||
void gps_fpga_acquisition_8sc::fpga_configure_acquisition_local_code(lv_16sc_t fft_local_code[])
|
||||
{
|
||||
short int local_code;
|
||||
unsigned int k, tmp, tmp2;
|
||||
short int local_code;
|
||||
unsigned int k, tmp, tmp2;
|
||||
|
||||
// clear memory address counter
|
||||
d_map_base[4] = 0x10000000;
|
||||
for (k = 0; k < d_nsamples_total; k++)
|
||||
{
|
||||
tmp = fft_local_code[k].real();
|
||||
tmp2 = fft_local_code[k].imag();
|
||||
local_code = (tmp & 0xFF) | ((tmp2*256) & 0xFF00); // put together the real part and the imaginary part
|
||||
d_map_base[4] = 0x0C000000 | (local_code & 0xFFFF);
|
||||
}
|
||||
// clear memory address counter
|
||||
d_map_base[4] = 0x10000000;
|
||||
for (k = 0; k < d_nsamples_total; k++)
|
||||
{
|
||||
tmp = fft_local_code[k].real();
|
||||
tmp2 = fft_local_code[k].imag();
|
||||
local_code = (tmp & 0xFF) | ((tmp2*256) & 0xFF00); // put together the real part and the imaginary part
|
||||
d_map_base[4] = 0x0C000000 | (local_code & 0xFFFF);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
void gps_fpga_acquisition_8sc::run_acquisition(void)
|
||||
{
|
||||
// enable interrupts
|
||||
int reenable = 1;
|
||||
write(d_fd, (void *)&reenable, sizeof(int));
|
||||
// enable interrupts
|
||||
int reenable = 1;
|
||||
write(d_fd, (void *)&reenable, sizeof(int));
|
||||
|
||||
d_map_base[5] = 0; // writing anything to reg 4 launches the acquisition process
|
||||
d_map_base[5] = 0; // writing anything to reg 4 launches the acquisition process
|
||||
|
||||
int irq_count;
|
||||
int irq_count;
|
||||
ssize_t nb;
|
||||
// wait for interrupt
|
||||
nb=read(d_fd, &irq_count, sizeof(irq_count));
|
||||
@ -250,8 +247,6 @@ void gps_fpga_acquisition_8sc::run_acquisition(void)
|
||||
printf("Tracking_module Interrupt number %d\n", irq_count);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -260,51 +255,51 @@ void gps_fpga_acquisition_8sc::run_acquisition(void)
|
||||
void gps_fpga_acquisition_8sc::configure_acquisition()
|
||||
{
|
||||
|
||||
d_map_base[0] = d_select_queue;
|
||||
d_map_base[1] = d_nsamples_total;
|
||||
d_map_base[2] = d_nsamples;
|
||||
|
||||
|
||||
d_map_base[0] = d_select_queue;
|
||||
d_map_base[1] = d_nsamples_total;
|
||||
d_map_base[2] = d_nsamples;
|
||||
}
|
||||
|
||||
|
||||
void gps_fpga_acquisition_8sc::set_phase_step(unsigned int doppler_index)
|
||||
{
|
||||
float phase_step_rad_real;
|
||||
float phase_step_rad_int_temp;
|
||||
int32_t phase_step_rad_int;
|
||||
float phase_step_rad_real;
|
||||
float phase_step_rad_int_temp;
|
||||
int32_t phase_step_rad_int;
|
||||
|
||||
phase_step_rad_real = d_phase_step_rad_vector[doppler_index];
|
||||
phase_step_rad_real = d_phase_step_rad_vector[doppler_index];
|
||||
|
||||
phase_step_rad_int_temp = phase_step_rad_real*4; // * 2^2
|
||||
phase_step_rad_int = (int32_t) (phase_step_rad_int_temp*(536870912)); // * 2^29 (in total it makes x2^31 in two steps to avoid the warnings
|
||||
|
||||
d_map_base[3] = phase_step_rad_int;
|
||||
phase_step_rad_int_temp = phase_step_rad_real*4; // * 2^2
|
||||
phase_step_rad_int = (int32_t) (phase_step_rad_int_temp*(536870912)); // * 2^29 (in total it makes x2^31 in two steps to avoid the warnings
|
||||
|
||||
d_map_base[3] = phase_step_rad_int;
|
||||
}
|
||||
|
||||
void gps_fpga_acquisition_8sc::read_acquisition_results(uint32_t* max_index, float* max_magnitude, unsigned *initial_sample, float *power_sum)
|
||||
{
|
||||
unsigned readval = 0;
|
||||
readval = d_map_base[0];
|
||||
readval = d_map_base[1];
|
||||
*initial_sample = readval;
|
||||
readval = d_map_base[2];
|
||||
*max_magnitude = (float) readval;
|
||||
readval = d_map_base[4];
|
||||
*power_sum = (float) readval;
|
||||
readval = d_map_base[3];
|
||||
*max_index = readval;
|
||||
unsigned readval = 0;
|
||||
readval = d_map_base[0];
|
||||
readval = d_map_base[1];
|
||||
*initial_sample = readval;
|
||||
readval = d_map_base[2];
|
||||
*max_magnitude = (float) readval;
|
||||
readval = d_map_base[4];
|
||||
*power_sum = (float) readval;
|
||||
readval = d_map_base[3];
|
||||
*max_index = readval;
|
||||
|
||||
}
|
||||
|
||||
|
||||
void gps_fpga_acquisition_8sc::block_samples()
|
||||
{
|
||||
d_map_base[14] = 1; // block the samples
|
||||
d_map_base[14] = 1; // block the samples
|
||||
}
|
||||
|
||||
|
||||
void gps_fpga_acquisition_8sc::unblock_samples()
|
||||
{
|
||||
d_map_base[14] = 0; // unblock the samples
|
||||
d_map_base[14] = 0; // unblock the samples
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user