From 2773ba47fe65421f27112ce1d3ad042fc10fa643 Mon Sep 17 00:00:00 2001 From: Astro Date: Thu, 14 Nov 2019 01:59:28 +0100 Subject: [PATCH] tec: init freq pins for 1 MHz switching --- firmware/src/board/gpio.rs | 4 ++++ firmware/src/tec.rs | 15 ++++++++++++++- 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/firmware/src/board/gpio.rs b/firmware/src/board/gpio.rs index 37628b1..8695c5e 100644 --- a/firmware/src/board/gpio.rs +++ b/firmware/src/board/gpio.rs @@ -72,7 +72,11 @@ pub struct PE4; def_gpio!(GPIO_PORTE_AHB, PE4, 4); pub struct PE5; def_gpio!(GPIO_PORTE_AHB, PE5, 5); +pub struct PK1; +def_gpio!(GPIO_PORTK, PK1, 1); pub struct PP2; def_gpio!(GPIO_PORTP, PP2, 2); pub struct PP3; def_gpio!(GPIO_PORTP, PP3, 3); +pub struct PQ4; +def_gpio!(GPIO_PORTQ, PQ4, 4); diff --git a/firmware/src/tec.rs b/firmware/src/tec.rs index ab4653d..3453026 100644 --- a/firmware/src/tec.rs +++ b/firmware/src/tec.rs @@ -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(gpio: G) +where + G: Gpio, + GpioOutput: 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 { @@ -61,6 +72,7 @@ impl Tec> { 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> { 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 } } }