hackrf: add fractional sample rate support introduced in libhackrf

d9c46cbdac
standalone
Dimitri Stolnikov 10 years ago
parent 40483d09c8
commit 40fb250e8f
  1. 9
      lib/hackrf/hackrf_sink_c.cc
  2. 9
      lib/hackrf/hackrf_source_c.cc

@ -474,6 +474,10 @@ osmosdr::meta_range_t hackrf_sink_c::get_sample_rates()
{
osmosdr::meta_range_t range;
/* we only add integer rates here because of better phase noise performance.
* the user is allowed to request arbitrary (fractional) rates within these
* boundaries. */
range += osmosdr::range_t( 8e6 );
range += osmosdr::range_t( 10e6 );
range += osmosdr::range_t( 12.5e6 );
@ -488,12 +492,13 @@ double hackrf_sink_c::set_sample_rate( double rate )
int ret;
if (_dev) {
ret = hackrf_sample_rate_set( _dev, uint32_t(rate) );
//ret = hackrf_sample_rate_set( _dev, uint32_t(rate) );
ret = hackrf_set_fracrate( _dev, float(rate/1e6) );
if ( HACKRF_SUCCESS == ret ) {
_sample_rate = rate;
set_bandwidth( rate );
} else {
HACKRF_THROW_ON_ERROR( ret, HACKRF_FUNC_STR( "hackrf_sample_rate_set", rate ) )
HACKRF_THROW_ON_ERROR( ret, HACKRF_FUNC_STR( "hackrf_set_fracrate", rate ) )
}
}

@ -366,6 +366,10 @@ osmosdr::meta_range_t hackrf_source_c::get_sample_rates()
{
osmosdr::meta_range_t range;
/* we only add integer rates here because of better phase noise performance.
* the user is allowed to request arbitrary (fractional) rates within these
* boundaries. */
range += osmosdr::range_t( 8e6 );
range += osmosdr::range_t( 10e6 );
range += osmosdr::range_t( 12.5e6 );
@ -380,12 +384,13 @@ double hackrf_source_c::set_sample_rate( double rate )
int ret;
if (_dev) {
ret = hackrf_sample_rate_set( _dev, uint32_t(rate) );
//ret = hackrf_sample_rate_set( _dev, uint32_t(rate) );
ret = hackrf_set_fracrate( _dev, float(rate/1e6) );
if ( HACKRF_SUCCESS == ret ) {
_sample_rate = rate;
set_bandwidth( rate );
} else {
HACKRF_THROW_ON_ERROR( ret, HACKRF_FUNC_STR( "hackrf_sample_rate_set", rate ) )
HACKRF_THROW_ON_ERROR( ret, HACKRF_FUNC_STR( "hackrf_set_fracrate", rate ) )
}
}

Loading…
Cancel
Save