Merge branch 'direct-sampling' into dev

This commit is contained in:
Oliver Jowett 2018-07-24 17:49:16 +01:00
commit 41fa394278

View file

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