diff options
| author | Yuval Adam <_@yuv.al> | 2021-04-16 17:23:10 +0300 |
|---|---|---|
| committer | Yuval Adam <_@yuv.al> | 2021-04-17 10:33:57 +0300 |
| commit | 01824ebaa3096d40a962b921ed239241f92e1076 (patch) | |
| tree | 1b3d9f810b5086e52678fbed7f6e96e9e39d4cdf /src/devices | |
| parent | 199f7cfb5749a1810db7923780e5a65eb17b8e11 (diff) | |
Implement search_tuner()
Diffstat (limited to 'src/devices')
| -rw-r--r-- | src/devices/fc0013.rs | 12 | ||||
| -rw-r--r-- | src/devices/mod.rs | 4 | ||||
| -rw-r--r-- | src/devices/r820t.rs | 10 |
3 files changed, 12 insertions, 14 deletions
diff --git a/src/devices/fc0013.rs b/src/devices/fc0013.rs index 3a26218..7c64758 100644 --- a/src/devices/fc0013.rs +++ b/src/devices/fc0013.rs @@ -1,12 +1,12 @@ -use super::{Device, DeviceInfo}; +use super::{Tuner, TunerInfo}; #[allow(dead_code)] pub struct FC0013 { - pub device: DeviceInfo, + pub device: TunerInfo, } #[allow(dead_code)] -pub const DEVICE_INFO: DeviceInfo = DeviceInfo { +pub const TUNER_INFO: TunerInfo = TunerInfo { id: "fc0013", name: "Fitipower FC0013", i2c_addr: 0xc6, @@ -17,13 +17,11 @@ pub const DEVICE_INFO: DeviceInfo = DeviceInfo { #[allow(dead_code)] impl FC0013 { pub fn new() -> FC0013 { - FC0013 { - device: DEVICE_INFO, - } + FC0013 { device: TUNER_INFO } } } -impl Device for FC0013 { +impl Tuner for FC0013 { fn init(&self) { println!("Init {}", self.device.name); } diff --git a/src/devices/mod.rs b/src/devices/mod.rs index a48531d..cbd7edf 100644 --- a/src/devices/mod.rs +++ b/src/devices/mod.rs @@ -1,7 +1,7 @@ pub mod fc0013; pub mod r820t; -pub struct DeviceInfo { +pub struct TunerInfo { pub id: &'static str, pub name: &'static str, pub i2c_addr: u8, @@ -9,7 +9,7 @@ pub struct DeviceInfo { pub check_val: u8, } -pub trait Device { +pub trait Tuner { fn init(&self); fn exit(&self); fn set_freq(&self, freq: u32); diff --git a/src/devices/r820t.rs b/src/devices/r820t.rs index a257b56..ad4720d 100644 --- a/src/devices/r820t.rs +++ b/src/devices/r820t.rs @@ -1,14 +1,14 @@ -use super::{Device, DeviceInfo}; +use super::{Tuner, TunerInfo}; use usb::RtlSdrDeviceHandle; const R82XX_IF_FREQ: u32 = 3570000; pub struct R820T<'a> { - pub device: DeviceInfo, + pub device: TunerInfo, pub handle: &'a RtlSdrDeviceHandle, } -pub const DEVICE_INFO: DeviceInfo = DeviceInfo { +pub const TUNER_INFO: TunerInfo = TunerInfo { id: "r820t", name: "Rafael Micro R820T", i2c_addr: 0x34, @@ -19,7 +19,7 @@ pub const DEVICE_INFO: DeviceInfo = DeviceInfo { impl<'a> R820T<'a> { pub fn new(handle: &'a RtlSdrDeviceHandle) -> R820T<'a> { R820T { - device: DEVICE_INFO, + device: TUNER_INFO, handle: handle, } } @@ -29,7 +29,7 @@ impl<'a> Drop for R820T<'a> { fn drop(&mut self) {} } -impl<'a> Device for R820T<'a> { +impl<'a> Tuner for R820T<'a> { fn init(&self) { // disable Zero-IF mode self.handle.demod_write_reg(1, 0xb1, 0x1a, 1); |
