aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJon Szymaniak <jon.szymaniak@gmail.com>2014-01-11 21:46:01 -0500
committerDimitri Stolnikov <horiz0n@gmx.net>2014-01-26 17:18:45 +0100
commitcd384138034582b7d1b3123287c3ed1feab45642 (patch)
tree09225a065c08f5d24ffb28b6908490f47129e893
parent43af3a851e9c1b5270ad02e607b872d7cb8505c1 (diff)
bladerf: Removed sign extension and masking of samples
This is no longer required as of FPGA v0.0.1, and has been removed to remove some unnecessary computation on samples.
-rw-r--r--lib/bladerf/bladerf_source_c.cc27
1 files changed, 17 insertions, 10 deletions
diff --git a/lib/bladerf/bladerf_source_c.cc b/lib/bladerf/bladerf_source_c.cc
index 578d981..bf0f0a1 100644
--- a/lib/bladerf/bladerf_source_c.cc
+++ b/lib/bladerf/bladerf_source_c.cc
@@ -85,6 +85,7 @@ bladerf_source_c::bladerf_source_c (const std::string &args)
int ret;
size_t fifo_size;
std::string device_name;
+ struct bladerf_version fpga_version;
dict_t dict = params_to_dict(args);
@@ -140,6 +141,19 @@ bladerf_source_c::bladerf_source_c (const std::string &args)
/* Set the range of VGA2 VGA2GAIN[4:0], not recommended to be used above 30dB */
_vga2_range = osmosdr::gain_range_t( 0, 60, 3 );
+
+ /* Warn user about using an old FPGA version, as we no longer strip off the
+ * markers that were pressent in the pre-v0.0.1 FPGA */
+ if (bladerf_fpga_version( _dev.get(), &fpga_version ) != 0) {
+ std::cerr << _pfx << "Failed to get FPGA version" << std::endl;
+ } else if ( fpga_version.major <= 0 &&
+ fpga_version.minor <= 0 &&
+ fpga_version.patch < 1 ) {
+
+ std::cerr << _pfx << "Warning: FPGA version v0.0.1 or later is required. "
+ << "Using an earlier FPGA version will result in misinterpeted samples. "
+ << std::endl;
+ }
}
/*
@@ -187,6 +201,7 @@ void *bladerf_source_c::stream_task( void *samples, size_t num_samples )
size_t i, n_avail, to_copy;
int16_t *sample = (int16_t *)samples;
void *ret;
+ const float scaling = 1.0f / 2048.0f;
ret = _buffers[_buf_index];
_buf_index = (_buf_index + 1) % _num_buffers;
@@ -197,17 +212,9 @@ void *bladerf_source_c::stream_task( void *samples, size_t num_samples )
to_copy = (n_avail < num_samples ? n_avail : num_samples);
for(i = 0; i < to_copy; i++ ) {
- /* Mask valid bits only */
- *(sample) &= 0xfff;
- *(sample+1) &= 0xfff;
-
- /* Sign extend the 12-bit IQ values, if needed */
- if( (*sample) & 0x800 ) *(sample) |= 0xf000;
- if( *(sample+1) & 0x800 ) *(sample+1) |= 0xf000;
-
/* Push sample to the fifo */
- _fifo->push_back( gr_complex( *sample * (1.0f/2048.0f),
- *(sample+1) * (1.0f/2048.0f) ) );
+ _fifo->push_back( gr_complex( *sample * scaling,
+ *(sample+1) * scaling) );
/* offset to the next I+Q sample */
sample += 2;