fix reciprocal_pll divide error when reference frequency is 0

This commit is contained in:
Matt Huszagh 2021-01-14 14:47:55 -08:00
parent 9f0b3eb77e
commit 9a3c9afa7e

View File

@ -62,18 +62,26 @@ impl TimestampHandler {
self.reference_frequency = frequency as u32 as i64; self.reference_frequency = frequency as u32 as i64;
} }
let demodulation_frequency = divide_round( let demodulation_frequency: u32;
1 << (32 + self.adc_sample_ticks_log2), let demodulation_initial_phase: u32;
self.reference_frequency,
) as u32; if self.reference_frequency == 0 {
let demodulation_initial_phase = divide_round( demodulation_frequency = u32::MAX;
(((self.batch_index as i64) demodulation_initial_phase = u32::MAX;
<< (self.adc_sample_ticks_log2 } else {
+ self.sample_buffer_size_log2)) demodulation_frequency = divide_round(
- self.reference_phase) 1 << (32 + self.adc_sample_ticks_log2),
<< 32, self.reference_frequency,
self.reference_frequency, ) as u32;
) as u32; demodulation_initial_phase = divide_round(
(((self.batch_index as i64)
<< (self.adc_sample_ticks_log2
+ self.sample_buffer_size_log2))
- self.reference_phase)
<< 32,
self.reference_frequency,
) as u32;
}
if self.batch_index if self.batch_index
< (1 << (32 < (1 << (32