Skip to content

Commit

Permalink
Modified an example
Browse files Browse the repository at this point in the history
  • Loading branch information
David-OConnor committed Sep 1, 2021
1 parent fd6f44b commit d79c10c
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
4 changes: 2 additions & 2 deletions examples/conductivity_module/src/ec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ impl EcSensor {

// Set the initial exciation voltage.
let mut V_exc = V_EXC_INIT;
self.dac.set_voltage(DacChannel::C1, V_exc);
self.dac.write_voltage(DacChannel::C1, V_exc);

// Read ADC Input V+ and V-
let readings = self.read_voltage(addr, read_cmd, i2c);
Expand Down Expand Up @@ -289,7 +289,7 @@ impl EcSensor {
// See `measure` for how we
let I = (V_exc - V_probe) / gain.resistance();
V_exc = I * gain.resistance() + V_PROBE_TGT;
self.dac.set_voltage(DacChannel::C1, V_exc);
self.dac.write_voltage(DacChannel::C1, V_exc);

(V_exc, gain)
}
Expand Down
4 changes: 3 additions & 1 deletion examples/syntax_overview/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -179,10 +179,12 @@ fn main() -> ! {
let reading: u16 = adc.read(1);

// Set up the Digital-to-analog converter
let mut dac_pin = Pin::new(Port::A, 12, PinMode::Analog);
let mut _dac_pin = Pin::new(Port::A, 12, PinMode::Analog);
let mut dac = Dac::new(dp.DAC1, DacDevice::One, Bits::TwelveR, 3.3);
dac.enable(DacChannel::C1);

dac.write(DacChannel::C1, 2_048); // Set DAC output voltage to half VCC, eg 1.65V

// Set up and start a timer; set it to fire interrupts at 5Hz.
let mut timer = Timer::new_tim1(dp.TIM1, 0.2, &clock_cfg);
timer.enable_interrupt(TimerInterrupt::Update); // Enable update event interrupts.
Expand Down

0 comments on commit d79c10c

Please sign in to comment.