fix reciprocal_pll divide error when reference frequency is 0
This commit is contained in:
parent
9f0b3eb77e
commit
9a3c9afa7e
@ -62,11 +62,18 @@ 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;
|
||||||
|
let demodulation_initial_phase: u32;
|
||||||
|
|
||||||
|
if self.reference_frequency == 0 {
|
||||||
|
demodulation_frequency = u32::MAX;
|
||||||
|
demodulation_initial_phase = u32::MAX;
|
||||||
|
} else {
|
||||||
|
demodulation_frequency = divide_round(
|
||||||
1 << (32 + self.adc_sample_ticks_log2),
|
1 << (32 + self.adc_sample_ticks_log2),
|
||||||
self.reference_frequency,
|
self.reference_frequency,
|
||||||
) as u32;
|
) as u32;
|
||||||
let demodulation_initial_phase = divide_round(
|
demodulation_initial_phase = divide_round(
|
||||||
(((self.batch_index as i64)
|
(((self.batch_index as i64)
|
||||||
<< (self.adc_sample_ticks_log2
|
<< (self.adc_sample_ticks_log2
|
||||||
+ self.sample_buffer_size_log2))
|
+ self.sample_buffer_size_log2))
|
||||||
@ -74,6 +81,7 @@ impl TimestampHandler {
|
|||||||
<< 32,
|
<< 32,
|
||||||
self.reference_frequency,
|
self.reference_frequency,
|
||||||
) as u32;
|
) as u32;
|
||||||
|
}
|
||||||
|
|
||||||
if self.batch_index
|
if self.batch_index
|
||||||
< (1 << (32
|
< (1 << (32
|
||||||
|
Loading…
Reference in New Issue
Block a user