diff options
| author | Yuval Adam <_@yuv.al> | 2021-04-28 17:21:11 +0300 |
|---|---|---|
| committer | Yuval Adam <_@yuv.al> | 2021-04-28 17:21:11 +0300 |
| commit | 54b4607c46094de0333f474af492981adf39a6cd (patch) | |
| tree | 3569fb94054d8bec0d317aca8af2aa9db43c2e1a /src/lib.rs | |
| parent | 25db452b3fb9c83ff8600362467bcde63591d67f (diff) | |
Fix set_if_freq() handling in initwip
Diffstat (limited to 'src/lib.rs')
| -rw-r--r-- | src/lib.rs | 14 |
1 files changed, 3 insertions, 11 deletions
@@ -111,7 +111,7 @@ impl RtlSdr { pub fn set_freq(&self) {} - pub fn set_sample_rate(self, samp_rate: u32) { + pub fn set_sample_rate(&mut self, samp_rate: u32) { let real_rsamp_ratio: u32; // check if the rate is supported by the resampler @@ -131,6 +131,7 @@ impl RtlSdr { self.handle.set_i2c_repeater(true); self.tuner + .as_mut() .unwrap() .set_bandwidth(real_rate as u32, &self.handle); self.handle.set_i2c_repeater(false); @@ -149,16 +150,7 @@ impl RtlSdr { } pub fn set_if_freq(&self, freq: u32) { - let rtl_xtal: u32 = DEF_RTL_XTAL_FREQ; // need to apply PPM correction - let base = 1u32 << 22; - let if_freq: i32 = (freq as f64 * base as f64 / rtl_xtal as f64 * -1f64) as i32; - - let tmp = ((if_freq >> 16) as u16) & 0x3f; - self.handle.demod_write_reg(1, 0x19, tmp, 1); - let tmp = ((if_freq >> 8) as u16) & 0xff; - self.handle.demod_write_reg(1, 0x1a, tmp, 1); - let tmp = if_freq as u16 & 0xff; - self.handle.demod_write_reg(1, 0x1b, tmp, 1); + self.handle.set_if_freq(freq); } pub fn set_test_mode(&self, on: bool) { |
