forked from M-Labs/kirdy
Clean up warnings
This commit is contained in:
parent
59f2385ecf
commit
e48f1979f0
@ -1,7 +1,8 @@
|
||||
use core::marker::PhantomData;
|
||||
use super::{gpio, sys_timer, usb};
|
||||
use crate::laser_diode::current_sources::{*, self};
|
||||
use crate::laser_diode::ld_drive::LD_Drive;
|
||||
use crate::thermostat::max1968::{MAX1968};
|
||||
use crate::laser_diode::current_sources::{*};
|
||||
use crate::laser_diode::ld_drive::{self, LdDrive};
|
||||
use crate::thermostat::max1968::MAX1968;
|
||||
use crate::thermostat::thermostat::Thermostat;
|
||||
use fugit::ExtU32;
|
||||
use log::info;
|
||||
@ -22,7 +23,7 @@ const WATCHDOG_PERIOD: u32 = 30000;
|
||||
pub fn bootup(
|
||||
mut core_perif: CorePeripherals,
|
||||
perif: Peripherals,
|
||||
) -> (IndependentWatchdog, LD_Drive, Thermostat) {
|
||||
) -> (IndependentWatchdog, LdDrive, Thermostat) {
|
||||
core_perif.SCB.enable_icache();
|
||||
core_perif.SCB.enable_dcache(&mut core_perif.CPUID);
|
||||
|
||||
@ -58,13 +59,15 @@ pub fn bootup(
|
||||
|
||||
let current_source = CurrentSource::new(current_source_phy, perif.ADC2);
|
||||
|
||||
let mut laser = LD_Drive::new(current_source);
|
||||
let mut laser = LdDrive::new(current_source);
|
||||
laser.setup();
|
||||
laser.ld_open();
|
||||
laser.power_up();
|
||||
|
||||
laser.ld_set_i(ElectricCurrent::new::<ampere>(0.15));
|
||||
|
||||
// Set a non-zero value so that there is a non NAN power reading
|
||||
laser.set_pd_i_to_out_pwr(ld_drive::IToPowerUnit {dimension: PhantomData, units: PhantomData, value: 0.001});
|
||||
|
||||
let tec_driver = MAX1968::new(max1968_phy, perif.ADC1);
|
||||
|
||||
|
@ -2,7 +2,6 @@ use crate::laser_diode::current_sources::{self, CurrentSourcePhy};
|
||||
use crate::laser_diode::max5719;
|
||||
use crate::thermostat::ad5680;
|
||||
use crate::thermostat::max1968::{self, MAX1968PinSet, MAX1968Phy, PWM_FREQ_KHZ};
|
||||
use fugit::RateExtU32;
|
||||
use stm32_eth::EthPins;
|
||||
use stm32f4xx_hal::{
|
||||
gpio::{gpioa::*, gpiob::*, gpioc::*, gpiog::*, GpioExt, Input},
|
||||
@ -12,7 +11,6 @@ use stm32f4xx_hal::{
|
||||
TIM4,
|
||||
},
|
||||
rcc::Clocks,
|
||||
spi,
|
||||
spi::{NoMiso, Spi},
|
||||
timer::pwm::PwmExt,
|
||||
};
|
||||
|
@ -16,7 +16,7 @@ use uom::si::{
|
||||
};
|
||||
|
||||
use crate::laser_diode::max5719::{self, Dac};
|
||||
use crate::laser_diode::ld_drive::transimpedance_unit;
|
||||
use crate::laser_diode::ld_drive::TransimpedanceUnit;
|
||||
|
||||
pub trait ChannelPins {
|
||||
type PdMonPin;
|
||||
@ -106,7 +106,7 @@ impl CurrentSource {
|
||||
voltage
|
||||
}
|
||||
|
||||
pub fn set_i(&mut self, current: ElectricCurrent, transimpedance: transimpedance_unit, dac_out_v_max: ElectricPotential) -> ElectricCurrent {
|
||||
pub fn set_i(&mut self, current: ElectricCurrent, transimpedance: TransimpedanceUnit, dac_out_v_max: ElectricPotential) -> ElectricCurrent {
|
||||
self.set_dac(current * transimpedance, dac_out_v_max) / transimpedance
|
||||
}
|
||||
}
|
@ -3,26 +3,20 @@ use crate::laser_diode::current_sources::CurrentSource;
|
||||
use core::{marker::PhantomData, f64::NAN};
|
||||
|
||||
use uom::si::{
|
||||
electric_current::{milliampere},
|
||||
f64::{ElectricPotential, ElectricCurrent, ElectricalResistance, Power},
|
||||
electric_current::milliampere,
|
||||
f64::{ElectricPotential, ElectricCurrent, Power},
|
||||
};
|
||||
|
||||
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>;
|
||||
pub type TransimpedanceUnit = 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>;
|
||||
type TransconductanceUnit = 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>;
|
||||
pub type IToPowerUnit = 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,
|
||||
@ -30,13 +24,13 @@ impl Settings{
|
||||
};
|
||||
|
||||
// Unit: A/V
|
||||
const PD_MON_TRANSCONDUCTANCE: transconductance_unit = transconductance_unit {
|
||||
const PD_MON_TRANSCONDUCTANCE: TransconductanceUnit = TransconductanceUnit {
|
||||
dimension: PhantomData,
|
||||
units: PhantomData,
|
||||
value: 0.001,
|
||||
};
|
||||
|
||||
const LD_DRIVE_TRANSIMPEDANCE: transimpedance_unit = transimpedance_unit {
|
||||
const LD_DRIVE_TRANSIMPEDANCE: TransimpedanceUnit = TransimpedanceUnit {
|
||||
dimension: PhantomData,
|
||||
units: PhantomData,
|
||||
value: 10.0 / 0.75,
|
||||
@ -46,26 +40,26 @@ impl Settings{
|
||||
#[derive(Clone, Debug, Miniconf)]
|
||||
pub struct Settings {
|
||||
ld_drive_current: ElectricCurrent,
|
||||
pd_i_to_out_pwr: i_to_power_unit,
|
||||
pd_i_to_out_pwr: IToPowerUnit,
|
||||
}
|
||||
|
||||
impl Default for Settings {
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
ld_drive_current: ElectricCurrent::new::<milliampere>(0.0),
|
||||
pd_i_to_out_pwr: i_to_power_unit {dimension: PhantomData, units: PhantomData, value: NAN}
|
||||
pd_i_to_out_pwr: IToPowerUnit {dimension: PhantomData, units: PhantomData, value: NAN}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub struct LD_Drive{
|
||||
pub struct LdDrive{
|
||||
ctrl: CurrentSource,
|
||||
settings: Settings,
|
||||
}
|
||||
|
||||
impl LD_Drive{
|
||||
impl LdDrive{
|
||||
pub fn new(current_source: CurrentSource)-> Self{
|
||||
LD_Drive {
|
||||
LdDrive {
|
||||
ctrl: current_source,
|
||||
settings: Settings::default()
|
||||
}
|
||||
@ -89,7 +83,7 @@ impl LD_Drive{
|
||||
self.settings.ld_drive_current
|
||||
}
|
||||
|
||||
pub fn set_pd_i_to_out_pwr(&mut self, val: i_to_power_unit){
|
||||
pub fn set_pd_i_to_out_pwr(&mut self, val: IToPowerUnit){
|
||||
self.settings.pd_i_to_out_pwr = val;
|
||||
}
|
||||
|
||||
|
@ -1,9 +1,5 @@
|
||||
use core::marker::PhantomData;
|
||||
use core::u16;
|
||||
|
||||
use crate::thermostat::ad5680;
|
||||
use crate::thermostat::thermostat::Settings;
|
||||
|
||||
use fugit::KilohertzU32;
|
||||
use stm32f4xx_hal::{
|
||||
adc::{
|
||||
@ -13,16 +9,13 @@ use stm32f4xx_hal::{
|
||||
gpio::{gpioa::*, gpiob::*, gpioc::*, Alternate, Analog, Output, PushPull},
|
||||
hal::{self, blocking::spi::Transfer, digital::v2::OutputPin},
|
||||
pac::{ADC1, SPI1, TIM4},
|
||||
rcc::Clocks,
|
||||
spi::{NoMiso, Spi, TransferModeNormal},
|
||||
timer::pwm::{PwmChannel, PwmExt},
|
||||
timer::pwm::PwmChannel,
|
||||
};
|
||||
|
||||
use uom::si::{
|
||||
electric_current::ampere,
|
||||
electric_potential::{millivolt, volt},
|
||||
electrical_resistance::ohm,
|
||||
f64::{ElectricCurrent, ElectricPotential, ElectricalResistance},
|
||||
electric_potential::millivolt,
|
||||
f64::ElectricPotential,
|
||||
ratio::ratio,
|
||||
};
|
||||
|
||||
|
@ -3,7 +3,6 @@ use crate::sys_timer;
|
||||
use crate::thermostat::ad5680;
|
||||
use crate::thermostat::max1968::{MAX1968, AdcReadTarget, PwmPinsEnum};
|
||||
use log::info;
|
||||
use miniconf::serde::de::value;
|
||||
use uom::si::{
|
||||
electric_current::ampere,
|
||||
electric_potential::volt,
|
||||
|
Loading…
Reference in New Issue
Block a user