@@ -14,16 +14,7 @@ use stm32_hrtim::{
1414 HrParts , HrPwmAdvExt , Polarity , Pscl4 ,
1515} ;
1616use 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 }
2718} ;
2819
2920#[ entry]
@@ -45,21 +36,16 @@ fn main() -> ! {
4536 ) ;
4637
4738 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) ;
5743
5844 let gpioa = dp. GPIOA . split ( & mut rcc) ;
5945 let gpioc = dp. GPIOC . split ( & mut rcc) ;
6046
6147 let dac3ch1 = dp. DAC3 . constrain ( Dac3IntSig1 , & mut rcc) ;
62- let mut dac = dac3ch1. enable ( ) ;
48+ let mut dac = dac3ch1. enable ( & mut rcc ) ;
6349
6450 // Use dac to define the fault threshold
6551 // 2^12 / 2 = 2^11 for about half of VCC
@@ -68,11 +54,11 @@ fn main() -> ! {
6854
6955 let ( _comp1, _comp2, comp3, ..) = dp. COMP . split ( & mut rcc) ;
7056
71- let pc1 = gpioc. pc1 . into_analog ( ) ;
57+ let ( pc1, [ pc1_token ] ) = gpioc. pc1 . into_analog ( ) . freeze ( ) ;
7258 let comp3 = comp3
7359 . comparator (
74- & pc1 ,
75- & dac,
60+ pc1_token ,
61+ dac,
7662 comparator:: Config :: default ( )
7763 . hysteresis ( comparator:: Hysteresis :: None )
7864 . output_inverted ( ) ,
0 commit comments