ld_drive: Add fns to get pd current & cal ld pwr

This commit is contained in:
linuswck 2024-01-09 16:11:50 +08:00
parent 707fac0775
commit b1123047c7
1 changed files with 10 additions and 1 deletions

View File

@ -4,7 +4,7 @@ use core::{marker::PhantomData, f64::NAN};
use uom::si::{
electric_current::{milliampere},
f64::{ElectricPotential, ElectricCurrent, ElectricalResistance},
f64::{ElectricPotential, ElectricCurrent, ElectricalResistance, Power},
};
use uom::{si::{ISQ, SI, Quantity}, typenum::*};
@ -87,6 +87,15 @@ impl LD_Drive{
self.ctrl.ld_short_disable();
}
pub fn get_ld_power_output(&mut self) -> Power {
let pd_i = self.get_pd_i();
pd_i * self.settings.pd_i_to_out_pwr
}
pub fn get_pd_i(&mut self) -> ElectricCurrent {
self.ctrl.get_pd_mon_v() * Settings::PD_MON_TRANSCONDUCTANCE
}
pub fn ld_set_i(&mut self, i: ElectricCurrent) -> ElectricCurrent {
let ld_i_set = self.ctrl.set_i(i, Settings::LD_DRIVE_TRANSIMPEDANCE, Settings::DAC_OUT_V_MAX);
self.settings.ld_drive_current = ld_i_set;