@@ -14,16 +14,7 @@ use stm32_hrtim::{
14
14
HrParts , HrPwmAdvExt , Polarity , Pscl4 ,
15
15
} ;
16
16
use stm32g4xx_hal:: {
17
- self as hal,
18
- adc:: AdcClaim ,
19
- comparator:: { self , ComparatorExt , ComparatorSplit } ,
20
- dac:: { Dac3IntSig1 , DacExt , DacOut } ,
21
- delay:: { DelayExt as _, SYSTDelayExt } ,
22
- gpio:: GpioExt ,
23
- hrtim:: { fault:: FaultInput , HrControltExt , HrPwmBuilderExt } ,
24
- pwr:: PwrExt ,
25
- rcc:: { self , RccExt } ,
26
- stm32:: { CorePeripherals , Peripherals } ,
17
+ self as hal, adc:: { AdcClaim , AdcCommonExt } , comparator:: { self , ComparatorExt , ComparatorSplit } , dac:: { Dac3IntSig1 , DacExt , DacOut } , delay:: { DelayExt as _, SYSTDelayExt } , gpio:: GpioExt , hrtim:: { fault:: FaultInput , HrControltExt , HrPwmBuilderExt } , pwr:: PwrExt , rcc:: { self , RccExt } , stasis:: Freeze , stm32:: { CorePeripherals , Peripherals }
27
18
} ;
28
19
29
20
#[ entry]
@@ -45,21 +36,16 @@ fn main() -> ! {
45
36
) ;
46
37
47
38
let mut delay = cp. SYST . delay ( & rcc. clocks ) ;
48
-
49
- let mut adc1 = dp. ADC1 . claim_and_configure (
50
- hal:: adc:: ClockSource :: SystemClock ,
51
- & rcc,
52
- hal:: adc:: config:: AdcConfig :: default ( )
53
- . clock_mode ( hal:: adc:: config:: ClockMode :: Synchronous_Div_4 ) ,
54
- & mut delay,
55
- false ,
56
- ) ;
39
+ let adc12_common = dp
40
+ . ADC12_COMMON
41
+ . claim ( hal:: adc:: config:: ClockMode :: AdcHclkDiv4 , & mut rcc) ;
42
+ let mut adc1 = adc12_common. claim_and_configure ( dp. ADC1 , Default :: default ( ) , & mut delay) ;
57
43
58
44
let gpioa = dp. GPIOA . split ( & mut rcc) ;
59
45
let gpioc = dp. GPIOC . split ( & mut rcc) ;
60
46
61
47
let dac3ch1 = dp. DAC3 . constrain ( Dac3IntSig1 , & mut rcc) ;
62
- let mut dac = dac3ch1. enable ( ) ;
48
+ let mut dac = dac3ch1. enable ( & mut rcc ) ;
63
49
64
50
// Use dac to define the fault threshold
65
51
// 2^12 / 2 = 2^11 for about half of VCC
@@ -68,11 +54,11 @@ fn main() -> ! {
68
54
69
55
let ( _comp1, _comp2, comp3, ..) = dp. COMP . split ( & mut rcc) ;
70
56
71
- let pc1 = gpioc. pc1 . into_analog ( ) ;
57
+ let ( pc1, [ pc1_token ] ) = gpioc. pc1 . into_analog ( ) . freeze ( ) ;
72
58
let comp3 = comp3
73
59
. comparator (
74
- & pc1 ,
75
- & dac,
60
+ pc1_token ,
61
+ dac,
76
62
comparator:: Config :: default ( )
77
63
. hysteresis ( comparator:: Hysteresis :: None )
78
64
. output_inverted ( ) ,
0 commit comments