mirror of
https://github.com/hubaldv/bioz-firmware-rs.git
synced 2025-12-06 05:01:18 +00:00
Change multi to sweep.
This commit is contained in:
@@ -20,9 +20,9 @@ use postcard_rpc::{
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
use bioz_icd_rs::{GetUniqueIdEndpoint, MeasurementPointSet, MultiImpedanceOutputTopic, MultiImpedanceResult, MultiImpedanceStartRequest, PingEndpoint, SetGreenLedEndpoint, SingleImpedanceOutputTopic, SingleImpedanceStartRequest, StartMultiImpedanceEndpoint, StartSingleImpedanceEndpoint, StopMultiImpedanceEndpoint, StopSingleImpedanceEndpoint, BioImpedanceLeadMode, ENDPOINT_LIST, TOPICS_IN_LIST, TOPICS_OUT_LIST};
|
use bioz_icd_rs::{GetUniqueIdEndpoint, MeasurementPointSet, SweepImpedanceOutputTopic, SweepImpedanceResult, SweepImpedanceStartRequest, PingEndpoint, SetGreenLedEndpoint, SingleImpedanceOutputTopic, SingleImpedanceStartRequest, StartSweepImpedanceEndpoint, StartSingleImpedanceEndpoint, StopImpedanceEndpoint, BioImpedanceLeadMode, ENDPOINT_LIST, TOPICS_IN_LIST, TOPICS_OUT_LIST};
|
||||||
|
|
||||||
use crate::impedance::{ImpedanceSetupType, RunningMode, IMPEDANCE_CHANNEL_MULTI, IMPEDANCE_CHANNEL_SINGLE};
|
use crate::impedance::{ImpedanceSetupType, RunningMode, IMPEDANCE_CHANNEL_SWEEP, IMPEDANCE_CHANNEL_SINGLE};
|
||||||
|
|
||||||
// Postcard RPC types
|
// Postcard RPC types
|
||||||
type AppDriver = usb::Driver<'static, peripherals::USB>;
|
type AppDriver = usb::Driver<'static, peripherals::USB>;
|
||||||
@@ -70,9 +70,8 @@ define_dispatch! {
|
|||||||
| GetUniqueIdEndpoint | blocking | get_unique_id_handler |
|
| GetUniqueIdEndpoint | blocking | get_unique_id_handler |
|
||||||
| SetGreenLedEndpoint | async | set_green_led_handler |
|
| SetGreenLedEndpoint | async | set_green_led_handler |
|
||||||
| StartSingleImpedanceEndpoint | spawn | start_single_impedance_handler |
|
| StartSingleImpedanceEndpoint | spawn | start_single_impedance_handler |
|
||||||
| StopSingleImpedanceEndpoint | async | stop_single_impedance_handler |
|
| StartSweepImpedanceEndpoint | spawn | start_sweep_impedance_handler |
|
||||||
| StartMultiImpedanceEndpoint | spawn | start_multi_impedance_handler |
|
| StopImpedanceEndpoint | async | stop_impedance_handler |
|
||||||
| StopMultiImpedanceEndpoint | async | stop_multi_impedance_handler |
|
|
||||||
};
|
};
|
||||||
topics_in: {
|
topics_in: {
|
||||||
list: TOPICS_IN_LIST;
|
list: TOPICS_IN_LIST;
|
||||||
@@ -198,7 +197,7 @@ pub async fn start_single_impedance_handler(context: SpawnCtx, header: VarHeader
|
|||||||
|
|
||||||
match select(stop_fut, recv_fut).await {
|
match select(stop_fut, recv_fut).await {
|
||||||
Either::First(_) => {
|
Either::First(_) => {
|
||||||
info!("Stop signal received.");
|
// info!("Stop signal received.");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
Either::Second(msg) => {
|
Either::Second(msg) => {
|
||||||
@@ -220,79 +219,70 @@ pub async fn start_single_impedance_handler(context: SpawnCtx, header: VarHeader
|
|||||||
STOP.reset();
|
STOP.reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn stop_single_impedance_handler(context: &mut Context, _header: VarHeader, _rqst: ()) -> bool {
|
|
||||||
info!("Stop impedance measurement");
|
|
||||||
let was_busy = context.impedance_setup.lock().await.running_mode;
|
|
||||||
if was_busy == RunningMode::SingleFrequency2Lead || was_busy == RunningMode::SingleFrequency4Lead || was_busy == RunningMode::MultiFrequency2Lead(MeasurementPointSet::Eight) || was_busy == RunningMode::MultiFrequency2Lead(MeasurementPointSet::Eighteen) || was_busy == RunningMode::MultiFrequency4Lead(MeasurementPointSet::Eight) || was_busy == RunningMode::MultiFrequency4Lead(MeasurementPointSet::Eighteen) {
|
|
||||||
STOP.signal(());
|
|
||||||
}
|
|
||||||
was_busy == RunningMode::SingleFrequency2Lead || was_busy == RunningMode::SingleFrequency4Lead || was_busy == RunningMode::MultiFrequency2Lead(MeasurementPointSet::Eight) || was_busy == RunningMode::MultiFrequency2Lead(MeasurementPointSet::Eighteen) || was_busy == RunningMode::MultiFrequency4Lead(MeasurementPointSet::Eight) || was_busy == RunningMode::MultiFrequency4Lead(MeasurementPointSet::Eighteen)
|
|
||||||
}
|
|
||||||
|
|
||||||
#[embassy_executor::task]
|
#[embassy_executor::task]
|
||||||
pub async fn start_multi_impedance_handler(context: SpawnCtx, header: VarHeader, rqst: MultiImpedanceStartRequest, sender: Sender<AppTx>) {
|
pub async fn start_sweep_impedance_handler(context: SpawnCtx, header: VarHeader, rqst: SweepImpedanceStartRequest, sender: Sender<AppTx>) {
|
||||||
// Mark the impedance setup as running
|
// Mark the impedance setup as running
|
||||||
|
|
||||||
|
|
||||||
// Init the sequencer
|
// Init the sequencer
|
||||||
let response = match (rqst.lead_mode, rqst.points) {
|
let response = match (rqst.lead_mode, rqst.points) {
|
||||||
(BioImpedanceLeadMode::TwoLead, MeasurementPointSet::Eight) => {
|
(BioImpedanceLeadMode::TwoLead, MeasurementPointSet::Eight) => {
|
||||||
context.impedance_setup.lock().await.running_mode = RunningMode::MultiFrequency2Lead(rqst.points);
|
context.impedance_setup.lock().await.running_mode = RunningMode::SweepFrequency2Lead(rqst.points);
|
||||||
const SIZE: usize = 8;
|
const SIZE: usize = 8;
|
||||||
context
|
context
|
||||||
.impedance_setup
|
.impedance_setup
|
||||||
.lock()
|
.lock()
|
||||||
.await
|
.await
|
||||||
.init_multi_frequency_measurement_2_lead::<SIZE>(rqst.points)
|
.init_sweep_frequency_measurement_2_lead::<SIZE>(rqst.points)
|
||||||
.await
|
.await
|
||||||
.map(|periods| MultiImpedanceResult {
|
.map(|periods| SweepImpedanceResult {
|
||||||
points: rqst.points,
|
points: rqst.points,
|
||||||
periods_per_dft_8: periods,
|
periods_per_dft_8: periods,
|
||||||
periods_per_dft_18: Vec::new(),
|
periods_per_dft_18: Vec::new(),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
(BioImpedanceLeadMode::TwoLead, MeasurementPointSet::Eighteen) => {
|
(BioImpedanceLeadMode::TwoLead, MeasurementPointSet::Eighteen) => {
|
||||||
context.impedance_setup.lock().await.running_mode = RunningMode::MultiFrequency2Lead(rqst.points);
|
context.impedance_setup.lock().await.running_mode = RunningMode::SweepFrequency2Lead(rqst.points);
|
||||||
const SIZE: usize = 18;
|
const SIZE: usize = 18;
|
||||||
context
|
context
|
||||||
.impedance_setup
|
.impedance_setup
|
||||||
.lock()
|
.lock()
|
||||||
.await
|
.await
|
||||||
.init_multi_frequency_measurement_2_lead::<SIZE>(rqst.points)
|
.init_sweep_frequency_measurement_2_lead::<SIZE>(rqst.points)
|
||||||
.await
|
.await
|
||||||
.map(|periods| MultiImpedanceResult {
|
.map(|periods| SweepImpedanceResult {
|
||||||
points: rqst.points,
|
points: rqst.points,
|
||||||
periods_per_dft_8: Vec::new(),
|
periods_per_dft_8: Vec::new(),
|
||||||
periods_per_dft_18: periods,
|
periods_per_dft_18: periods,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
(BioImpedanceLeadMode::FourLead, MeasurementPointSet::Eight) => {
|
(BioImpedanceLeadMode::FourLead, MeasurementPointSet::Eight) => {
|
||||||
info!("Start multi impedance 4 lead 8 points");
|
info!("Start impedance spectroscopy 4-lead with 8 points");
|
||||||
context.impedance_setup.lock().await.running_mode = RunningMode::MultiFrequency4Lead(rqst.points);
|
context.impedance_setup.lock().await.running_mode = RunningMode::SweepFrequency4Lead(rqst.points);
|
||||||
const SIZE: usize = 8;
|
const SIZE: usize = 8;
|
||||||
context
|
context
|
||||||
.impedance_setup
|
.impedance_setup
|
||||||
.lock()
|
.lock()
|
||||||
.await
|
.await
|
||||||
.init_multi_frequency_measurement_4_lead::<SIZE>(rqst.points)
|
.init_sweep_frequency_measurement_4_lead::<SIZE>(rqst.points)
|
||||||
.await
|
.await
|
||||||
.map(|periods| MultiImpedanceResult {
|
.map(|periods| SweepImpedanceResult {
|
||||||
points: rqst.points,
|
points: rqst.points,
|
||||||
periods_per_dft_8: periods,
|
periods_per_dft_8: periods,
|
||||||
periods_per_dft_18: Vec::new(),
|
periods_per_dft_18: Vec::new(),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
(BioImpedanceLeadMode::FourLead, MeasurementPointSet::Eighteen) => {
|
(BioImpedanceLeadMode::FourLead, MeasurementPointSet::Eighteen) => {
|
||||||
info!("Start multi impedance 4 lead 18 points");
|
info!("Start impedance spectroscopy 4-lead with 18 points");
|
||||||
context.impedance_setup.lock().await.running_mode = RunningMode::MultiFrequency4Lead(rqst.points);
|
context.impedance_setup.lock().await.running_mode = RunningMode::SweepFrequency4Lead(rqst.points);
|
||||||
const SIZE: usize = 18;
|
const SIZE: usize = 18;
|
||||||
context
|
context
|
||||||
.impedance_setup
|
.impedance_setup
|
||||||
.lock()
|
.lock()
|
||||||
.await
|
.await
|
||||||
.init_multi_frequency_measurement_4_lead::<SIZE>(rqst.points)
|
.init_sweep_frequency_measurement_4_lead::<SIZE>(rqst.points)
|
||||||
.await
|
.await
|
||||||
.map(|periods| MultiImpedanceResult {
|
.map(|periods| SweepImpedanceResult {
|
||||||
points: rqst.points,
|
points: rqst.points,
|
||||||
periods_per_dft_8: Vec::new(),
|
periods_per_dft_8: Vec::new(),
|
||||||
periods_per_dft_18: periods,
|
periods_per_dft_18: periods,
|
||||||
@@ -304,7 +294,7 @@ pub async fn start_multi_impedance_handler(context: SpawnCtx, header: VarHeader,
|
|||||||
context.impedance_setup.lock().await.start_measurement().await;
|
context.impedance_setup.lock().await.start_measurement().await;
|
||||||
|
|
||||||
if sender
|
if sender
|
||||||
.reply::<StartMultiImpedanceEndpoint>(header.seq_no, &response)
|
.reply::<StartSweepImpedanceEndpoint>(header.seq_no, &response)
|
||||||
.await
|
.await
|
||||||
.is_err()
|
.is_err()
|
||||||
{
|
{
|
||||||
@@ -312,21 +302,19 @@ pub async fn start_multi_impedance_handler(context: SpawnCtx, header: VarHeader,
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
info!("Start multi impedance measurement.");
|
|
||||||
|
|
||||||
let mut seq: u8 = 0;
|
let mut seq: u8 = 0;
|
||||||
loop {
|
loop {
|
||||||
let stop_fut = STOP.wait();
|
let stop_fut = STOP.wait();
|
||||||
let recv_fut = IMPEDANCE_CHANNEL_MULTI.receive();
|
let recv_fut = IMPEDANCE_CHANNEL_SWEEP.receive();
|
||||||
|
|
||||||
match select(stop_fut, recv_fut).await {
|
match select(stop_fut, recv_fut).await {
|
||||||
Either::First(_) => {
|
Either::First(_) => {
|
||||||
info!("Stop signal received.");
|
// info!("Stop signal received.");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
Either::Second(msg) => {
|
Either::Second(msg) => {
|
||||||
if sender
|
if sender
|
||||||
.publish::<MultiImpedanceOutputTopic>(seq.into(), &msg)
|
.publish::<SweepImpedanceOutputTopic>(seq.into(), &msg)
|
||||||
.await
|
.await
|
||||||
.is_err()
|
.is_err()
|
||||||
{
|
{
|
||||||
@@ -339,15 +327,15 @@ pub async fn start_multi_impedance_handler(context: SpawnCtx, header: VarHeader,
|
|||||||
}
|
}
|
||||||
|
|
||||||
context.impedance_setup.lock().await.running_mode = RunningMode::None;
|
context.impedance_setup.lock().await.running_mode = RunningMode::None;
|
||||||
info!("Impedance measurement stopped.");
|
info!("Impedance spectroscopy measurement stopped.");
|
||||||
STOP.reset();
|
STOP.reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn stop_multi_impedance_handler(context: &mut Context, _header: VarHeader, _rqst: ()) -> bool {
|
pub async fn stop_impedance_handler(context: &mut Context, _header: VarHeader, _rqst: ()) -> bool {
|
||||||
info!("Stop impedance measurement");
|
info!("Stop impedance measurement");
|
||||||
let was_busy = context.impedance_setup.lock().await.running_mode;
|
let was_busy = context.impedance_setup.lock().await.running_mode;
|
||||||
if was_busy == RunningMode::SingleFrequency2Lead || was_busy == RunningMode::SingleFrequency4Lead || was_busy == RunningMode::MultiFrequency2Lead(MeasurementPointSet::Eight) || was_busy == RunningMode::MultiFrequency2Lead(MeasurementPointSet::Eighteen) || was_busy == RunningMode::MultiFrequency4Lead(MeasurementPointSet::Eight) || was_busy == RunningMode::MultiFrequency4Lead(MeasurementPointSet::Eighteen) {
|
if was_busy == RunningMode::SingleFrequency2Lead || was_busy == RunningMode::SingleFrequency4Lead || was_busy == RunningMode::SweepFrequency2Lead(MeasurementPointSet::Eight) || was_busy == RunningMode::SweepFrequency2Lead(MeasurementPointSet::Eighteen) || was_busy == RunningMode::SweepFrequency4Lead(MeasurementPointSet::Eight) || was_busy == RunningMode::SweepFrequency4Lead(MeasurementPointSet::Eighteen) {
|
||||||
STOP.signal(());
|
STOP.signal(());
|
||||||
}
|
}
|
||||||
was_busy == RunningMode::SingleFrequency2Lead || was_busy == RunningMode::SingleFrequency4Lead || was_busy == RunningMode::MultiFrequency2Lead(MeasurementPointSet::Eight) || was_busy == RunningMode::MultiFrequency2Lead(MeasurementPointSet::Eighteen) || was_busy == RunningMode::MultiFrequency4Lead(MeasurementPointSet::Eight) || was_busy == RunningMode::MultiFrequency4Lead(MeasurementPointSet::Eighteen)
|
was_busy == RunningMode::SingleFrequency2Lead || was_busy == RunningMode::SingleFrequency4Lead || was_busy == RunningMode::SweepFrequency2Lead(MeasurementPointSet::Eight) || was_busy == RunningMode::SweepFrequency2Lead(MeasurementPointSet::Eighteen) || was_busy == RunningMode::SweepFrequency4Lead(MeasurementPointSet::Eight) || was_busy == RunningMode::SweepFrequency4Lead(MeasurementPointSet::Eighteen)
|
||||||
}
|
}
|
||||||
@@ -16,11 +16,11 @@ use num::complex::Complex;
|
|||||||
use crate::ad5940::*;
|
use crate::ad5940::*;
|
||||||
use crate::ad5940_registers::*;
|
use crate::ad5940_registers::*;
|
||||||
|
|
||||||
use bioz_icd_rs::{SingleImpedanceOutput, IcdDftNum, ImpedanceInitError, MeasurementPointSet, MultiImpedanceOutput};
|
use bioz_icd_rs::{SingleImpedanceOutput, IcdDftNum, ImpedanceInitError, MeasurementPointSet, SweepImpedanceOutput};
|
||||||
use crate::icd_mapping::IntoDftnum;
|
use crate::icd_mapping::IntoDftnum;
|
||||||
|
|
||||||
pub static IMPEDANCE_CHANNEL_SINGLE: Channel<ThreadModeRawMutex, SingleImpedanceOutput, 50> = Channel::new();
|
pub static IMPEDANCE_CHANNEL_SINGLE: Channel<ThreadModeRawMutex, SingleImpedanceOutput, 50> = Channel::new();
|
||||||
pub static IMPEDANCE_CHANNEL_MULTI: Channel<ThreadModeRawMutex, MultiImpedanceOutput, 5> = Channel::new();
|
pub static IMPEDANCE_CHANNEL_SWEEP: Channel<ThreadModeRawMutex, SweepImpedanceOutput, 5> = Channel::new();
|
||||||
|
|
||||||
pub type ImpedanceSetupType = Mutex<ThreadModeRawMutex, ImpedanceSetup>;
|
pub type ImpedanceSetupType = Mutex<ThreadModeRawMutex, ImpedanceSetup>;
|
||||||
pub static IMPEDANCE_SETUP: StaticCell<ImpedanceSetupType> = StaticCell::new();
|
pub static IMPEDANCE_SETUP: StaticCell<ImpedanceSetupType> = StaticCell::new();
|
||||||
@@ -32,8 +32,8 @@ pub enum RunningMode {
|
|||||||
None,
|
None,
|
||||||
SingleFrequency2Lead,
|
SingleFrequency2Lead,
|
||||||
SingleFrequency4Lead,
|
SingleFrequency4Lead,
|
||||||
MultiFrequency2Lead(MeasurementPointSet),
|
SweepFrequency2Lead(MeasurementPointSet),
|
||||||
MultiFrequency4Lead(MeasurementPointSet),
|
SweepFrequency4Lead(MeasurementPointSet),
|
||||||
}
|
}
|
||||||
|
|
||||||
pub enum RtiaCalibrated {
|
pub enum RtiaCalibrated {
|
||||||
@@ -303,7 +303,7 @@ impl ImpedanceSetup {
|
|||||||
if let Some(dsp_config) = &self.dsp_config {
|
if let Some(dsp_config) = &self.dsp_config {
|
||||||
wait_time = self.ad5940.sequencer_calculate_wait_time(dsp_config).await.unwrap();
|
wait_time = self.ad5940.sequencer_calculate_wait_time(dsp_config).await.unwrap();
|
||||||
sinus_periods_per_dft = wait_time as f32 / dsp_config.fsys.unwrap() as f32 * frequency as f32;
|
sinus_periods_per_dft = wait_time as f32 / dsp_config.fsys.unwrap() as f32 * frequency as f32;
|
||||||
info!("Sinus periods per DFT: {}", sinus_periods_per_dft);
|
// info!("Sinus periods per DFT: {}", sinus_periods_per_dft);
|
||||||
} else {
|
} else {
|
||||||
error!("DSP configuration not set, cannot calculate wait time");
|
error!("DSP configuration not set, cannot calculate wait time");
|
||||||
return Err(ImpedanceInitError::DSPNotSet);
|
return Err(ImpedanceInitError::DSPNotSet);
|
||||||
@@ -385,7 +385,7 @@ impl ImpedanceSetup {
|
|||||||
if let Some(dsp_config) = &self.dsp_config {
|
if let Some(dsp_config) = &self.dsp_config {
|
||||||
wait_time = self.ad5940.sequencer_calculate_wait_time(dsp_config).await.unwrap();
|
wait_time = self.ad5940.sequencer_calculate_wait_time(dsp_config).await.unwrap();
|
||||||
sinus_periods_per_dft = wait_time as f32 / dsp_config.fsys.unwrap() as f32 * frequency as f32;
|
sinus_periods_per_dft = wait_time as f32 / dsp_config.fsys.unwrap() as f32 * frequency as f32;
|
||||||
info!("Sinus periods per DFT: {}", sinus_periods_per_dft);
|
// info!("Sinus periods per DFT: {}", sinus_periods_per_dft);
|
||||||
} else {
|
} else {
|
||||||
error!("DSP configuration not set, cannot calculate wait time");
|
error!("DSP configuration not set, cannot calculate wait time");
|
||||||
return Err(ImpedanceInitError::DSPNotSet);
|
return Err(ImpedanceInitError::DSPNotSet);
|
||||||
@@ -464,7 +464,7 @@ impl ImpedanceSetup {
|
|||||||
Ok(sinus_periods_per_dft)
|
Ok(sinus_periods_per_dft)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn init_multi_frequency_measurement_2_lead<const N: usize>(&mut self, number_of_points: MeasurementPointSet) -> Result<heapless::Vec<f32, N>, ImpedanceInitError> {
|
pub async fn init_sweep_frequency_measurement_2_lead<const N: usize>(&mut self, number_of_points: MeasurementPointSet) -> Result<heapless::Vec<f32, N>, ImpedanceInitError> {
|
||||||
// Configure LP DAC and TIA
|
// Configure LP DAC and TIA
|
||||||
self.common_mode_output_enable(false).await.unwrap();
|
self.common_mode_output_enable(false).await.unwrap();
|
||||||
|
|
||||||
@@ -511,7 +511,7 @@ impl ImpedanceSetup {
|
|||||||
let periods_per_dft = wait_time as f32 / dsp_config.fsys.unwrap() as f32 * frequency as f32;
|
let periods_per_dft = wait_time as f32 / dsp_config.fsys.unwrap() as f32 * frequency as f32;
|
||||||
|
|
||||||
periods_per_dft_vec.push(periods_per_dft).unwrap();
|
periods_per_dft_vec.push(periods_per_dft).unwrap();
|
||||||
info!("{}Hz: Sinus periods per DFT: {}", frequency, periods_per_dft);
|
// info!("{}Hz: Sinus periods per DFT: {}", frequency, periods_per_dft);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
error!("DSP configuration not set, cannot calculate wait time");
|
error!("DSP configuration not set, cannot calculate wait time");
|
||||||
@@ -572,7 +572,7 @@ impl ImpedanceSetup {
|
|||||||
Ok(periods_per_dft_vec)
|
Ok(periods_per_dft_vec)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn init_multi_frequency_measurement_4_lead<const N: usize>(&mut self, number_of_points: MeasurementPointSet) -> Result<heapless::Vec<f32, N>, ImpedanceInitError> {
|
pub async fn init_sweep_frequency_measurement_4_lead<const N: usize>(&mut self, number_of_points: MeasurementPointSet) -> Result<heapless::Vec<f32, N>, ImpedanceInitError> {
|
||||||
// Configure LP DAC and TIA
|
// Configure LP DAC and TIA
|
||||||
self.common_mode_output_enable(true).await.unwrap();
|
self.common_mode_output_enable(true).await.unwrap();
|
||||||
|
|
||||||
@@ -631,8 +631,7 @@ impl ImpedanceSetup {
|
|||||||
let periods_per_dft = wait_time as f32 / dsp_config.fsys.unwrap() as f32 * frequency as f32;
|
let periods_per_dft = wait_time as f32 / dsp_config.fsys.unwrap() as f32 * frequency as f32;
|
||||||
|
|
||||||
periods_per_dft_vec.push(periods_per_dft).unwrap();
|
periods_per_dft_vec.push(periods_per_dft).unwrap();
|
||||||
info!("{}Hz: Sinus periods per DFT: {}", frequency, periods_per_dft);
|
// info!("{}Hz: Sinus periods per DFT: {}", frequency, periods_per_dft);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
error!("DSP configuration not set, cannot calculate wait time");
|
error!("DSP configuration not set, cannot calculate wait time");
|
||||||
return Err(ImpedanceInitError::DSPNotSet);
|
return Err(ImpedanceInitError::DSPNotSet);
|
||||||
@@ -726,7 +725,7 @@ pub async fn impedance_setup_readout_task(mut pin: ExtiInput<'static>, impedance
|
|||||||
let mut impedance_setup = impedance_setup.lock().await;
|
let mut impedance_setup = impedance_setup.lock().await;
|
||||||
|
|
||||||
// Trigger the sequencer again
|
// Trigger the sequencer again
|
||||||
if impedance_setup.running_mode == RunningMode::SingleFrequency2Lead || impedance_setup.running_mode == RunningMode::SingleFrequency4Lead || impedance_setup.running_mode == RunningMode::MultiFrequency2Lead(MeasurementPointSet::Eight) || impedance_setup.running_mode == RunningMode::MultiFrequency2Lead(MeasurementPointSet::Eighteen) || impedance_setup.running_mode == RunningMode::MultiFrequency4Lead(MeasurementPointSet::Eight) || impedance_setup.running_mode == RunningMode::MultiFrequency4Lead(MeasurementPointSet::Eighteen) {
|
if impedance_setup.running_mode == RunningMode::SingleFrequency2Lead || impedance_setup.running_mode == RunningMode::SingleFrequency4Lead || impedance_setup.running_mode == RunningMode::SweepFrequency2Lead(MeasurementPointSet::Eight) || impedance_setup.running_mode == RunningMode::SweepFrequency2Lead(MeasurementPointSet::Eighteen) || impedance_setup.running_mode == RunningMode::SweepFrequency4Lead(MeasurementPointSet::Eight) || impedance_setup.running_mode == RunningMode::SweepFrequency4Lead(MeasurementPointSet::Eighteen) {
|
||||||
impedance_setup.start_measurement().await;
|
impedance_setup.start_measurement().await;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -780,7 +779,7 @@ pub async fn impedance_setup_readout_task(mut pin: ExtiInput<'static>, impedance
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
RunningMode::MultiFrequency2Lead(points) => {
|
RunningMode::SweepFrequency2Lead(points) => {
|
||||||
// Each frequency point produces 4 samples (DFT real/imag for Rcal and Rz)
|
// Each frequency point produces 4 samples (DFT real/imag for Rcal and Rz)
|
||||||
let required_count = points.len() * 4;
|
let required_count = points.len() * 4;
|
||||||
|
|
||||||
@@ -791,7 +790,7 @@ pub async fn impedance_setup_readout_task(mut pin: ExtiInput<'static>, impedance
|
|||||||
impedance_setup.read_fifo(data_slice).await.unwrap();
|
impedance_setup.read_fifo(data_slice).await.unwrap();
|
||||||
|
|
||||||
// Output structure
|
// Output structure
|
||||||
let mut impedance_output = MultiImpedanceOutput {
|
let mut impedance_output = SweepImpedanceOutput {
|
||||||
points,
|
points,
|
||||||
magnitudes_8: Vec::new(),
|
magnitudes_8: Vec::new(),
|
||||||
phases_8: Vec::new(),
|
phases_8: Vec::new(),
|
||||||
@@ -815,11 +814,11 @@ pub async fn impedance_setup_readout_task(mut pin: ExtiInput<'static>, impedance
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
IMPEDANCE_CHANNEL_MULTI.try_send(impedance_output).ok();
|
IMPEDANCE_CHANNEL_SWEEP.try_send(impedance_output).ok();
|
||||||
}
|
}
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
RunningMode::MultiFrequency4Lead(points) => {
|
RunningMode::SweepFrequency4Lead(points) => {
|
||||||
// Each frequency point produces 4 samples (DFT real/imag for Rcal and Rz)
|
// Each frequency point produces 4 samples (DFT real/imag for Rcal and Rz)
|
||||||
let required_count = points.len() * 4;
|
let required_count = points.len() * 4;
|
||||||
|
|
||||||
@@ -830,7 +829,7 @@ pub async fn impedance_setup_readout_task(mut pin: ExtiInput<'static>, impedance
|
|||||||
impedance_setup.read_fifo(data_slice).await.unwrap();
|
impedance_setup.read_fifo(data_slice).await.unwrap();
|
||||||
|
|
||||||
// Output structure
|
// Output structure
|
||||||
let mut impedance_output = MultiImpedanceOutput {
|
let mut impedance_output = SweepImpedanceOutput {
|
||||||
points,
|
points,
|
||||||
magnitudes_8: Vec::new(),
|
magnitudes_8: Vec::new(),
|
||||||
phases_8: Vec::new(),
|
phases_8: Vec::new(),
|
||||||
@@ -865,7 +864,7 @@ pub async fn impedance_setup_readout_task(mut pin: ExtiInput<'static>, impedance
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
IMPEDANCE_CHANNEL_MULTI.try_send(impedance_output).ok();
|
IMPEDANCE_CHANNEL_SWEEP.try_send(impedance_output).ok();
|
||||||
}
|
}
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user