hackrf: introduce bias=0|1 and bias_tx=0|1 parameters
... to support antenna/phantom power via a new device argument "bias" (to match Airspy's existing bias power syntax). 0=disable and 1=enable. I also added a device argument to control bias power at transmit time. I named this option differently - "bias_tx" - to avoid accidentally enabling bias power in transmit mode when an LNA may be attached in an input amplifier configuration. Original patch provided by Brad Hein
This commit is contained in:
parent
44c223cb5d
commit
5943919828
|
@ -253,7 +253,7 @@ Lines ending with ... mean it's possible to bind devices together by specifying
|
||||||
sdr-iq=/dev/ttyUSB0
|
sdr-iq=/dev/ttyUSB0
|
||||||
airspy=0[,bias=0|1]
|
airspy=0[,bias=0|1]
|
||||||
#end if
|
#end if
|
||||||
hackrf=0[,buffers=32]
|
hackrf=0[,buffers=32][,bias=0|1][,bias_tx=0|1]
|
||||||
bladerf=0[,fpga='/path/to/the/bitstream.rbf']
|
bladerf=0[,fpga='/path/to/the/bitstream.rbf']
|
||||||
uhd[,serial=...][,lo_offset=0][,mcr=52e6][,nchan=2][,subdev='\\\\'B:0 A:0\\\\''] ...
|
uhd[,serial=...][,lo_offset=0][,mcr=52e6][,nchan=2][,subdev='\\\\'B:0 A:0\\\\''] ...
|
||||||
|
|
||||||
|
|
|
@ -56,6 +56,10 @@ using namespace boost::assign;
|
||||||
|
|
||||||
#define BYTES_PER_SAMPLE 2 /* HackRF device consumes 8 bit unsigned IQ data */
|
#define BYTES_PER_SAMPLE 2 /* HackRF device consumes 8 bit unsigned IQ data */
|
||||||
|
|
||||||
|
#define HACKRF_FORMAT_ERROR(ret) \
|
||||||
|
boost::str( boost::format("(%d) %s") \
|
||||||
|
% ret % hackrf_error_name((enum hackrf_error)ret) ) \
|
||||||
|
|
||||||
#define HACKRF_THROW_ON_ERROR(ret, msg) \
|
#define HACKRF_THROW_ON_ERROR(ret, msg) \
|
||||||
if ( ret != HACKRF_SUCCESS ) \
|
if ( ret != HACKRF_SUCCESS ) \
|
||||||
throw std::runtime_error( boost::str( boost::format(msg " (%d) %s") \
|
throw std::runtime_error( boost::str( boost::format(msg " (%d) %s") \
|
||||||
|
@ -218,6 +222,20 @@ hackrf_sink_c::hackrf_sink_c (const std::string &args)
|
||||||
|
|
||||||
set_if_gain( 16 ); /* preset to a reasonable default (non-GRC use case) */
|
set_if_gain( 16 ); /* preset to a reasonable default (non-GRC use case) */
|
||||||
|
|
||||||
|
// Check device args to find out if bias/phantom power is desired.
|
||||||
|
if ( dict.count("bias_tx") ) {
|
||||||
|
bool bias = boost::lexical_cast<bool>( dict["bias_tx"] );
|
||||||
|
ret = hackrf_set_antenna_enable(_dev, static_cast<uint8_t>(bias));
|
||||||
|
if ( ret != HACKRF_SUCCESS )
|
||||||
|
{
|
||||||
|
std::cerr << "Failed to apply antenna bias voltage state: " << bias << " " << HACKRF_FORMAT_ERROR(ret) << std::endl;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
std::cerr << (bias ? "Enabled" : "Disabled") << " antenna bias voltage" << std::endl;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
_buf = (char *) malloc( BUF_LEN );
|
_buf = (char *) malloc( BUF_LEN );
|
||||||
|
|
||||||
cb_init( &_cbuf, _buf_num, BUF_LEN );
|
cb_init( &_cbuf, _buf_num, BUF_LEN );
|
||||||
|
|
|
@ -49,6 +49,10 @@ using namespace boost::assign;
|
||||||
|
|
||||||
#define BYTES_PER_SAMPLE 2 /* HackRF device produces 8 bit unsigned IQ data */
|
#define BYTES_PER_SAMPLE 2 /* HackRF device produces 8 bit unsigned IQ data */
|
||||||
|
|
||||||
|
#define HACKRF_FORMAT_ERROR(ret) \
|
||||||
|
boost::str( boost::format("(%d) %s") \
|
||||||
|
% ret % hackrf_error_name((enum hackrf_error)ret) ) \
|
||||||
|
|
||||||
#define HACKRF_THROW_ON_ERROR(ret, msg) \
|
#define HACKRF_THROW_ON_ERROR(ret, msg) \
|
||||||
if ( ret != HACKRF_SUCCESS ) \
|
if ( ret != HACKRF_SUCCESS ) \
|
||||||
throw std::runtime_error( boost::str( boost::format(msg " (%d) %s") \
|
throw std::runtime_error( boost::str( boost::format(msg " (%d) %s") \
|
||||||
|
@ -174,6 +178,20 @@ hackrf_source_c::hackrf_source_c (const std::string &args)
|
||||||
|
|
||||||
set_bb_gain( 20 ); /* preset to a reasonable default (non-GRC use case) */
|
set_bb_gain( 20 ); /* preset to a reasonable default (non-GRC use case) */
|
||||||
|
|
||||||
|
// Check device args to find out if bias/phantom power is desired.
|
||||||
|
if ( dict.count("bias") ) {
|
||||||
|
bool bias = boost::lexical_cast<bool>( dict["bias"] );
|
||||||
|
ret = hackrf_set_antenna_enable(_dev, static_cast<uint8_t>(bias));
|
||||||
|
if ( ret != HACKRF_SUCCESS )
|
||||||
|
{
|
||||||
|
std::cerr << "Failed to apply antenna bias voltage state: " << bias << " " << HACKRF_FORMAT_ERROR(ret) << std::endl;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
std::cerr << (bias ? "Enabled" : "Disabled") << " antenna bias voltage" << std::endl;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
_buf = (unsigned short **) malloc(_buf_num * sizeof(unsigned short *));
|
_buf = (unsigned short **) malloc(_buf_num * sizeof(unsigned short *));
|
||||||
|
|
||||||
if (_buf) {
|
if (_buf) {
|
||||||
|
|
Loading…
Reference in New Issue