forked from M-Labs/kirdy
laser: Add driver and fn to get termination status
This commit is contained in:
parent
f6677d874c
commit
4e0d14def2
|
@ -82,6 +82,7 @@ pub fn setup(
|
||||||
gpiob.pb14.into_push_pull_output(),
|
gpiob.pb14.into_push_pull_output(),
|
||||||
),
|
),
|
||||||
current_source_short_pin: gpioa.pa4.into_push_pull_output(),
|
current_source_short_pin: gpioa.pa4.into_push_pull_output(),
|
||||||
|
termination_status_pin: gpiod.pd7.internal_pull_up(true),
|
||||||
};
|
};
|
||||||
|
|
||||||
let pd_mon_phy = LdPwrExcProtectorPhy {
|
let pd_mon_phy = LdPwrExcProtectorPhy {
|
||||||
|
|
|
@ -174,4 +174,8 @@ impl LdDrive{
|
||||||
pub fn set_pd_i_limit(&mut self, i: ElectricCurrent){
|
pub fn set_pd_i_limit(&mut self, i: ElectricCurrent){
|
||||||
LdPwrExcProtector::set_trigger_threshold_v(i / Settings::PD_MON_TRANSCONDUCTANCE);
|
LdPwrExcProtector::set_trigger_threshold_v(i / Settings::PD_MON_TRANSCONDUCTANCE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn get_term_status(&mut self)->bool{
|
||||||
|
self.ctrl.get_term_status()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
use stm32f4xx_hal::{
|
use stm32f4xx_hal::{
|
||||||
gpio::{gpioa::*, gpiob::*, gpiod::*, Alternate, Output, PushPull},
|
gpio::{gpioa::*, gpiob::*, gpiod::*, Alternate, Input, Output, PushPull},
|
||||||
hal::{blocking::spi::Transfer, digital::v2::OutputPin},
|
hal::{blocking::spi::Transfer, digital::{v2::OutputPin, v2::InputPin}},
|
||||||
pac::SPI2,
|
pac::SPI2,
|
||||||
spi::{NoMiso, Spi, TransferModeNormal},
|
spi::{NoMiso, Spi, TransferModeNormal},
|
||||||
};
|
};
|
||||||
|
@ -15,6 +15,7 @@ use crate::laser_diode::laser_diode::TransimpedanceUnit;
|
||||||
|
|
||||||
pub trait ChannelPins {
|
pub trait ChannelPins {
|
||||||
type CurrentSourceShort: OutputPin;
|
type CurrentSourceShort: OutputPin;
|
||||||
|
type TerminationStatus: InputPin;
|
||||||
type Max5719Load: OutputPin;
|
type Max5719Load: OutputPin;
|
||||||
type Max5719Cs: OutputPin;
|
type Max5719Cs: OutputPin;
|
||||||
type Max5719Spi: Transfer<u8>;
|
type Max5719Spi: Transfer<u8>;
|
||||||
|
@ -23,11 +24,13 @@ pub trait ChannelPins {
|
||||||
pub struct LdCtrlPhy<C: ChannelPins> {
|
pub struct LdCtrlPhy<C: ChannelPins> {
|
||||||
pub dac: Dac<C::Max5719Spi, C::Max5719Cs, C::Max5719Load>,
|
pub dac: Dac<C::Max5719Spi, C::Max5719Cs, C::Max5719Load>,
|
||||||
pub current_source_short_pin: C::CurrentSourceShort,
|
pub current_source_short_pin: C::CurrentSourceShort,
|
||||||
|
pub termination_status_pin: C::TerminationStatus
|
||||||
}
|
}
|
||||||
pub struct Channel0;
|
pub struct Channel0;
|
||||||
|
|
||||||
impl ChannelPins for Channel0 {
|
impl ChannelPins for Channel0 {
|
||||||
type CurrentSourceShort = PA4<Output<PushPull>>;
|
type CurrentSourceShort = PA4<Output<PushPull>>;
|
||||||
|
type TerminationStatus = PD7<Input>;
|
||||||
type Max5719Load = DacLoad;
|
type Max5719Load = DacLoad;
|
||||||
type Max5719Cs = DacCs;
|
type Max5719Cs = DacCs;
|
||||||
type Max5719Spi = DacSpi;
|
type Max5719Spi = DacSpi;
|
||||||
|
@ -58,6 +61,10 @@ impl LdCtrl {
|
||||||
self.phy.current_source_short_pin.set_high();
|
self.phy.current_source_short_pin.set_high();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn get_term_status(&mut self)-> bool{
|
||||||
|
self.phy.termination_status_pin.is_high()
|
||||||
|
}
|
||||||
|
|
||||||
pub fn set_dac(&mut self, voltage: ElectricPotential, dac_out_v_max: ElectricPotential) -> ElectricPotential {
|
pub fn set_dac(&mut self, voltage: ElectricPotential, dac_out_v_max: ElectricPotential) -> ElectricPotential {
|
||||||
let value = ((voltage / dac_out_v_max).get::<ratio>()
|
let value = ((voltage / dac_out_v_max).get::<ratio>()
|
||||||
* (max5719::MAX_VALUE as f64)) as u32;
|
* (max5719::MAX_VALUE as f64)) as u32;
|
||||||
|
|
|
@ -84,6 +84,7 @@ fn main() -> ! {
|
||||||
info!("pd_mon_v: {:?}", volt_fmt.with(laser.pd_mon_status().v));
|
info!("pd_mon_v: {:?}", volt_fmt.with(laser.pd_mon_status().v));
|
||||||
info!("power_excursion: {:?}", laser.pd_mon_status().pwr_excursion);
|
info!("power_excursion: {:?}", laser.pd_mon_status().pwr_excursion);
|
||||||
|
|
||||||
|
info!("Termination Status: {:?}", laser.get_term_status());
|
||||||
sys_timer::sleep(500);
|
sys_timer::sleep(500);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue