Skip to content

Commit 00d0543

Browse files
committed
Minor fixes
1 parent d7451ab commit 00d0543

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

examples/opamp.rs

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ fn main() -> ! {
3636
let gpiob = dp.GPIOB.split(&mut rcc);
3737

3838
// setup opamps
39-
let (opamp1, opamp2, opamp3, opamp4, _opamp5, _opamp6) = dp.OPAMP.split(&mut rcc);
39+
let (opamp1, opamp2, opamp3, opamp4, ..) = dp.OPAMP.split(&mut rcc);
4040

4141
let opamp1 = opamp1.follower(gpioa.pa1, Some(gpioa.pa2));
4242
let opamp2 = opamp2.follower(gpioa.pa7, Option::<PA6<Analog>>::None);
@@ -51,11 +51,11 @@ fn main() -> ! {
5151
let (_opamp3, _pb0, _pb2, _some_pb1) = opamp3.disable();
5252
let (_opamp4, _pb11, _pb10, _none) = opamp4.disable();
5353

54-
/*let _opamp1 = opamp1.pga(
54+
let _opamp1 = opamp1.pga(
5555
pa1,
5656
PgaModeInternal::gain(NonInvertingGain::Gain2),
5757
some_pa2,
58-
);*/
58+
);
5959
let mut opamp2 = opamp2.pga(
6060
pa7,
6161
PgaModeInternal::gain(NonInvertingGain::Gain4),
@@ -69,12 +69,13 @@ fn main() -> ! {
6969
.claim(ClockSource::SystemClock, &rcc, &mut delay, true);
7070

7171
loop {
72+
// Here we can sample the output of opamp2 as if it was a regular AD pin
7273
let sample = adc.convert(&mut opamp2, stm32g4xx_hal::adc::config::SampleTime::Cycles_640_5);
7374

74-
delay.delay_ms(100);
75-
7675
let millivolts = adc.sample_to_millivolts(sample);
77-
info!("opamp2 thus 2x pa7: {}mV", millivolts);
76+
info!("opamp2 thus 4x pa7: {}mV", millivolts);
77+
78+
delay.delay_ms(100);
7879
}
7980

8081
#[allow(unreachable_code)]

0 commit comments

Comments
 (0)