mirror of
https://github.com/hubaldv/bioz-firmware-rs.git
synced 2025-12-06 05:01:18 +00:00
Implemented LP DAC for enabling common-mode during 4-lead measurement.
This commit is contained in:
@@ -83,6 +83,9 @@ impl ImpedanceSetup {
|
||||
|
||||
self.ad5940.apply_clk_config(&clk_config).await.unwrap();
|
||||
|
||||
// Configure LP DAC and TIA
|
||||
self.common_mode_output_enable(false).await.unwrap();
|
||||
|
||||
// Set DSP configuration
|
||||
let mut dsp_config = DspConfig::default();
|
||||
dsp_config
|
||||
@@ -253,7 +256,36 @@ impl ImpedanceSetup {
|
||||
Ok(results)
|
||||
}
|
||||
|
||||
pub async fn common_mode_output_enable(&mut self, enable: bool) -> Result<(), Error> {
|
||||
// Configure LP DAC and TIA
|
||||
let mut lp_config = LpConfig::default();
|
||||
|
||||
if enable {
|
||||
lp_config
|
||||
.data_reset(true)
|
||||
.power_enable(true)
|
||||
.data_6bit(31) // Mid-scale for 6-bit DAC
|
||||
.common_mode_enable(true)
|
||||
.tia_switches_enabled(1 << 5 | 1 << 7 | 1 << 9 | 1 << 13)
|
||||
.tia_enable(true)
|
||||
.filter_resistor(TIARF::R20k);
|
||||
|
||||
} else {
|
||||
lp_config
|
||||
.power_enable(false)
|
||||
.common_mode_enable(false)
|
||||
.tia_enable(false);
|
||||
}
|
||||
|
||||
self.ad5940.apply_lp_config(&lp_config).await.unwrap();
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub async fn init_single_frequency_measurement_2_lead(&mut self, frequency: u32, dft_number: IcdDftNum) -> Result<f32, ImpedanceInitError> {
|
||||
// Configure LP DAC and TIA
|
||||
self.common_mode_output_enable(false).await.unwrap();
|
||||
|
||||
// Reset FIFO
|
||||
self.ad5940.clear_and_enable_fifo().await.unwrap();
|
||||
|
||||
@@ -333,6 +365,9 @@ impl ImpedanceSetup {
|
||||
}
|
||||
|
||||
pub async fn init_single_frequency_measurement_4_lead(&mut self, frequency: u32, dft_number: IcdDftNum) -> Result<f32, ImpedanceInitError> {
|
||||
// Configure LP DAC and TIA
|
||||
self.common_mode_output_enable(true).await.unwrap();
|
||||
|
||||
// Reset FIFO
|
||||
self.ad5940.clear_and_enable_fifo().await.unwrap();
|
||||
|
||||
@@ -430,6 +465,9 @@ impl ImpedanceSetup {
|
||||
}
|
||||
|
||||
pub async fn init_multi_frequency_measurement_2_lead<const N: usize>(&mut self, number_of_points: MeasurementPointSet) -> Result<heapless::Vec<f32, N>, ImpedanceInitError> {
|
||||
// Configure LP DAC and TIA
|
||||
self.common_mode_output_enable(false).await.unwrap();
|
||||
|
||||
// Create vector to store the periods per DFT for each frequency
|
||||
let mut periods_per_dft_vec = heapless::Vec::<f32, N>::new();
|
||||
|
||||
@@ -535,6 +573,9 @@ impl ImpedanceSetup {
|
||||
}
|
||||
|
||||
pub async fn init_multi_frequency_measurement_4_lead<const N: usize>(&mut self, number_of_points: MeasurementPointSet) -> Result<heapless::Vec<f32, N>, ImpedanceInitError> {
|
||||
// Configure LP DAC and TIA
|
||||
self.common_mode_output_enable(true).await.unwrap();
|
||||
|
||||
// Create vector to store the periods per DFT for each frequency
|
||||
let mut periods_per_dft_vec = heapless::Vec::<f32, N>::new();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user