forked from M-Labs/kirdy
Add MAX1968 Startup Sequence
This commit is contained in:
parent
f6767b147b
commit
0179e7641a
|
@ -1,5 +1,6 @@
|
||||||
use super::{gpio, sys_timer, usb};
|
use super::{gpio, sys_timer, usb};
|
||||||
use crate::{laser_diode::current_sources::*, thermostat::max1968};
|
use crate::{laser_diode::current_sources::*};
|
||||||
|
use crate::{thermostat::max1968::MAX1968}
|
||||||
use fugit::ExtU32;
|
use fugit::ExtU32;
|
||||||
use log::info;
|
use log::info;
|
||||||
use stm32f4xx_hal::{
|
use stm32f4xx_hal::{
|
||||||
|
@ -9,6 +10,11 @@ use stm32f4xx_hal::{
|
||||||
watchdog::IndependentWatchdog,
|
watchdog::IndependentWatchdog,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
use uom::si::{
|
||||||
|
electric_current::ampere,
|
||||||
|
f64::ElectricCurrent,
|
||||||
|
};
|
||||||
|
|
||||||
#[cfg(not(feature = "semihosting"))]
|
#[cfg(not(feature = "semihosting"))]
|
||||||
const WATCHDOG_PERIOD: u32 = 1000;
|
const WATCHDOG_PERIOD: u32 = 1000;
|
||||||
#[cfg(feature = "semihosting")]
|
#[cfg(feature = "semihosting")]
|
||||||
|
@ -58,7 +64,12 @@ pub fn bootup(mut core_perif: CorePeripherals, perif: Peripherals) -> Independen
|
||||||
laser.setup();
|
laser.setup();
|
||||||
laser.set_current(0.1).unwrap();
|
laser.set_current(0.1).unwrap();
|
||||||
|
|
||||||
let tec_driver = max1968::MAX1968::new(max1968_phy, perif.ADC1);
|
let mut tec_driver = MAX1968::new(max1968_phy, perif.ADC1);
|
||||||
|
tec_driver.setup();
|
||||||
|
|
||||||
|
tec_driver.set_i(ElectricCurrent::new::<ampere>(1.0));
|
||||||
|
|
||||||
|
tec_driver.power_up();
|
||||||
|
|
||||||
let mut wd = IndependentWatchdog::new(perif.IWDG);
|
let mut wd = IndependentWatchdog::new(perif.IWDG);
|
||||||
wd.start(WATCHDOG_PERIOD.millis());
|
wd.start(WATCHDOG_PERIOD.millis());
|
||||||
|
|
|
@ -143,6 +143,20 @@ impl MAX1968 {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn setup(&mut self){
|
||||||
|
self.power_down();
|
||||||
|
|
||||||
|
let vref = self.adc_read(AdcReadTarget::VREF, 2048);
|
||||||
|
self.set_center_point(vref);
|
||||||
|
|
||||||
|
// Todo: Add Calibration here
|
||||||
|
self.set_max_v(ElectricPotential::new::<volt>(5.0));
|
||||||
|
self.set_max_i_pos(ElectricCurrent::new::<ampere>(1.0));
|
||||||
|
self.set_max_i_neg(ElectricCurrent::new::<ampere>(1.0));
|
||||||
|
|
||||||
|
self.set_i(ElectricCurrent::new::<ampere>(0.0));
|
||||||
|
}
|
||||||
|
|
||||||
pub fn power_down(&mut self) {
|
pub fn power_down(&mut self) {
|
||||||
let _ = self.shdn.set_low();
|
let _ = self.shdn.set_low();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue