@@ -36,7 +36,7 @@ fn main() -> ! {
36
36
let gpiob = dp. GPIOB . split ( & mut rcc) ;
37
37
38
38
// 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) ;
40
40
41
41
let opamp1 = opamp1. follower ( gpioa. pa1 , Some ( gpioa. pa2 ) ) ;
42
42
let opamp2 = opamp2. follower ( gpioa. pa7 , Option :: < PA6 < Analog > > :: None ) ;
@@ -51,11 +51,11 @@ fn main() -> ! {
51
51
let ( _opamp3, _pb0, _pb2, _some_pb1) = opamp3. disable ( ) ;
52
52
let ( _opamp4, _pb11, _pb10, _none) = opamp4. disable ( ) ;
53
53
54
- /* let _opamp1 = opamp1.pga(
54
+ let _opamp1 = opamp1. pga (
55
55
pa1,
56
56
PgaModeInternal :: gain ( NonInvertingGain :: Gain2 ) ,
57
57
some_pa2,
58
- );*/
58
+ ) ;
59
59
let mut opamp2 = opamp2. pga (
60
60
pa7,
61
61
PgaModeInternal :: gain ( NonInvertingGain :: Gain4 ) ,
@@ -69,12 +69,13 @@ fn main() -> ! {
69
69
. claim ( ClockSource :: SystemClock , & rcc, & mut delay, true ) ;
70
70
71
71
loop {
72
+ // Here we can sample the output of opamp2 as if it was a regular AD pin
72
73
let sample = adc. convert ( & mut opamp2, stm32g4xx_hal:: adc:: config:: SampleTime :: Cycles_640_5 ) ;
73
74
74
- delay. delay_ms ( 100 ) ;
75
-
76
75
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 ) ;
78
79
}
79
80
80
81
#[ allow( unreachable_code) ]
0 commit comments