lib: Add GPIO version of the bias tee configuration API

rtl_biast allows for non-default GPIO pins to be used.
Add an API call which allows for that.

(cherry picked from commit 5d0735f5dfe276203261b8bcd3817341d4630ab2)
fixed conflicts

Signed-off-by: hayati ayguen <h_ayguen@web.de>
development
hayati ayguen 2020-08-19 15:06:55 -07:00
parent a88dee8482
commit 284b415ec3
2 changed files with 18 additions and 3 deletions

View File

@ -535,6 +535,16 @@ RTLSDR_API int rtlsdr_ir_query(rtlsdr_dev_t *dev, uint8_t *buf, size_t buf_len);
*/ */
RTLSDR_API int rtlsdr_set_bias_tee(rtlsdr_dev_t *dev, int on); RTLSDR_API int rtlsdr_set_bias_tee(rtlsdr_dev_t *dev, int on);
/*!
* Enable or disable the bias tee on the given GPIO pin.
*
* \param dev the device handle given by rtlsdr_open()
* \param gpio the gpio pin to configure as a Bias T control.
* \param on 1 for Bias T on. 0 for Bias T off.
* \return -1 if device is not initialized. 0 otherwise.
*/
RTLSDR_API int rtlsdr_set_bias_tee_gpio(rtlsdr_dev_t *dev, int gpio, int on);
/*! /*!
* Sets multiple options from a string encoded like "bw=300:agc=0:gain=27.3:dagc=0:T=1". * Sets multiple options from a string encoded like "bw=300:agc=0:gain=27.3:dagc=0:T=1".
* this is a helper function, that programs don't need to implement every single option * this is a helper function, that programs don't need to implement every single option

View File

@ -3821,18 +3821,23 @@ err:
return ret; return ret;
} }
int rtlsdr_set_bias_tee(rtlsdr_dev_t *dev, int on) int rtlsdr_set_bias_tee_gpio(rtlsdr_dev_t *dev, int gpio, int on)
{ {
if (!dev) if (!dev)
return -1; return -1;
rtlsdr_set_gpio_output(dev, 0); rtlsdr_set_gpio_output(dev, gpio);
rtlsdr_set_gpio_bit(dev, 0, on); rtlsdr_set_gpio_bit(dev, gpio, on);
reactivate_softagc(dev, SOFTSTATE_RESET); reactivate_softagc(dev, SOFTSTATE_RESET);
return 0; return 0;
} }
int rtlsdr_set_bias_tee(rtlsdr_dev_t *dev, int on)
{
return rtlsdr_set_bias_tee_gpio(dev, 0, on);
}
const char * rtlsdr_get_opt_help(int longInfo) const char * rtlsdr_get_opt_help(int longInfo)
{ {