main: Add demo fns reading all hardware status

This commit is contained in:
linuswck 2024-01-11 13:15:19 +08:00
parent 33d9cb45c4
commit 33ff0c3678

View File

@ -8,9 +8,13 @@ use stm32f4xx_hal::pac::{CorePeripherals, Peripherals};
mod device;
mod laser_diode;
mod thermostat;
use device::{boot::bootup, log_setup, sys_timer};
use crate::thermostat::max1968;
use device::{boot::bootup, log_setup, sys_timer};
use uom::fmt::DisplayStyle::Abbreviation;
use uom::si::electric_potential::volt;
use uom::si::electric_current::{ampere, milliampere};
use uom::si::power::milliwatt;
use uom::si::f64::{ElectricPotential, ElectricCurrent, Power};
// If RTT is used, print panic info through RTT
#[cfg(all(feature = "RTT", not(test)))]
@ -34,11 +38,26 @@ fn main() -> ! {
let core_perif = CorePeripherals::take().unwrap();
let perif = Peripherals::take().unwrap();
let (mut wd, mut tec_driver, mut laser,) = bootup(core_perif, perif);
let (mut wd, mut laser, mut thermostat,) = bootup(core_perif, perif);
// https://github.com/iliekturtles/uom/blob/master/examples/si.rs
let volt_fmt = ElectricPotential::format_args(volt, Abbreviation);
let amp_fmt = ElectricCurrent::format_args(ampere, Abbreviation);
let mili_amp_fmt = ElectricCurrent::format_args(milliampere, Abbreviation);
let mili_watt_fmt = Power::format_args(milliwatt, Abbreviation);
loop {
wd.feed();
info!("looping");
info!("curr_ld_power: {:?}", mili_watt_fmt.with(laser.get_ld_power_output()));
info!("curr_ld_drive_cuurent: {:?}", mili_amp_fmt.with(laser.get_ld_drive_current()));
info!("curr_dac_vfb: {:?}", volt_fmt.with(thermostat.get_dac_vfb()));
info!("curr_vref: {:?}", volt_fmt.with(thermostat.get_vref()));
info!("curr_tec_i: {:?}", amp_fmt.with(thermostat.get_tec_i()));
info!("curr_tec_v: {:?}", volt_fmt.with(thermostat.get_tec_v()));
sys_timer::sleep(10);
}
}