summaryrefslogtreecommitdiff
path: root/src/tuners/r820t.rs
diff options
context:
space:
mode:
authorYuval Adam <_@yuv.al>2021-04-17 15:49:04 +0300
committerYuval Adam <_@yuv.al>2021-04-17 15:49:04 +0300
commitac956ac7d3dd5b51bfa9fc467ffb68a4715f3478 (patch)
tree74b77e4055be4d5e75134050685287d254fbfeb7 /src/tuners/r820t.rs
parent46439763077ce7b656e8fae257f9c2205f23c6e5 (diff)
Start refactoring out handle and implementing rtl_test
Diffstat (limited to 'src/tuners/r820t.rs')
-rw-r--r--src/tuners/r820t.rs33
1 files changed, 17 insertions, 16 deletions
diff --git a/src/tuners/r820t.rs b/src/tuners/r820t.rs
index 9844b41..14d54e8 100644
--- a/src/tuners/r820t.rs
+++ b/src/tuners/r820t.rs
@@ -3,9 +3,9 @@ use usb::RtlSdrDeviceHandle;
const R82XX_IF_FREQ: u32 = 3570000;
-pub struct R820T<'a> {
+pub struct R820T {
pub device: TunerInfo,
- pub handle: &'a RtlSdrDeviceHandle,
+ // pub handle: &'a RtlSdrDeviceHandle,
}
pub const TUNER_ID: &str = "r820t";
@@ -16,39 +16,40 @@ pub const TUNER_INFO: TunerInfo = TunerInfo {
i2c_addr: 0x34,
check_addr: 0x00,
check_val: 0x69,
+ // gains: vec![
+ // 0, 9, 14, 27, 37, 77, 87, 125, 144, 157, 166, 197, 207, 229, 254, 280, 297, 328, 338, 364,
+ // 372, 386, 402, 421, 434, 439, 445, 480, 496,
+ // ],
};
-impl<'a> R820T<'a> {
- pub fn new(handle: &'a RtlSdrDeviceHandle) -> R820T<'a> {
- let tuner = R820T {
- device: TUNER_INFO,
- handle: handle,
- };
- tuner.init();
+impl R820T {
+ pub fn new(handle: &RtlSdrDeviceHandle) -> R820T {
+ let tuner = R820T { device: TUNER_INFO };
+ tuner.init(handle);
tuner
}
}
-impl<'a> Drop for R820T<'a> {
+impl Drop for R820T {
fn drop(&mut self) {
self.exit();
}
}
-impl<'a> Tuner for R820T<'a> {
- fn init(&self) {
+impl Tuner for R820T {
+ fn init(&self, handle: &RtlSdrDeviceHandle) {
// disable Zero-IF mode
- self.handle.demod_write_reg(1, 0xb1, 0x1a, 1);
+ handle.demod_write_reg(1, 0xb1, 0x1a, 1);
// only enable In-phase ADC input
- self.handle.demod_write_reg(0, 0x08, 0x4d, 1);
+ handle.demod_write_reg(0, 0x08, 0x4d, 1);
// the R82XX use 3.57 MHz IF for the DVB-T 6 MHz mode, and
// 4.57 MHz for the 8 MHz mode
- self.handle.set_if_freq(R82XX_IF_FREQ);
+ handle.set_if_freq(R82XX_IF_FREQ);
// enable spectrum inversion
- self.handle.demod_write_reg(1, 0x15, 0x01, 1);
+ handle.demod_write_reg(1, 0x15, 0x01, 1);
}
fn exit(&self) {}