ld: Set default ld_current_limit in setup() fn

This commit is contained in:
linuswck 2024-02-20 16:22:13 +08:00
parent 88cca12a60
commit 30ab228b4b
2 changed files with 7 additions and 2 deletions

View File

@ -75,7 +75,6 @@ pub fn bootup(
let mut laser = LdDrive::new(current_source, perif.ADC2, perif.TIM2.counter(&clocks), pd_mon_phy);
laser.setup();
laser.ld_open();
laser.set_ld_drive_current_limit(ElectricCurrent::new::<ampere>(0.2));
laser.ld_set_i(ElectricCurrent::new::<ampere>(0.0));
laser.set_pd_i_limit(ElectricCurrent::new::<milliampere>(2.5));
laser.set_pd_mon_calibrated_vdda(thermostat.get_calibrated_vdda());

View File

@ -22,6 +22,11 @@ pub type TransimpedanceUnit = Quantity<ISQ<P2, P1, N3, N2, Z0, Z0, Z0>, SI<f64>,
type TransconductanceUnit = Quantity<ISQ<N2, N1, P3, P2, Z0, Z0, Z0>, SI<f64>, f64>;
impl Settings{
pub const LD_CURRENT_MAX: ElectricCurrent = ElectricCurrent {
dimension: PhantomData,
units: PhantomData,
value: 0.3,
};
pub const DAC_OUT_V_MAX: ElectricPotential = ElectricPotential {
dimension: PhantomData,
units: PhantomData,
@ -89,6 +94,7 @@ impl LdDrive{
pub fn setup(&mut self) {
LdPwrExcProtector::pwr_off();
self.ctrl.set_i(ElectricCurrent::new::<milliampere>(0.0), Settings::LD_DRIVE_TRANSIMPEDANCE, Settings::DAC_OUT_V_MAX);
self.set_ld_drive_current_limit(Settings::LD_CURRENT_MAX);
LdCurrentOutCtrlTimer::reset();
self.ld_short();
}
@ -98,7 +104,7 @@ impl LdDrive{
}
pub fn set_ld_drive_current_limit(&mut self, i_limit: ElectricCurrent){
self.settings.ld_drive_current_limit = i_limit;
self.settings.ld_drive_current_limit = i_limit.min(Settings::LD_CURRENT_MAX);
}
pub fn ld_short(&mut self) {