Skip to content

Commit

Permalink
add toggle test function for tuner register debugging purposes
Browse files Browse the repository at this point in the history
  • Loading branch information
rtlsdrblog committed Aug 25, 2023
1 parent bb5c047 commit 18954da
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 0 deletions.
1 change: 1 addition & 0 deletions include/tuner_r82xx.h
Original file line number Diff line number Diff line change
Expand Up @@ -116,5 +116,6 @@ int r82xx_init(struct r82xx_priv *priv);
int r82xx_set_freq(struct r82xx_priv *priv, uint32_t freq);
int r82xx_set_gain(struct r82xx_priv *priv, int set_manual_gain, int gain);
int r82xx_set_bandwidth(struct r82xx_priv *priv, int bandwidth, uint32_t rate);
int r82xx_toggle_test(struct r82xx_priv *priv, int toggle);

#endif
10 changes: 10 additions & 0 deletions src/librtlsdr.c
Original file line number Diff line number Diff line change
Expand Up @@ -1177,6 +1177,16 @@ int rtlsdr_set_agc_mode(rtlsdr_dev_t *dev, int on)
if (!dev)
return -1;

/* FOR TESTING ONLY. Uncomment to enable repurposing the RTL AGC button
* for switching registers on/off. Uses to test functions of registers easily. */

/*
rtlsdr_set_i2c_repeater(dev, 1);
r82xx_toggle_test(&dev->r82xx_p, on);
rtlsdr_set_i2c_repeater(dev, 0);
return 0;
*/

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

Expand Down
19 changes: 19 additions & 0 deletions src/tuner_r82xx.c
Original file line number Diff line number Diff line change
Expand Up @@ -1105,6 +1105,25 @@ int r82xx_set_bandwidth(struct r82xx_priv *priv, int bw, uint32_t rate)

return priv->int_freq;
}

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

if (toggle)
{
fprintf(stderr, "TOGGLE ON \n");
rc = r82xx_write_reg_mask(priv, 0x17, 0x08, 0x08); /* open_d notch on */
}
else
{
fprintf(stderr, "TOGGLE OFF \n");
rc = r82xx_write_reg_mask(priv, 0x17, 0x00, 0x08); /* open_d notch off */
}

return rc;
}

#undef FILT_HP_BW1
#undef FILT_HP_BW2

Expand Down

0 comments on commit 18954da

Please sign in to comment.