Fixing merge
This commit is contained in:
parent
61321c484a
commit
ff79e0a8ac
|
@ -2,7 +2,6 @@
|
||||||
#![no_std]
|
#![no_std]
|
||||||
#![no_main]
|
#![no_main]
|
||||||
|
|
||||||
use embedded_hal::digital::v2::InputPin;
|
|
||||||
use generic_array::typenum::U4;
|
use generic_array::typenum::U4;
|
||||||
|
|
||||||
use serde::Deserialize;
|
use serde::Deserialize;
|
||||||
|
@ -31,7 +30,7 @@ const DAC_SEQUENCE: [i16; design_parameters::SAMPLE_BUFFER_SIZE] =
|
||||||
enum Conf {
|
enum Conf {
|
||||||
Magnitude,
|
Magnitude,
|
||||||
Phase,
|
Phase,
|
||||||
PllFrequency,
|
ReferenceFrequency,
|
||||||
LogPower,
|
LogPower,
|
||||||
InPhase,
|
InPhase,
|
||||||
Quadrature,
|
Quadrature,
|
||||||
|
@ -171,50 +170,38 @@ const APP: () = {
|
||||||
let lockin = c.resources.lockin;
|
let lockin = c.resources.lockin;
|
||||||
let settings = c.resources.settings;
|
let settings = c.resources.settings;
|
||||||
|
|
||||||
let mut pll_frequency = 0;
|
let (reference_phase, reference_frequency) = match settings.lockin_mode
|
||||||
|
{
|
||||||
let (sample_phase, sample_frequency) = match settings.lockin_mode {
|
|
||||||
LockinMode::External => {
|
LockinMode::External => {
|
||||||
let timestamp =
|
let timestamp =
|
||||||
c.resources.timestamper.latest_timestamp().unwrap_or(None); // Ignore data from timer capture overflows.
|
c.resources.timestamper.latest_timestamp().unwrap_or(None); // Ignore data from timer capture overflows.
|
||||||
let (pll_phase, frequency) = c.resources.pll.update(
|
let (pll_phase, pll_frequency) = c.resources.pll.update(
|
||||||
timestamp.map(|t| t as i32),
|
timestamp.map(|t| t as i32),
|
||||||
settings.pll_tc[0],
|
settings.pll_tc[0],
|
||||||
settings.pll_tc[1],
|
settings.pll_tc[1],
|
||||||
);
|
);
|
||||||
|
(
|
||||||
pll_frequency = frequency;
|
pll_phase,
|
||||||
|
(pll_frequency
|
||||||
let sample_frequency = ((pll_frequency
|
>> design_parameters::SAMPLE_BUFFER_SIZE_LOG2)
|
||||||
>> design_parameters::SAMPLE_BUFFER_SIZE_LOG2)
|
as i32,
|
||||||
as i32)
|
)
|
||||||
.wrapping_mul(settings.lockin_harmonic);
|
|
||||||
let sample_phase = settings.lockin_phase.wrapping_add(
|
|
||||||
pll_phase.wrapping_mul(settings.lockin_harmonic),
|
|
||||||
);
|
|
||||||
|
|
||||||
(sample_phase, sample_frequency)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
LockinMode::Internal => {
|
LockinMode::Internal => {
|
||||||
// Reference phase and frequency are known.
|
// Reference phase and frequency are known.
|
||||||
let pll_phase = 0i32;
|
(
|
||||||
let pll_frequency =
|
1i32 << 30,
|
||||||
1i32 << (32 - design_parameters::SAMPLE_BUFFER_SIZE_LOG2);
|
1i32 << (32 - design_parameters::SAMPLE_BUFFER_SIZE_LOG2),
|
||||||
|
)
|
||||||
// Demodulation LO phase offset
|
|
||||||
let phase_offset: i32 = 1 << 30;
|
|
||||||
|
|
||||||
let sample_frequency = (pll_frequency as i32)
|
|
||||||
.wrapping_mul(settings.lockin_harmonic);
|
|
||||||
let sample_phase = phase_offset.wrapping_add(
|
|
||||||
pll_phase.wrapping_mul(settings.lockin_harmonic),
|
|
||||||
);
|
|
||||||
|
|
||||||
(sample_phase, sample_frequency)
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
let sample_frequency =
|
||||||
|
reference_frequency.wrapping_mul(settings.lockin_harmonic);
|
||||||
|
let sample_phase = settings.lockin_phase.wrapping_add(
|
||||||
|
reference_phase.wrapping_mul(settings.lockin_harmonic),
|
||||||
|
);
|
||||||
|
|
||||||
let output: Complex<i32> = adc_samples[0]
|
let output: Complex<i32> = adc_samples[0]
|
||||||
.iter()
|
.iter()
|
||||||
// Zip in the LO phase.
|
// Zip in the LO phase.
|
||||||
|
@ -236,7 +223,9 @@ const APP: () = {
|
||||||
Conf::Magnitude => output.abs_sqr() as i32 >> 16,
|
Conf::Magnitude => output.abs_sqr() as i32 >> 16,
|
||||||
Conf::Phase => output.arg() >> 16,
|
Conf::Phase => output.arg() >> 16,
|
||||||
Conf::LogPower => (output.log2() << 24) as i32 >> 16,
|
Conf::LogPower => (output.log2() << 24) as i32 >> 16,
|
||||||
Conf::PllFrequency => pll_frequency as i32 >> 16,
|
Conf::ReferenceFrequency => {
|
||||||
|
reference_frequency as i32 >> 16
|
||||||
|
}
|
||||||
Conf::InPhase => output.re >> 16,
|
Conf::InPhase => output.re >> 16,
|
||||||
Conf::Quadrature => output.im >> 16,
|
Conf::Quadrature => output.im >> 16,
|
||||||
Conf::Modulation => DAC_SEQUENCE[i] as i32,
|
Conf::Modulation => DAC_SEQUENCE[i] as i32,
|
||||||
|
|
Loading…
Reference in New Issue