Skip to content

Commit

Permalink
bladeRF: 8bit source support
Browse files Browse the repository at this point in the history
The gnuradio sink now receives 8bit samples. Meta mode is currently
not working with 8bit mode.
  • Loading branch information
rthomp10 authored and rghilduta committed Feb 14, 2023
1 parent 226dac9 commit af95b97
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
10 changes: 7 additions & 3 deletions lib/bladerf/bladerf_source_c.cc
Original file line number Diff line number Diff line change
Expand Up @@ -331,9 +331,13 @@ int bladerf_source_c::work(int noutput_items,

// convert from int16_t to float
// output_items is gr_complex (2x float), so num_points is 2*noutput_items
volk_16i_s32f_convert_32f(reinterpret_cast<float *>(_32fcbuf), _16icbuf,
SCALING_FACTOR_SC16_Q11, 2*noutput_items);

if (_format == BLADERF_FORMAT_SC8_Q7 || _format == BLADERF_FORMAT_SC8_Q7_META) {
volk_8i_s32f_convert_32f(reinterpret_cast<float *>(_32fcbuf), (int8_t*)_16icbuf,
SCALING_FACTOR_SC8_Q7, 2*noutput_items);
} else {
volk_16i_s32f_convert_32f(reinterpret_cast<float *>(_32fcbuf), _16icbuf,
SCALING_FACTOR_SC16_Q11, 2*noutput_items);
}
// copy the samples into output_items
gr_complex **out = reinterpret_cast<gr_complex **>(&output_items[0]);

Expand Down
1 change: 1 addition & 0 deletions lib/bladerf/bladerf_source_c.h
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@ class bladerf_source_c :

/* Scaling factor used when converting from int16_t to float */
const float SCALING_FACTOR_SC16_Q11 = 2048.0f;
const float SCALING_FACTOR_SC8_Q7 = 127.0f;
};

#endif // INCLUDED_BLADERF_SOURCE_C_H

0 comments on commit af95b97

Please sign in to comment.