Skip to content

Commit cbe9a76

Browse files
committed
Update examples
1 parent e025998 commit cbe9a76

File tree

3 files changed

+16
-31
lines changed

3 files changed

+16
-31
lines changed

examples/hrtim/adc-trigger.rs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ use stm32_hrtim::{
99
Pscl4,
1010
};
1111
use stm32g4xx_hal::{
12-
adc::{self, AdcClaim, ClockSource, Temperature, Vref},
12+
adc::{self, temperature::Temperature, AdcClaim, AdcCommonExt, Vref},
1313
delay::SYSTDelayExt,
1414
dma::{self, channel::DMAExt, config::DmaConfig, TransferExt},
1515
gpio::GpioExt,
@@ -103,15 +103,14 @@ fn main() -> ! {
103103
out2.enable_set_event(&timer);
104104

105105
defmt::info!("Setup Adc1");
106-
let mut adc = dp
107-
.ADC1
108-
.claim(ClockSource::SystemClock, &rcc, &mut delay, true);
106+
let mut adc12_common = dp.ADC12_COMMON.claim(Default::default(), &mut rcc);
107+
let mut adc = adc12_common.claim(dp.ADC1, &mut delay);
109108

110109
adc.set_external_trigger((
111110
adc::config::TriggerMode::RisingEdge,
112111
(&hr_control.adc_trigger1).into(),
113112
));
114-
adc.enable_temperature(&dp.ADC12_COMMON);
113+
adc12_common.enable_temperature();
115114
adc.set_continuous(adc::config::Continuous::Discontinuous);
116115
adc.reset_sequence();
117116
adc.configure_channel(

examples/hrtim/eev-comp.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ fn main() -> ! {
5353
let pin_a = gpioa.pa8;
5454

5555
let dac1ch1 = dp.DAC1.constrain(dac::Dac1IntSig1, &mut rcc);
56-
let mut dac = dac1ch1.calibrate_buffer(&mut delay).enable();
56+
let mut dac = dac1ch1.calibrate_buffer(&mut delay).enable(&mut rcc);
5757

5858
// Use dac to define the fault threshold
5959
// 2^12 / 2 = 2^11 for about half of VCC
@@ -63,8 +63,8 @@ fn main() -> ! {
6363
let (comp1, ..) = dp.COMP.split(&mut rcc);
6464

6565
let comp1 = comp1.comparator(
66-
&input,
67-
&dac,
66+
input,
67+
dac,
6868
comparator::Config::default().hysteresis(comparator::Hysteresis::None),
6969
//.output_inverted(),
7070
&rcc.clocks,

examples/hrtim/flt-comp.rs

Lines changed: 9 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -14,16 +14,7 @@ use stm32_hrtim::{
1414
HrParts, HrPwmAdvExt, Polarity, Pscl4,
1515
};
1616
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}
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

Comments
 (0)