Skip to content

Commit ad4b87a

Browse files
committed
Clean up example
1 parent 00d0543 commit ad4b87a

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

examples/opamp.rs

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,11 @@ fn main() -> ! {
3838
// setup opamps
3939
let (opamp1, opamp2, opamp3, opamp4, ..) = dp.OPAMP.split(&mut rcc);
4040

41+
// Set up opamp1 and opamp2 in follower mode
4142
let opamp1 = opamp1.follower(gpioa.pa1, Some(gpioa.pa2));
4243
let opamp2 = opamp2.follower(gpioa.pa7, Option::<PA6<Analog>>::None);
4344

45+
// Set up opamp1 and opamp2 in open loop mode
4446
let opamp3 = opamp3.open_loop(gpiob.pb0, gpiob.pb2, Some(gpiob.pb1));
4547
let opamp4 = opamp4.open_loop(gpiob.pb11, gpiob.pb10, Option::<PB12<Analog>>::None);
4648

@@ -51,16 +53,19 @@ fn main() -> ! {
5153
let (_opamp3, _pb0, _pb2, _some_pb1) = opamp3.disable();
5254
let (_opamp4, _pb11, _pb10, _none) = opamp4.disable();
5355

56+
// Configure opamp1 with pa1 as non-inverting input and set gain to x2
5457
let _opamp1 = opamp1.pga(
5558
pa1,
5659
PgaModeInternal::gain(NonInvertingGain::Gain2),
57-
some_pa2,
60+
some_pa2, // Route output to pin pa2
5861
);
62+
63+
// Configure op with pa7 as non-inverting input and set gain to x4
5964
let mut opamp2 = opamp2.pga(
6065
pa7,
6166
PgaModeInternal::gain(NonInvertingGain::Gain4),
6267
//Some(gpioa.pa6),
63-
Option::<PA6<Analog>>::None,
68+
Option::<PA6<Analog>>::None, // Do not route output to any external pin, use internal AD instead
6469
);
6570

6671
let mut delay = cp.SYST.delay(&rcc.clocks);
@@ -80,7 +85,7 @@ fn main() -> ! {
8085

8186
#[allow(unreachable_code)]
8287
{
83-
//let (_opamp1, _pa1, _mode, _some_pa2) = _opamp1.disable();
88+
let (_opamp1, _pa1, _mode, _some_pa2) = _opamp1.disable();
8489
let (_opamp2, _pa7, _mode, _none) = opamp2.disable();
8590

8691
loop {}

0 commit comments

Comments
 (0)