tec: keep shdn off until first use
This commit is contained in:
parent
6041e41716
commit
ecdebe76bc
@ -35,44 +35,47 @@ impl fmt::Display for TecPin {
|
||||
}
|
||||
}
|
||||
|
||||
fn enable_shdn<G>(gpio: G)
|
||||
fn setup_shdn<G>(gpio: G) -> GpioOutput<G>
|
||||
where
|
||||
G: Gpio,
|
||||
GpioOutput<G>: OutputPin,
|
||||
{
|
||||
let mut pin = gpio.into_output();
|
||||
let _ = pin.set_high();
|
||||
// keep off until first use
|
||||
let _ = pin.set_low();
|
||||
pin
|
||||
}
|
||||
|
||||
/// Thermo-Electric Cooling device controlled through four PWM
|
||||
/// channels
|
||||
pub struct Tec<MaxIPos: PwmChannel, MaxINeg: PwmChannel, ISet: PwmChannel, MaxV: PwmChannel> {
|
||||
pub struct Tec<MaxIPos: PwmChannel, MaxINeg: PwmChannel, ISet: PwmChannel, MaxV: PwmChannel, SHDN: OutputPin> {
|
||||
max_i_pos: MaxIPos,
|
||||
max_i_neg: MaxINeg,
|
||||
i_set: ISet,
|
||||
max_v: MaxV,
|
||||
shdn: SHDN,
|
||||
}
|
||||
|
||||
impl Tec<pwm::T2CCP0, pwm::T2CCP1, pwm::T3CCP0, pwm::T3CCP1> {
|
||||
impl Tec<pwm::T2CCP0, pwm::T2CCP1, pwm::T3CCP0, pwm::T3CCP1, GpioOutput<PP4>> {
|
||||
pub fn tec0() -> Self {
|
||||
let (max_i_pos, max_i_neg) = tm4c129x::TIMER2::split();
|
||||
let (i_set, max_v) = tm4c129x::TIMER3::split();
|
||||
enable_shdn(PP4);
|
||||
Tec { max_i_pos, max_i_neg, i_set, max_v }
|
||||
let shdn = setup_shdn(PP4);
|
||||
Tec { max_i_pos, max_i_neg, i_set, max_v, shdn }
|
||||
}
|
||||
}
|
||||
|
||||
impl Tec<pwm::T4CCP0, pwm::T4CCP1, pwm::T5CCP0, pwm::T5CCP1> {
|
||||
impl Tec<pwm::T4CCP0, pwm::T4CCP1, pwm::T5CCP0, pwm::T5CCP1, GpioOutput<PP5>> {
|
||||
pub fn tec1() -> Self {
|
||||
let (max_i_pos, max_i_neg) = tm4c129x::TIMER4::split();
|
||||
let (i_set, max_v) = tm4c129x::TIMER5::split();
|
||||
enable_shdn(PP5);
|
||||
Tec { max_i_pos, max_i_neg, i_set, max_v }
|
||||
let shdn = setup_shdn(PP5);
|
||||
Tec { max_i_pos, max_i_neg, i_set, max_v, shdn }
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
impl<MaxIPos: PwmChannel, MaxINeg: PwmChannel, ISet: PwmChannel, MaxV: PwmChannel> Tec<MaxIPos, MaxINeg, ISet, MaxV> {
|
||||
impl<MaxIPos: PwmChannel, MaxINeg: PwmChannel, ISet: PwmChannel, MaxV: PwmChannel, SHDN: OutputPin> Tec<MaxIPos, MaxINeg, ISet, MaxV, SHDN> {
|
||||
pub fn setup(mut self, max: u16) -> Self {
|
||||
self.max_i_pos.set(max, max);
|
||||
self.max_i_neg.set(max, max);
|
||||
@ -99,8 +102,11 @@ impl<MaxIPos: PwmChannel, MaxINeg: PwmChannel, ISet: PwmChannel, MaxV: PwmChanne
|
||||
self.max_i_pos.set(width, total),
|
||||
TecPin::MaxINeg =>
|
||||
self.max_i_neg.set(width, total),
|
||||
TecPin::ISet =>
|
||||
self.i_set.set(width, total),
|
||||
TecPin::ISet => {
|
||||
self.i_set.set(width, total);
|
||||
// enable on first use
|
||||
let _ = self.shdn.set_high();
|
||||
}
|
||||
TecPin::MaxV =>
|
||||
self.max_v.set(width, total),
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user