diff --git a/dsp/src/lib.rs b/dsp/src/lib.rs index 748b4b8..10cfcaa 100644 --- a/dsp/src/lib.rs +++ b/dsp/src/lib.rs @@ -8,4 +8,4 @@ pub mod pll; pub mod unwrap; #[cfg(test)] -mod testing; \ No newline at end of file +mod testing; diff --git a/dsp/src/pll.rs b/dsp/src/pll.rs index c27cf4a..8f060c2 100644 --- a/dsp/src/pll.rs +++ b/dsp/src/pll.rs @@ -49,7 +49,7 @@ impl PLL { /// Returns: /// A tuple of instantaneous phase and frequency (the current phase increment). pub fn update(&mut self, x: i32, shift: u8) -> (i32, i32) { - debug_assert!(shift >= 1 && shift <= 31); + debug_assert!((1..=30).contains(&shift)); let bias = 1i32 << shift; let e = x.wrapping_sub(self.f); self.f = self.f.wrapping_add( @@ -57,7 +57,7 @@ impl PLL { ); self.x = x; let f = self.f.wrapping_add( - bias.wrapping_add(e).wrapping_sub(self.y) >> shift - 1, + bias.wrapping_add(e).wrapping_sub(self.y) >> (shift - 1), ); self.y = self.y.wrapping_add(f); (self.y, f)