Skip to content

Commit 272bd53

Browse files
committed
Dont depend on hal (#6)
* Dont depend on hal * Remove connect pins * Move out device specific things to hals * update pac * Update CI * fixes * Fix errors for f334 and h7 * Update examples * clippy
1 parent 7921747 commit 272bd53

25 files changed

+282
-960
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,7 @@ jobs:
1515
rust:
1616
- stable
1717
device:
18-
- stm32f334x4
19-
- stm32f334x6
20-
- stm32f334x8
18+
- stm32f334
2119

2220
- stm32h742
2321
- stm32h743

Cargo.toml

Lines changed: 23 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -3,21 +3,17 @@ name = "stm32-hrtim"
33
version = "0.1.0"
44
edition = "2021"
55

6-
[dependencies]
6+
[patch.crates-io]
7+
stm32-hrtim = { path = "." }
8+
9+
[patch."https://github.com/usbalbin/stm32-hrtim"]
10+
stm32-hrtim = { path = "." }
711

12+
[dependencies]
813
stm32f3 = { git = "https://github.com/stm32-rs/stm32-rs-nightlies", optional = true }
9-
stm32h7 = { git = "https://github.com/stm32-rs/stm32-rs-nightlies", fatures = ["critical-section"], optional = true }
10-
#stm32g4 = { git = "", optional = true }
11-
12-
#stm32f3xx-hal = { version = "0.10.0", optional = true }
13-
stm32f3xx-hal = { git = "https://github.com/usbalbin/stm32f3xx-hal", branch = "update_for_new_pac", optional = true }
14-
#stm32h7xx-hal = { version = "0.16.0", optional = true }
15-
stm32h7xx-hal = { git = "https://github.com/usbalbin/stm32h7xx-hal", branch = "update_for_new_pac", optional = true }
16-
#stm32h7xx-hal = { path = "../stm32h7xx-hal", optional = true }
17-
18-
#stm32g4xx-hal = { version = "0.0.1", optional = true }
19-
stm32g4xx-hal = { git = "https://github.com/stm32-rs/stm32g4xx-hal", branch = "staged-pac", optional = true }
20-
#stm32g4xx-hal = { path = "../stm32g4xx-hal", optional = true }
14+
stm32h7 = { git = "https://github.com/stm32-rs/stm32-rs-nightlies", features = ["critical-section"], optional = true }
15+
stm32g4 = { version = "0.22.0", package = "stm32g4-staging", optional = true }
16+
2117
defmt = { version = "0.3.10", optional = true }
2218
fugit = "0.3.7"
2319

@@ -26,6 +22,7 @@ cortex-m = { version = "0.7.7", features = ["critical-section-single-core"] }
2622
defmt-rtt = "0.4.0"
2723
cortex-m-rt = "0.7.2"
2824
panic-probe = { version = "0.3.0", features = ["print-defmt"] }
25+
stm32g4xx-hal = { git = "https://github.com/usbalbin/stm32g4xx-hal", branch = "hrtim", features = ["defmt", "hrtim"] }
2926

3027
[features]
3128
default = []
@@ -38,30 +35,20 @@ stm32f3 = ["stm32f3/stm32f3x4"]
3835
stm32h7 = ["dep:stm32h7"]
3936
stm32g4 = []
4037

41-
stm32f334x4 = ["stm32f3", "stm32f3xx-hal/stm32f334x4", "hrtim_v1"]
42-
stm32f334x6 = ["stm32f3", "stm32f3xx-hal/stm32f334x6", "hrtim_v1"]
43-
stm32f334x8 = ["stm32f3", "stm32f3xx-hal/stm32f334x8", "hrtim_v1"]
44-
45-
stm32h742 = ["stm32h7", "stm32h7xx-hal/stm32h742", "hrtim_v1_1"]
46-
stm32h743 = ["stm32h7", "stm32h7xx-hal/stm32h743", "hrtim_v1_1"]
47-
#stm32h745 = ["stm32h7", "stm32h7xx-hal/stm32h745", "hrtim_v1_1"]
48-
stm32h747cm7 = ["stm32h7", "stm32h7xx-hal/stm32h747cm7", "hrtim_v1_1"]
49-
stm32h750 = ["stm32h7", "stm32h7xx-hal/stm32h750", "hrtim_v1_1"]
50-
stm32h753 = ["stm32h7", "stm32h7xx-hal/stm32h753", "hrtim_v1_1"]
51-
#stm32h755 = ["stm32h7", "stm32h7xx-hal/stm32h755", "hrtim_v1_1"]
52-
#stm32h757 = ["stm32h7", "stm32h7xx-hal/stm32h757", "hrtim_v1_1"]
53-
54-
stm32g474 = ["stm32g4", "stm32g4xx-hal/stm32g474", "hrtim_v2"]
55-
stm32g484 = ["stm32g4", "stm32g4xx-hal/stm32g484", "hrtim_v2"]
56-
defmt = ["dep:defmt", "fugit/defmt"]
38+
stm32f334 = ["stm32f3/stm32f3x4", "hrtim_v1"]
5739

58-
# F3
59-
60-
[[example]]
61-
name = "stm32f3"
62-
required-features = ["stm32f3"]
63-
path = "examples/stm32f3/hrtim.rs"
40+
stm32h742 = ["stm32h7/stm32h742", "hrtim_v1_1"]
41+
stm32h743 = ["stm32h7/stm32h743", "hrtim_v1_1"]
42+
#stm32h745 = ["stm32h7/stm32h745", "hrtim_v1_1"]
43+
stm32h747cm7 = ["stm32h7/stm32h747cm7", "hrtim_v1_1"]
44+
stm32h750 = ["stm32h7/stm32h750", "hrtim_v1_1"]
45+
stm32h753 = ["stm32h7/stm32h753", "hrtim_v1_1"]
46+
#stm32h755 = ["stm32h7/stm32h755", "hrtim_v1_1"]
47+
#stm32h757 = ["stm32h7/stm32h757", "hrtim_v1_1"]
6448

49+
stm32g474 = ["stm32g4/stm32g474", "stm32g4xx-hal/stm32g474", "hrtim_v2"]
50+
stm32g484 = ["stm32g4/stm32g484", "stm32g4xx-hal/stm32g484", "hrtim_v2"]
51+
defmt = ["dep:defmt", "fugit/defmt"]
6552

6653
# G4
6754

@@ -108,11 +95,4 @@ path = "examples/stm32g4/hrtim.rs"
10895
[[example]]
10996
name = "stm32g4-master"
11097
required-features = ["stm32g4"]
111-
path = "examples/stm32g4/master.rs"
112-
113-
# H7
114-
115-
[[example]]
116-
name = "stm32h7"
117-
required-features = ["stm32h7"]
118-
path = "examples/stm32h7/hrtim.rs"
98+
path = "examples/stm32g4/master.rs"

examples/stm32f3/hrtim.rs

Lines changed: 0 additions & 107 deletions
This file was deleted.

examples/stm32g4/adc-trigger.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,15 @@
55
use cortex_m_rt::entry;
66
use panic_probe as _;
77
use stm32_hrtim::{
8-
compare_register::HrCompareRegister, control::HrControltExt, output::HrOutput, timer::HrTimer,
9-
HrParts, HrPwmAdvExt, Pscl4,
8+
compare_register::HrCompareRegister, output::HrOutput, timer::HrTimer, HrParts, HrPwmAdvExt,
9+
Pscl4,
1010
};
1111
use stm32g4xx_hal::{
1212
adc::{self, AdcClaim, ClockSource, Temperature, Vref},
1313
delay::SYSTDelayExt,
1414
dma::{self, channel::DMAExt, config::DmaConfig, TransferExt},
1515
gpio::GpioExt,
16+
hrtim::{HrControltExt, HrPwmBuilderExt},
1617
pwr::PwrExt,
1718
rcc::{self, RccExt},
1819
stm32::{CorePeripherals, Peripherals},

examples/stm32g4/capture-dma.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ use panic_probe as _;
77
use stm32_hrtim::{
88
capture,
99
compare_register::HrCompareRegister,
10-
control::HrControltExt,
1110
external_event::{self, ToExternalEventSource},
1211
output::HrOutput,
1312
timer::{HrSlaveTimerCpt, HrTimer, TimerSplitCapture},
@@ -16,6 +15,7 @@ use stm32_hrtim::{
1615
use stm32g4xx_hal::{
1716
dma::{channel::DMAExt, config::DmaConfig, TransferExt},
1817
gpio::GpioExt,
18+
hrtim::{external_event::EevInputExt, HrControltExt, HrPwmBuilderExt},
1919
pwr::PwrExt,
2020
rcc::{self, RccExt},
2121
stm32::Peripherals,

examples/stm32g4/capture.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,14 @@ use panic_probe as _;
77
use stm32_hrtim::{
88
capture::HrCapture,
99
compare_register::HrCompareRegister,
10-
control::HrControltExt,
1110
external_event::{self, ToExternalEventSource},
1211
output::HrOutput,
1312
timer::{HrSlaveTimerCpt, HrTimer},
1413
HrParts, HrPwmAdvExt, Pscl128,
1514
};
1615
use stm32g4xx_hal::{
1716
gpio::GpioExt,
17+
hrtim::{external_event::EevInputExt, HrControltExt, HrPwmBuilderExt},
1818
pwr::PwrExt,
1919
rcc::{self, RccExt},
2020
stm32::Peripherals,

examples/stm32g4/eev-comp.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,19 +7,18 @@ use cortex_m_rt::entry;
77
use panic_probe as _;
88
use stm32_hrtim::{
99
compare_register::HrCompareRegister,
10-
control::HrControltExt,
1110
external_event::{self, ToExternalEventSource},
1211
output::HrOutput,
1312
timer::HrTimer,
1413
timer_eev_cfg::{EevCfg, EevCfgs},
15-
HrParts, HrPwmAdvExt, Pscl4,
14+
HrParts, HrPwmAdvExt, Polarity, Pscl4,
1615
};
1716
use stm32g4xx_hal::{
1817
comparator::{self, ComparatorExt, ComparatorSplit},
1918
dac::{self, DacExt, DacOut},
2019
delay::SYSTDelayExt,
2120
gpio::{GpioExt, SignalEdge},
22-
pwm,
21+
hrtim::{external_event::EevInputExt, HrControltExt, HrPwmBuilderExt},
2322
pwr::PwrExt,
2423
rcc::{self, RccExt},
2524
stm32::{CorePeripherals, Peripherals},
@@ -80,7 +79,7 @@ fn main() -> ! {
8079
.eev_input4
8180
.bind(&comp1)
8281
.edge_or_polarity(external_event::EdgeOrPolarity::Polarity(
83-
pwm::Polarity::ActiveHigh,
82+
Polarity::ActiveHigh,
8483
))
8584
.finalize(&mut hr_control);
8685

examples/stm32g4/eev.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,15 @@ use cortex_m_rt::entry;
77
use panic_probe as _;
88
use stm32_hrtim::{
99
compare_register::HrCompareRegister,
10-
control::HrControltExt,
1110
external_event::{self, ToExternalEventSource},
1211
output::HrOutput,
1312
timer::HrTimer,
1413
timer_eev_cfg::EevCfgs,
15-
HrParts, HrPwmAdvExt, Pscl4,
14+
HrParts, HrPwmAdvExt, Polarity, Pscl4,
1615
};
1716
use stm32g4xx_hal::{
1817
gpio::GpioExt,
19-
pwm,
18+
hrtim::{external_event::EevInputExt, HrControltExt, HrPwmBuilderExt},
2019
pwr::PwrExt,
2120
rcc::{self, RccExt},
2221
stm32::Peripherals,
@@ -50,7 +49,7 @@ fn main() -> ! {
5049
.eev_input3
5150
.bind(gpiob.pb7.into_pull_down_input())
5251
.edge_or_polarity(external_event::EdgeOrPolarity::Polarity(
53-
pwm::Polarity::ActiveHigh,
52+
Polarity::ActiveHigh,
5453
))
5554
.finalize(&mut hr_control);
5655

examples/stm32g4/flt-comp.rs

Lines changed: 6 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -7,23 +7,10 @@ use cortex_m_rt::entry;
77
use fugit::ExtU32 as _;
88
use panic_probe as _;
99
use stm32_hrtim::{
10-
compare_register::HrCompareRegister,
11-
control::HrControltExt,
12-
fault::{FaultAction, FaultMonitor},
13-
output::HrOutput,
14-
timer::HrTimer,
15-
HrParts, HrPwmAdvExt, Pscl4,
10+
compare_register::HrCompareRegister, fault::{FaultAction, FaultMonitor}, output::HrOutput, timer::HrTimer, HrParts, HrPwmAdvExt, Polarity, Pscl4
1611
};
1712
use stm32g4xx_hal::{
18-
self as hal,
19-
adc::AdcClaim,
20-
comparator::{self, ComparatorExt, ComparatorSplit},
21-
dac::{Dac3IntSig1, DacExt, DacOut},
22-
delay::{DelayExt as _, SYSTDelayExt},
23-
gpio::GpioExt,
24-
pwr::PwrExt,
25-
rcc::{self, RccExt},
26-
stm32::{CorePeripherals, Peripherals},
13+
self as hal, adc::AdcClaim, comparator::{self, ComparatorExt, ComparatorSplit}, dac::{Dac3IntSig1, DacExt, DacOut}, delay::{DelayExt as _, SYSTDelayExt}, gpio::GpioExt, hrtim::{fault::FaultInput, HrControltExt, HrPwmBuilderExt}, pwr::PwrExt, rcc::{self, RccExt}, stm32::{CorePeripherals, Peripherals}
2714
};
2815

2916
#[entry]
@@ -85,8 +72,8 @@ fn main() -> ! {
8572

8673
let fault_source5 = flt_inputs
8774
.fault_input5
88-
.bind_comp(&comp3)
89-
.polarity(hal::pwm::Polarity::ActiveHigh)
75+
.bind(comp3)
76+
.polarity(Polarity::ActiveHigh)
9077
.finalize(&mut hr_control);
9178

9279
// ...with a prescaler of 4 this gives us a HrTimer with a tick rate of 960MHz
@@ -137,9 +124,9 @@ fn main() -> ! {
137124
for _ in 0..5 {
138125
delay.delay(500_u32.millis());
139126
defmt::info!(
140-
"State: {:?}, comp: {}, is_fault_active: {}, pc1: {}",
127+
"State: {:?}, comp: {}, is_fault_active: _, pc1: {}",
141128
out1.get_state(),
142-
comp3.output(),
129+
//comp3.output(), // TODO
143130
hr_control.fault_5.is_fault_active(),
144131
adc1.convert(&pc1, hal::adc::config::SampleTime::Cycles_92_5)
145132
);

0 commit comments

Comments
 (0)