disable second ADC in IF mode, make input selectable in DS-mode

Signed-off-by: Steve Markgraf <steve@steve-m.de>
master
Steve Markgraf 12 years ago
parent 519406264c
commit 01d8d308fc
  1. 2
      include/rtl-sdr.h
  2. 18
      src/librtlsdr.c

@ -236,7 +236,7 @@ RTLSDR_API int rtlsdr_set_agc_mode(rtlsdr_dev_t *dev, int on);
* (xtal frequency of the RTL2832). * (xtal frequency of the RTL2832).
* *
* \param dev the device handle given by rtlsdr_open() * \param dev the device handle given by rtlsdr_open()
* \param direct sampling mode, 1 means enabled, 0 disabled * \param on 0 means disabled, 1 I-ADC input enabled, 2 Q-ADC input enabled
* \return 0 on success * \return 0 on success
*/ */
RTLSDR_API int rtlsdr_set_direct_sampling(rtlsdr_dev_t *dev, int on); RTLSDR_API int rtlsdr_set_direct_sampling(rtlsdr_dev_t *dev, int on);

@ -955,6 +955,13 @@ int rtlsdr_set_direct_sampling(rtlsdr_dev_t *dev, int on)
/* disable spectrum inversion */ /* disable spectrum inversion */
r |= rtlsdr_demod_write_reg(dev, 1, 0x15, 0x00, 1); r |= rtlsdr_demod_write_reg(dev, 1, 0x15, 0x00, 1);
/* only enable In-phase ADC input */
r |= rtlsdr_demod_write_reg(dev, 0, 0x08, 0x4d, 1);
/* swap I and Q ADC, this allows to select between two inputs */
if (on > 1)
r |= rtlsdr_demod_write_reg(dev, 0, 0x06, 0x90, 1);
fprintf(stderr, "Enabled direct sampling mode\n"); fprintf(stderr, "Enabled direct sampling mode\n");
dev->direct_sampling = 1; dev->direct_sampling = 1;
} else { } else {
@ -970,10 +977,16 @@ int rtlsdr_set_direct_sampling(rtlsdr_dev_t *dev, int on)
/* enable spectrum inversion */ /* enable spectrum inversion */
r |= rtlsdr_demod_write_reg(dev, 1, 0x15, 0x01, 1); r |= rtlsdr_demod_write_reg(dev, 1, 0x15, 0x01, 1);
} else { } else {
/* enable In-phase + Quadrature ADC input */
r |= rtlsdr_demod_write_reg(dev, 0, 0x08, 0xcd, 1);
/* Enable Zero-IF mode */ /* Enable Zero-IF mode */
rtlsdr_demod_write_reg(dev, 1, 0xb1, 0x1b, 1); r |= rtlsdr_demod_write_reg(dev, 1, 0xb1, 0x1b, 1);
} }
/* opt_adc_iq = 0, default ADC_I/ADC_Q datapath */
r |= rtlsdr_demod_write_reg(dev, 0, 0x06, 0x80, 1);
fprintf(stderr, "Disabled direct sampling mode\n"); fprintf(stderr, "Disabled direct sampling mode\n");
dev->direct_sampling = 0; dev->direct_sampling = 0;
} }
@ -1193,6 +1206,9 @@ int rtlsdr_open(rtlsdr_dev_t **out_dev, uint32_t index)
/* disable Zero-IF mode */ /* disable Zero-IF mode */
rtlsdr_demod_write_reg(dev, 1, 0xb1, 0x1a, 1); rtlsdr_demod_write_reg(dev, 1, 0xb1, 0x1a, 1);
/* only enable In-phase ADC input */
rtlsdr_demod_write_reg(dev, 0, 0x08, 0x4d, 1);
/* the R820T uses 3.57 MHz IF for the DVB-T 6 MHz mode, and /* the R820T uses 3.57 MHz IF for the DVB-T 6 MHz mode, and
* 4.57 MHz for the 8 MHz mode */ * 4.57 MHz for the 8 MHz mode */
rtlsdr_set_if_freq(dev, R820T_IF_FREQ); rtlsdr_set_if_freq(dev, R820T_IF_FREQ);

Loading…
Cancel
Save