Add --direct option for rtlsdr direct sampling

This commit is contained in:
Oliver Jowett 2018-07-23 20:37:01 +01:00
parent 1caabc5ad8
commit 2b00c05465

View file

@ -57,6 +57,7 @@ static struct {
rtlsdr_dev_t *dev;
bool digital_agc;
int ppm_error;
int direct_sampling;
iq_convert_fn converter;
struct converter_state *converter_state;
@ -71,6 +72,7 @@ void rtlsdrInitConfig()
RTLSDR.dev = NULL;
RTLSDR.digital_agc = false;
RTLSDR.ppm_error = 0;
RTLSDR.direct_sampling = 0;
RTLSDR.converter = NULL;
RTLSDR.converter_state = NULL;
}
@ -142,6 +144,7 @@ void rtlsdrShowHelp()
printf("--device <index|serial> select device by index or serial number\n");
printf("--enable-agc enable digital AGC (not tuner AGC!)\n");
printf("--ppm <correction> set oscillator frequency correction in PPM\n");
printf("--direct <0|1|2> set direct sampling mode\n");
printf("\n");
}
@ -154,6 +157,8 @@ bool rtlsdrHandleOption(int argc, char **argv, int *jptr)
RTLSDR.digital_agc = true;
} else if (!strcmp(argv[j], "--ppm") && more) {
RTLSDR.ppm_error = atoi(argv[++j]);
} else if (!strcmp(argv[j], "--direct") && more) {
RTLSDR.direct_sampling = atoi(argv[++j]);
} else {
return false;
}
@ -196,6 +201,10 @@ bool rtlsdrOpen(void) {
}
// Set gain, frequency, sample rate, and reset the device
if (RTLSDR.direct_sampling) {
fprintf(stderr, "rtlsdr: direct sampling from input %d\n", RTLSDR.direct_sampling);
rtlsdr_set_direct_sampling(RTLSDR.dev, RTLSDR.direct_sampling);
} else {
if (Modes.gain == MODES_AUTO_GAIN) {
fprintf(stderr, "rtlsdr: enabling tuner AGC\n");
rtlsdr_set_tuner_gain_mode(RTLSDR.dev, 0);
@ -230,6 +239,7 @@ bool rtlsdrOpen(void) {
fprintf(stderr, "rtlsdr: tuner gain set to %.1f dB\n",
rtlsdr_get_tuner_gain(RTLSDR.dev)/10.0);
}
}
if (RTLSDR.digital_agc) {
fprintf(stderr, "rtlsdr: enabling digital AGC\n");