From c8d31c7b0d35afeb62d97d8d1b8e563587af2e6b Mon Sep 17 00:00:00 2001 From: Astro Date: Thu, 3 Oct 2019 01:33:21 +0200 Subject: [PATCH] tec: add pwm default setup --- firmware/src/main.rs | 4 ++-- firmware/src/tec.rs | 7 +++++++ 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/firmware/src/main.rs b/firmware/src/main.rs index ae3d171..beebf85 100644 --- a/firmware/src/main.rs +++ b/firmware/src/main.rs @@ -127,8 +127,8 @@ fn main() -> ! { writeln!(stdout, "tecpak boot").unwrap(); board::init(); writeln!(stdout, "board initialized").unwrap(); - let mut tec0 = Tec::tec0(); - let mut tec1 = Tec::tec1(); + let mut tec0 = Tec::tec0().setup(PWM_PID_WIDTH); + let mut tec1 = Tec::tec1().setup(PWM_PID_WIDTH); println!(r#" _ _ diff --git a/firmware/src/tec.rs b/firmware/src/tec.rs index 95219e7..85813c7 100644 --- a/firmware/src/tec.rs +++ b/firmware/src/tec.rs @@ -60,6 +60,13 @@ impl Tec { impl Tec { + pub fn setup(mut self, max: u16) -> Self { + self.max_i_pos.set(max, max); + self.max_i_neg.set(max, max); + self.max_v.set(max, max); + self + } + pub fn get(&mut self, pin: TecPin) -> (u16, u16) { match pin { TecPin::MaxIPos =>