apply steve-m/librtlsdr/pull/64 (bias-t only)

master
Ondřej Hruška 3 years ago
parent 9fe533c949
commit bbe2e520d7
  1. 4
      .gitignore
  2. 9
      include/rtl-sdr.h
  3. 25
      src/librtlsdr.c
  4. 5
      src/rtl_biast.c

4
.gitignore vendored

@ -39,3 +39,7 @@ CMakeCache.txt
*/CMakeFiles
CMakeFiles
*.cmake
build/
cmake-build-*

@ -397,7 +397,14 @@ RTLSDR_API int rtlsdr_set_bias_tee(rtlsdr_dev_t *dev, int on);
*/
RTLSDR_API int rtlsdr_set_gpio(rtlsdr_dev_t *dev, int gpio_pin, int on);
/*!
* Control whether the bias tee is left on after rtlsdr_close() is called.
*
* \param dev the device handle given by rtlsdr_open()
* \param leave_on 1 to leave Bias T on upon library close; 0 otherwise
* \return -1 if device is not initialized. 0 otherwise.
*/
RTLSDR_API int rtlsdr_set_bias_tee_leave_on(rtlsdr_dev_t *dev, int leave_on);
#ifdef __cplusplus
}

@ -104,6 +104,8 @@ struct rtlsdr_dev {
enum rtlsdr_async_status async_status;
int async_cancel;
int use_zerocopy;
int keep_biast_on;
int biast_gpio;
/* rtl demod context */
uint32_t rate; /* Hz */
uint32_t rtl_xtal; /* Hz */
@ -1686,6 +1688,14 @@ int rtlsdr_close(rtlsdr_dev_t *dev)
rtlsdr_deinit_baseband(dev);
}
/*
* Disable bias-tee unless we're explicitly asked
* to keep it on.
*/
if (dev->keep_biast_on == 0) {
rtlsdr_set_bias_tee(dev, 0);
}
libusb_release_interface(dev->devh, 0);
#ifdef DETACH_KERNEL_DRIVER
@ -2060,8 +2070,12 @@ int rtlsdr_set_bias_tee(rtlsdr_dev_t *dev, int on)
if (!dev)
return -1;
if(dev->force_bt) on = 1; // If force_bt is on from the EEPROM, do not allow bias tee to turn off
if(dev->force_bt) {
on = 1; // If force_bt is on from the EEPROM, do not allow bias tee to turn off
dev->keep_biast_on = 1;
}
dev->biast_gpio = 0; // always 0?
rtlsdr_set_gpio_output(dev, 0);
rtlsdr_set_gpio_bit(dev, 0, on);
@ -2080,3 +2094,12 @@ int rtlsdr_set_gpio(rtlsdr_dev_t *dev, int gpio_pin, int on)
return 1;
}
int rtlsdr_set_bias_tee_leave_on(rtlsdr_dev_t *dev, int leave_on)
{
if (!dev)
return -1;
dev->keep_biast_on = leave_on;
return 0;
}

@ -112,7 +112,10 @@ int main(int argc, char **argv)
r = rtlsdr_open(&dev, dev_index);
rtlsdr_set_gpio(dev, gpio_pin, bias_on);
//dev->biast_gpio = gpio_pin;
rtlsdr_set_gpio(dev, gpio_pin, bias_on);
rtlsdr_set_bias_tee_leave_on(dev, 1);
//rtlsdr_set_bias_tee(dev, bias_on);
//rtlsdr_set_direct_sampling(dev, 1);

Loading…
Cancel
Save