Skip to content

Commit

Permalink
minor changes to make testing easier
Browse files Browse the repository at this point in the history
  • Loading branch information
rtlsdrblog committed Jun 8, 2023
1 parent b8be1be commit 70805d0
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 10 deletions.
12 changes: 7 additions & 5 deletions src/librtlsdr.c
Original file line number Diff line number Diff line change
Expand Up @@ -1193,6 +1193,7 @@ uint32_t rtlsdr_get_sample_rate(rtlsdr_dev_t *dev)
return dev->rate;
}

/* Used to test any register setting with a toggle */
int rtlsdr_set_testmode(rtlsdr_dev_t *dev, int on)
{
if (!dev)
Expand All @@ -1209,13 +1210,14 @@ int rtlsdr_set_agc_mode(rtlsdr_dev_t *dev, int on)
/* testing:
* replaceme the useless RTL AGC function with a function that
implements max LNA gain for sensitivity when on */
rtlsdr_set_i2c_repeater(dev, 1);
sensitivity_mode_toggle(&dev->r82xx_p, on);
rtlsdr_set_i2c_repeater(dev, 0);
//rtlsdr_set_i2c_repeater(dev, 1);
//sensitivity_mode_toggle(&dev->r82xx_p, on);
//notch_toggle(&dev->r82xx_p, on);
//rtlsdr_set_i2c_repeater(dev, 0);

return 0;
//return 0;

//return rtlsdr_demod_write_reg(dev, 0, 0x19, on ? 0x25 : 0x05, 1);
return rtlsdr_demod_write_reg(dev, 0, 0x19, on ? 0x25 : 0x05, 1);
}

int rtlsdr_set_direct_sampling(rtlsdr_dev_t *dev, int on)
Expand Down
28 changes: 23 additions & 5 deletions src/tuner_r82xx.c
Original file line number Diff line number Diff line change
Expand Up @@ -377,9 +377,9 @@ static int r82xx_set_mux(struct r82xx_priv *priv, uint32_t freq)
range = &freq_ranges[i];

/* Open Drain */
rc = r82xx_write_reg_mask(priv, 0x17, range->open_d, 0x08);
if (rc < 0)
return rc;
//rc = r82xx_write_reg_mask(priv, 0x17, range->open_d, 0x08);
//if (rc < 0)
// return rc;

/* RF_MUX,Polymux */
rc = r82xx_write_reg_mask(priv, 0x1a, range->rf_mux_ploy, 0xc3);
Expand Down Expand Up @@ -677,7 +677,7 @@ static int r82xx_sysfreq_sel(struct r82xx_priv *priv, uint32_t freq,
return rc;

// RTLSDRBLOG. Improve L-band performance by setting PLL drop out to 2.0v
div_buf_cur = 0xa0;
div_buf_cur = 0xa0;
rc = r82xx_write_reg_mask(priv, 0x17, div_buf_cur, 0x30);
if (rc < 0)
return rc;
Expand Down Expand Up @@ -1145,6 +1145,24 @@ int sensitivity_mode_toggle(struct r82xx_priv *priv, int toggle)
return rc;
}

int notch_toggle(struct r82xx_priv *priv, int toggle)
{
int rc;

if (toggle)
{
//fprintf(stdout, "TOGGLE ON");
rc = r82xx_write_reg_mask(priv, 0x17, 0x08, 0x08);
}
else
{
//fprintf(stdout, "TOGGLE OFF");
rc = r82xx_write_reg_mask(priv, 0x17, 0x00, 0x08);
}

return rc;
}

int r82xx_set_freq(struct r82xx_priv *priv, uint32_t freq)
{
int rc = -1;
Expand Down Expand Up @@ -1180,7 +1198,7 @@ int r82xx_set_freq(struct r82xx_priv *priv, uint32_t freq)
/* select tuner band based on frequency
* and only switch if there is a band change
*(to avoid excessive register writes when tuning rapidly) */
uint8_t band = (freq <= MHZ(28.8)) ? HF : ((freq > MHZ(28.8) && freq < MHZ(300)) ? VHF : UHF);
uint8_t band = (freq <= MHZ(28.8)) ? HF : ((freq > MHZ(28.8) && freq < MHZ(250)) ? VHF : UHF);

/* switch between tuner inputs on the RTL-SDR Blog V4 */
if (band != priv->input)
Expand Down

0 comments on commit 70805d0

Please sign in to comment.