summaryrefslogtreecommitdiff
path: root/src/tuners/r820t.rs
diff options
context:
space:
mode:
authorYuval Adam <_@yuv.al>2021-04-16 23:56:40 +0300
committerYuval Adam <_@yuv.al>2021-04-17 10:33:57 +0300
commitc430b4b2f5467a0b86d2312f742e5b4ece4f4bad (patch)
treefab4ed16477ee94a3527f131bfe9c521345427de /src/tuners/r820t.rs
parentcc3a300afcba8fffaee5feb5f56792cfd697bf28 (diff)
Cleanup deinit and document lifecyclev0.2
Diffstat (limited to 'src/tuners/r820t.rs')
-rw-r--r--src/tuners/r820t.rs73
1 files changed, 73 insertions, 0 deletions
diff --git a/src/tuners/r820t.rs b/src/tuners/r820t.rs
new file mode 100644
index 0000000..2638917
--- /dev/null
+++ b/src/tuners/r820t.rs
@@ -0,0 +1,73 @@
+use super::{Tuner, TunerInfo};
+use usb::RtlSdrDeviceHandle;
+
+const R82XX_IF_FREQ: u32 = 3570000;
+
+pub struct R820T<'a> {
+ pub device: TunerInfo,
+ pub handle: &'a RtlSdrDeviceHandle,
+}
+
+pub const TUNER_ID: &str = "r820t";
+
+pub const TUNER_INFO: TunerInfo = TunerInfo {
+ id: TUNER_ID,
+ name: "Rafael Micro R820T",
+ i2c_addr: 0x34,
+ check_addr: 0x00,
+ check_val: 0x69,
+};
+
+impl<'a> R820T<'a> {
+ pub fn new(handle: &'a RtlSdrDeviceHandle) -> R820T<'a> {
+ R820T {
+ device: TUNER_INFO,
+ handle: handle,
+ }
+ }
+}
+
+impl<'a> Drop for R820T<'a> {
+ fn drop(&mut self) {
+ self.exit();
+ }
+}
+
+impl<'a> Tuner for R820T<'a> {
+ fn init(&self) {
+ // disable Zero-IF mode
+ self.handle.demod_write_reg(1, 0xb1, 0x1a, 1);
+
+ // only enable In-phase ADC input
+ self.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);
+
+ // enable spectrum inversion
+ self.handle.demod_write_reg(1, 0x15, 0x01, 1);
+ }
+
+ fn exit(&self) {}
+
+ fn set_freq(&self, _freq: u32) {
+ unimplemented!()
+ }
+
+ fn set_bw(&self, _bw: u32) {
+ unimplemented!()
+ }
+
+ fn set_gain(&self, _gain: u32) {
+ unimplemented!()
+ }
+
+ fn set_if_gain(&self, _if_gain: u32) {
+ unimplemented!()
+ }
+
+ fn set_gain_mode(&self, _mode: bool) {
+ unimplemented!()
+ }
+}