From a792fa11bea0bde00aa9aaf0aa6c2640bdb633a3 Mon Sep 17 00:00:00 2001 From: Yuval Adam <_@yuv.al> Date: Fri, 3 Aug 2018 16:19:11 +0300 Subject: Implement r820t init --- src/devices/mod.rs | 4 +++- src/devices/r820t.rs | 18 ++++++++++++++++-- 2 files changed, 19 insertions(+), 3 deletions(-) (limited to 'src/devices') diff --git a/src/devices/mod.rs b/src/devices/mod.rs index 05dd2a3..659b131 100644 --- a/src/devices/mod.rs +++ b/src/devices/mod.rs @@ -1,3 +1,5 @@ +use usb::Usb; + pub mod fc0013; pub mod r820t; @@ -10,5 +12,5 @@ pub struct DeviceInfo { } pub trait Device { - fn init(&self); + fn init(&self, &Usb); } diff --git a/src/devices/r820t.rs b/src/devices/r820t.rs index fec572c..46046bc 100644 --- a/src/devices/r820t.rs +++ b/src/devices/r820t.rs @@ -1,4 +1,7 @@ use super::{DeviceInfo, Device}; +use usb::Usb; + +const R82XX_IF_FREQ: u32 = 3570000; pub struct R820T { pub device: DeviceInfo @@ -21,7 +24,18 @@ impl R820T { } impl Device for R820T { - fn init(&self) { - println!("Init {}", self.device.name); + fn init(&self, usb: &Usb) { + // disable Zero-IF mode + usb.demod_write_reg(1, 0xb1, 0x1a, 1); + + // only enable In-phase ADC input + usb.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 + usb.set_if_freq(R82XX_IF_FREQ); + + // enable spectrum inversion + usb.demod_write_reg(1, 0x15, 0x01, 1); } } -- cgit v1.3.1