forked from M-Labs/thermostat
rename dac_loopback to dac_feedback
This commit is contained in:
parent
34c2da4484
commit
0bc0af7487
|
@ -21,7 +21,7 @@ pub struct Channel<C: ChannelPins> {
|
||||||
pub adc: C::Adc,
|
pub adc: C::Adc,
|
||||||
pub itec_pin: C::ItecPin,
|
pub itec_pin: C::ItecPin,
|
||||||
/// feedback from `dac` output
|
/// feedback from `dac` output
|
||||||
pub dac_loopback_pin: C::DacLoopbackPin,
|
pub dac_feedback_pin: C::DacFeedbackPin,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<C: ChannelPins> Channel<C> {
|
impl<C: ChannelPins> Channel<C> {
|
||||||
|
@ -36,7 +36,7 @@ impl<C: ChannelPins> Channel<C> {
|
||||||
shdn: pins.shdn,
|
shdn: pins.shdn,
|
||||||
adc: pins.adc,
|
adc: pins.adc,
|
||||||
itec_pin: pins.itec_pin,
|
itec_pin: pins.itec_pin,
|
||||||
dac_loopback_pin: pins.dac_loopback_pin,
|
dac_feedback_pin: pins.dac_feedback_pin,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -95,11 +95,11 @@ impl Channels {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn read_dac_loopback(&mut self, channel: usize) -> Volts {
|
pub fn read_dac_feedback(&mut self, channel: usize) -> Volts {
|
||||||
match channel {
|
match channel {
|
||||||
0 => {
|
0 => {
|
||||||
let sample = self.channel0.adc.convert(
|
let sample = self.channel0.adc.convert(
|
||||||
&self.channel0.dac_loopback_pin,
|
&self.channel0.dac_feedback_pin,
|
||||||
stm32f4xx_hal::adc::config::SampleTime::Cycles_480
|
stm32f4xx_hal::adc::config::SampleTime::Cycles_480
|
||||||
);
|
);
|
||||||
let mv = self.channel0.adc.sample_to_millivolts(sample);
|
let mv = self.channel0.adc.sample_to_millivolts(sample);
|
||||||
|
@ -107,7 +107,7 @@ impl Channels {
|
||||||
}
|
}
|
||||||
1 => {
|
1 => {
|
||||||
let sample = self.channel1.adc.convert(
|
let sample = self.channel1.adc.convert(
|
||||||
&self.channel1.dac_loopback_pin,
|
&self.channel1.dac_feedback_pin,
|
||||||
stm32f4xx_hal::adc::config::SampleTime::Cycles_480
|
stm32f4xx_hal::adc::config::SampleTime::Cycles_480
|
||||||
);
|
);
|
||||||
let mv = self.channel1.adc.sample_to_millivolts(sample);
|
let mv = self.channel1.adc.sample_to_millivolts(sample);
|
||||||
|
|
|
@ -143,17 +143,17 @@ fn main() -> ! {
|
||||||
Command::Show(ShowCommand::Input) => {
|
Command::Show(ShowCommand::Input) => {
|
||||||
for channel in 0..CHANNELS {
|
for channel in 0..CHANNELS {
|
||||||
if let Some(adc_data) = channels.channel_state(channel).adc_data {
|
if let Some(adc_data) = channels.channel_state(channel).adc_data {
|
||||||
let dac_loopback = channels.read_dac_loopback(channel);
|
let dac_feedback = channels.read_dac_feedback(channel);
|
||||||
let dac_i = dac_loopback / Ohms(5.0);
|
let dac_i = dac_feedback / Ohms(5.0);
|
||||||
|
|
||||||
let itec = channels.read_itec(channel);
|
let itec = channels.read_itec(channel);
|
||||||
let tec_i = Amps((itec.0 - 1.5) / 8.0);
|
let tec_i = Amps((itec.0 - 1.5) / 8.0);
|
||||||
|
|
||||||
let state = channels.channel_state(channel);
|
let state = channels.channel_state(channel);
|
||||||
let _ = writeln!(
|
let _ = writeln!(
|
||||||
socket, "t={} raw{}=0x{:06X} dac_loopback={}/{} itec={} tec={}",
|
socket, "t={} raw{}=0x{:06X} dac_feedback={}/{} itec={} tec={}",
|
||||||
state.adc_time, channel, adc_data,
|
state.adc_time, channel, adc_data,
|
||||||
dac_loopback, dac_i,
|
dac_feedback, dac_i,
|
||||||
itec, tec_i,
|
itec, tec_i,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
16
src/pins.rs
16
src/pins.rs
|
@ -28,7 +28,7 @@ pub trait ChannelPins {
|
||||||
type Shdn: OutputPin;
|
type Shdn: OutputPin;
|
||||||
type Adc;
|
type Adc;
|
||||||
type ItecPin;
|
type ItecPin;
|
||||||
type DacLoopbackPin;
|
type DacFeedbackPin;
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ChannelPins for Channel0 {
|
impl ChannelPins for Channel0 {
|
||||||
|
@ -37,7 +37,7 @@ impl ChannelPins for Channel0 {
|
||||||
type Shdn = PE10<Output<PushPull>>;
|
type Shdn = PE10<Output<PushPull>>;
|
||||||
type Adc = Adc<ADC1>;
|
type Adc = Adc<ADC1>;
|
||||||
type ItecPin = PA6<Analog>;
|
type ItecPin = PA6<Analog>;
|
||||||
type DacLoopbackPin = PA4<Analog>;
|
type DacFeedbackPin = PA4<Analog>;
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ChannelPins for Channel1 {
|
impl ChannelPins for Channel1 {
|
||||||
|
@ -46,7 +46,7 @@ impl ChannelPins for Channel1 {
|
||||||
type Shdn = PE15<Output<PushPull>>;
|
type Shdn = PE15<Output<PushPull>>;
|
||||||
type Adc = Adc<ADC2>;
|
type Adc = Adc<ADC2>;
|
||||||
type ItecPin = PB0<Analog>;
|
type ItecPin = PB0<Analog>;
|
||||||
type DacLoopbackPin = PA5<Analog>;
|
type DacFeedbackPin = PA5<Analog>;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// SPI peripheral used for communication with the ADC
|
/// SPI peripheral used for communication with the ADC
|
||||||
|
@ -62,7 +62,7 @@ pub struct ChannelPinSet<C: ChannelPins> {
|
||||||
pub shdn: C::Shdn,
|
pub shdn: C::Shdn,
|
||||||
pub adc: C::Adc,
|
pub adc: C::Adc,
|
||||||
pub itec_pin: C::ItecPin,
|
pub itec_pin: C::ItecPin,
|
||||||
pub dac_loopback_pin: C::DacLoopbackPin,
|
pub dac_feedback_pin: C::DacFeedbackPin,
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct Pins {
|
pub struct Pins {
|
||||||
|
@ -113,14 +113,14 @@ impl Pins {
|
||||||
let mut adc0 = Adc::adc1(adc1, true, Default::default());
|
let mut adc0 = Adc::adc1(adc1, true, Default::default());
|
||||||
adc0.enable();
|
adc0.enable();
|
||||||
let itec0_pin = gpioa.pa6.into_analog();
|
let itec0_pin = gpioa.pa6.into_analog();
|
||||||
let dac_loopback0_pin = gpioa.pa4.into_analog();
|
let dac_feedback0_pin = gpioa.pa4.into_analog();
|
||||||
let channel0 = ChannelPinSet {
|
let channel0 = ChannelPinSet {
|
||||||
dac_spi: dac0_spi,
|
dac_spi: dac0_spi,
|
||||||
dac_sync: dac0_sync,
|
dac_sync: dac0_sync,
|
||||||
shdn: shdn0,
|
shdn: shdn0,
|
||||||
adc: adc0,
|
adc: adc0,
|
||||||
itec_pin: itec0_pin,
|
itec_pin: itec0_pin,
|
||||||
dac_loopback_pin: dac_loopback0_pin,
|
dac_feedback_pin: dac_feedback0_pin,
|
||||||
};
|
};
|
||||||
|
|
||||||
let (dac1_spi, dac1_sync) = Self::setup_dac1(
|
let (dac1_spi, dac1_sync) = Self::setup_dac1(
|
||||||
|
@ -132,14 +132,14 @@ impl Pins {
|
||||||
let mut adc1 = Adc::adc2(adc2, true, Default::default());
|
let mut adc1 = Adc::adc2(adc2, true, Default::default());
|
||||||
adc1.enable();
|
adc1.enable();
|
||||||
let itec1_pin = gpiob.pb0.into_analog();
|
let itec1_pin = gpiob.pb0.into_analog();
|
||||||
let dac_loopback1_pin = gpioa.pa5.into_analog();
|
let dac_feedback1_pin = gpioa.pa5.into_analog();
|
||||||
let channel1 = ChannelPinSet {
|
let channel1 = ChannelPinSet {
|
||||||
dac_spi: dac1_spi,
|
dac_spi: dac1_spi,
|
||||||
dac_sync: dac1_sync,
|
dac_sync: dac1_sync,
|
||||||
shdn: shdn1,
|
shdn: shdn1,
|
||||||
adc: adc1,
|
adc: adc1,
|
||||||
itec_pin: itec1_pin,
|
itec_pin: itec1_pin,
|
||||||
dac_loopback_pin: dac_loopback1_pin,
|
dac_feedback_pin: dac_feedback1_pin,
|
||||||
};
|
};
|
||||||
|
|
||||||
Pins {
|
Pins {
|
||||||
|
|
Loading…
Reference in New Issue