summaryrefslogtreecommitdiff
path: root/src/devices/r820t.rs
blob: d08fc7651b8926fc8403568ac6243b33e8a2f7f0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
use super::{DeviceInfo, Device};
use usb::Usb;

const R82XX_IF_FREQ: u32 = 3570000;

pub struct R820T<'a> {
    pub device: DeviceInfo,
    pub usb: &'a Usb<'a>
}

pub const DEVICE_INFO: DeviceInfo = DeviceInfo {
    id: "r820t",
    name: "Rafael Micro R820T",
    i2c_addr: 0x34,
    check_addr: 0x00,
    check_val: 0x69
};

impl<'a> R820T<'a> {
    pub fn new(usb: &'a Usb) -> R820T<'a> {
        R820T {
            device: DEVICE_INFO,
            usb
        }
    }
}

impl<'a> Device for R820T<'a> {
    fn init(&self) {
        // disable Zero-IF mode
        self.usb.demod_write_reg(1, 0xb1, 0x1a, 1);

        // only enable In-phase ADC input
        self.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
        self.usb.set_if_freq(R82XX_IF_FREQ);

        // enable spectrum inversion
        self.usb.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!()
    }

}