1
0
forked from M-Labs/kirdy

ld_drive: add unit type and hw related constant

This commit is contained in:
linuswck 2024-01-09 15:58:31 +08:00
parent 590ba8171c
commit 58a8b15c40
2 changed files with 39 additions and 16 deletions

View File

@ -1,6 +1,5 @@
use super::{gpio, sys_timer, usb};
use crate::laser_diode::current_sources::*;
use crate::laser_diode::pd_mon::PdMon;
use crate::thermostat::max1968::{MAX1968};
use crate::thermostat::thermostat::Thermostat;
use fugit::ExtU32;
@ -39,7 +38,7 @@ pub fn bootup(
sys_timer::setup(core_perif.SYST, clocks);
let (_eth_pins, usb, current_source_phy, pd_mon_phy, max1968_phy) = gpio::setup(
let (_eth_pins, usb, current_source_phy, max1968_phy) = gpio::setup(
clocks,
perif.TIM4,
perif.GPIOA,
@ -56,19 +55,6 @@ pub fn bootup(
usb::State::setup(usb);
let mut laser = CurrentSource {
phy: current_source_phy,
setting: CurrentSourceSettings {
output_current: 0.0,
},
};
laser.setup();
laser.set_current(0.1).unwrap();
let mut pd_mon = PdMon::new(pd_mon_phy, perif.ADC2);
let tec_driver = MAX1968::new(max1968_phy, perif.ADC1);
let mut thermostat = Thermostat::new(tec_driver);

View File

@ -1,11 +1,48 @@
use miniconf::Miniconf;
use crate::laser_diode::current_sources::CurrentSource;
use core::marker::PhantomData;
use uom::si::{
electric_current::{milliampere},
f64::ElectricCurrent,
f64::{ElectricPotential, ElectricCurrent, ElectricalResistance},
};
use uom::{si::{ISQ, SI, Quantity}, typenum::*};
// Volt / Ampere
pub type transimpedance_unit = Quantity<ISQ<P2, P1, N3, N2, Z0, Z0, Z0>, SI<f64>, f64>;
// Ampere / Volt
type transconductance_unit = Quantity<ISQ<N2, N1, P3, P2, Z0, Z0, Z0>, SI<f64>, f64>;
// Watt / Ampere
pub type i_to_power_unit = Quantity<ISQ<P2, P1, N3, N1, Z0, Z0, Z0>, SI<f64>, f64>;
impl Settings{
pub const R_SENSE: ElectricalResistance = ElectricalResistance {
dimension: PhantomData,
units: PhantomData,
value: 10.0,
};
pub const DAC_OUT_V_MAX: ElectricPotential = ElectricPotential {
dimension: PhantomData,
units: PhantomData,
value: 4.096,
};
// Unit: A/V
const PD_MON_TRANSCONDUCTANCE: transconductance_unit = transconductance_unit {
dimension: PhantomData,
units: PhantomData,
value: 0.001,
};
const LD_DRIVE_TRANSIMPEDANCE: transimpedance_unit = transimpedance_unit {
dimension: PhantomData,
units: PhantomData,
value: 10.0 / 0.75,
};
}
#[derive(Clone, Debug, Miniconf)]
pub struct Settings {
pub ld_drive_current: ElectricCurrent,