|
|
|
@ -581,6 +581,7 @@ void rtlsdr_set_gpio_output(rtlsdr_dev_t *dev, uint8_t gpio) |
|
|
|
|
|
|
|
|
|
void rtlsdr_set_i2c_repeater(rtlsdr_dev_t *dev, int on) |
|
|
|
|
{ |
|
|
|
|
on = !!on; /* values +2 to force on */ |
|
|
|
|
rtlsdr_demod_write_reg(dev, 1, 0x01, on ? 0x18 : 0x10, 1); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -2016,16 +2017,34 @@ uint32_t rtlsdr_get_tuner_clock(void *dev) |
|
|
|
|
|
|
|
|
|
int rtlsdr_i2c_write_fn(void *dev, uint8_t addr, uint8_t *buf, int len) |
|
|
|
|
{ |
|
|
|
|
if (dev) |
|
|
|
|
return rtlsdr_i2c_write(((rtlsdr_dev_t *)dev), addr, buf, len); |
|
|
|
|
int r; |
|
|
|
|
int retries = 2; |
|
|
|
|
if (!dev) |
|
|
|
|
return -1; |
|
|
|
|
do { |
|
|
|
|
r = rtlsdr_i2c_write(((rtlsdr_dev_t *)dev), addr, buf, len); |
|
|
|
|
if (r >= 0) |
|
|
|
|
return r; |
|
|
|
|
rtlsdr_set_i2c_repeater(dev, 2); |
|
|
|
|
retries--; |
|
|
|
|
} while (retries > 0); |
|
|
|
|
|
|
|
|
|
return -1; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
int rtlsdr_i2c_read_fn(void *dev, uint8_t addr, uint8_t *buf, int len) |
|
|
|
|
{ |
|
|
|
|
if (dev) |
|
|
|
|
return rtlsdr_i2c_read(((rtlsdr_dev_t *)dev), addr, buf, len); |
|
|
|
|
int r; |
|
|
|
|
int retries = 2; |
|
|
|
|
if (!dev) |
|
|
|
|
return -1; |
|
|
|
|
do { |
|
|
|
|
r = rtlsdr_i2c_read(((rtlsdr_dev_t *)dev), addr, buf, len); |
|
|
|
|
if (r >= 0) |
|
|
|
|
return r; |
|
|
|
|
rtlsdr_set_i2c_repeater(dev, 2); |
|
|
|
|
retries--; |
|
|
|
|
} while (retries > 0); |
|
|
|
|
|
|
|
|
|
return -1; |
|
|
|
|
} |
|
|
|
|