From c430b4b2f5467a0b86d2312f742e5b4ece4f4bad Mon Sep 17 00:00:00 2001 From: Yuval Adam <_@yuv.al> Date: Fri, 16 Apr 2021 23:56:40 +0300 Subject: Cleanup deinit and document lifecycle --- src/devices/fc0013.rs | 56 --------------------------------------- src/devices/mod.rs | 20 -------------- src/devices/r820t.rs | 73 --------------------------------------------------- 3 files changed, 149 deletions(-) delete mode 100644 src/devices/fc0013.rs delete mode 100644 src/devices/mod.rs delete mode 100644 src/devices/r820t.rs (limited to 'src/devices') diff --git a/src/devices/fc0013.rs b/src/devices/fc0013.rs deleted file mode 100644 index 9eb03f4..0000000 --- a/src/devices/fc0013.rs +++ /dev/null @@ -1,56 +0,0 @@ -use super::{Tuner, TunerInfo}; -use usb::RtlSdrDeviceHandle; - -pub struct FC0013<'a> { - pub device: TunerInfo, - pub handle: &'a RtlSdrDeviceHandle, -} - -pub const TUNER_ID: &str = "fc0013"; - -pub const TUNER_INFO: TunerInfo = TunerInfo { - id: TUNER_ID, - name: "Fitipower FC0013", - i2c_addr: 0xc6, - check_addr: 0x00, - check_val: 0xa3, -}; - -impl<'a> FC0013<'a> { - pub fn new(handle: &'a RtlSdrDeviceHandle) -> FC0013<'a> { - FC0013 { - device: TUNER_INFO, - handle: handle, - } - } -} - -impl<'a> Tuner for FC0013<'a> { - fn init(&self) { - println!("Init {}", self.device.name); - } - - fn exit(&self) { - unimplemented!() - } - - 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!() - } -} diff --git a/src/devices/mod.rs b/src/devices/mod.rs deleted file mode 100644 index cbd7edf..0000000 --- a/src/devices/mod.rs +++ /dev/null @@ -1,20 +0,0 @@ -pub mod fc0013; -pub mod r820t; - -pub struct TunerInfo { - pub id: &'static str, - pub name: &'static str, - pub i2c_addr: u8, - pub check_addr: u8, - pub check_val: u8, -} - -pub trait Tuner { - fn init(&self); - fn exit(&self); - fn set_freq(&self, freq: u32); - fn set_bw(&self, bw: u32); - fn set_gain(&self, gain: u32); - fn set_if_gain(&self, if_gain: u32); - fn set_gain_mode(&self, mode: bool); -} diff --git a/src/devices/r820t.rs b/src/devices/r820t.rs deleted file mode 100644 index ec0f173..0000000 --- a/src/devices/r820t.rs +++ /dev/null @@ -1,73 +0,0 @@ -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) {} -} - -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) { - unimplemented!() - } - - 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!() - } -} -- cgit v1.3.1