|
|
|
@ -1,6 +1,6 @@ |
|
|
|
|
use core::fmt; |
|
|
|
|
use crate::board::pwm::{self, PwmChannel, PwmPeripheral}; |
|
|
|
|
use crate::board::gpio::{Gpio, GpioOutput, PP2, PP3}; |
|
|
|
|
use crate::board::gpio::{Gpio, GpioOutput, PP2, PP3, PK1, PQ4}; |
|
|
|
|
use embedded_hal::digital::v2::OutputPin; |
|
|
|
|
|
|
|
|
|
#[derive(Clone, Copy, Debug)] |
|
|
|
@ -46,6 +46,17 @@ where |
|
|
|
|
pin |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
fn setup_freq<G>(gpio: G) |
|
|
|
|
where |
|
|
|
|
G: Gpio, |
|
|
|
|
GpioOutput<G>: OutputPin, |
|
|
|
|
{ |
|
|
|
|
let mut pin = gpio.into_output(); |
|
|
|
|
// Switching Frequency Select
|
|
|
|
|
// high: 1 MHz, low: 500 kHz
|
|
|
|
|
let _ = pin.set_high(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/// Thermo-Electric Cooling device controlled through four PWM
|
|
|
|
|
/// channels
|
|
|
|
|
pub struct Tec<MaxIPos: PwmChannel, MaxINeg: PwmChannel, ISet: PwmChannel, MaxV: PwmChannel, SHDN: OutputPin> { |
|
|
|
@ -61,6 +72,7 @@ impl Tec<pwm::T2CCP0, pwm::T2CCP1, pwm::T3CCP0, pwm::T3CCP1, GpioOutput<PP2>> { |
|
|
|
|
let (max_i_pos, max_i_neg) = tm4c129x::TIMER2::split(); |
|
|
|
|
let (i_set, max_v) = tm4c129x::TIMER3::split(); |
|
|
|
|
let shdn = setup_shdn(PP2); |
|
|
|
|
setup_freq(PK1); |
|
|
|
|
Tec { max_i_pos, max_i_neg, i_set, max_v, shdn } |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
@ -70,6 +82,7 @@ impl Tec<pwm::T4CCP0, pwm::T4CCP1, pwm::T5CCP0, pwm::T5CCP1, GpioOutput<PP3>> { |
|
|
|
|
let (max_i_pos, max_i_neg) = tm4c129x::TIMER4::split(); |
|
|
|
|
let (i_set, max_v) = tm4c129x::TIMER5::split(); |
|
|
|
|
let shdn = setup_shdn(PP3); |
|
|
|
|
setup_freq(PQ4); |
|
|
|
|
Tec { max_i_pos, max_i_neg, i_set, max_v, shdn } |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|