Skip to content

Commit b0dd45f

Browse files
committed
Update for h7 (broken)
1 parent a8dd2e2 commit b0dd45f

File tree

5 files changed

+51
-10
lines changed

5 files changed

+51
-10
lines changed

Cargo.toml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,10 @@ stm32f3 = { git = "https://github.com/stm32-rs/stm32-rs-nightlies", optional = t
1111

1212
#stm32f3xx-hal = { version = "0.10.0", optional = true }
1313
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 }
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+
1518
#stm32g4xx-hal = { version = "0.0.1", optional = true }
1619
stm32g4xx-hal = { git = "https://github.com/stm32-rs/stm32g4xx-hal", branch = "staged-pac", optional = true }
1720
#stm32g4xx-hal = { path = "../stm32g4xx-hal", optional = true }

src/control.rs

Lines changed: 30 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,20 +5,29 @@ use crate::fault::{
55
};
66

77
use crate::{hal, stm32};
8-
use hal::rcc::{Enable, Rcc, Reset};
8+
9+
#[cfg(feature = "stm32h7")]
10+
use hal::rcc::{rec::Hrtim as Rcc, ResetEnable as Reset, ResetEnable as Enable};
11+
12+
#[cfg(not(feature = "stm32h7"))]
13+
use hal::rcc::{Enable, Reset};
14+
15+
#[cfg(not(feature = "stm32h7"))]
16+
type Rcc = &mut hal::rcc::Rcc;
17+
918
use stm32::HRTIM_COMMON;
1019

1120
use super::{external_event::EevInputs, fault::FaultInputs};
1221

1322
pub trait HrControltExt {
14-
fn hr_control(self, _rcc: &mut Rcc) -> HrTimOngoingCalibration;
23+
fn hr_control(self, _rcc: Rcc) -> HrTimOngoingCalibration;
1524
}
1625

1726
impl HrControltExt for HRTIM_COMMON {
18-
fn hr_control(self, #[allow(unused_variables)] rcc: &mut Rcc) -> HrTimOngoingCalibration {
27+
fn hr_control(self, #[allow(unused_variables)] rcc: Rcc) -> HrTimOngoingCalibration {
1928
let common = unsafe { &*HRTIM_COMMON::ptr() };
2029

21-
let rcc_ptr = {
30+
let rcc = {
2231
#[cfg(feature = "stm32g4")]
2332
unsafe {
2433
&*stm32::RCC::ptr()
@@ -28,10 +37,20 @@ impl HrControltExt for HRTIM_COMMON {
2837
{
2938
&mut rcc.apb2
3039
}
40+
41+
#[cfg(feature = "stm32h7")]
42+
{
43+
rcc
44+
}
3145
};
3246

33-
<HRTIM_COMMON as Enable>::enable(rcc_ptr);
34-
<HRTIM_COMMON as Reset>::reset(rcc_ptr);
47+
#[cfg(not(feature = "stm32h7"))]
48+
<HRTIM_COMMON as Enable>::enable(rcc);
49+
#[cfg(not(feature = "stm32h7"))]
50+
<HRTIM_COMMON as Reset>::reset(rcc);
51+
52+
#[cfg(feature = "stm32h7")]
53+
rcc.enable().reset();
3554

3655
// Start calibration procedure
3756
common
@@ -136,6 +155,11 @@ impl HrTimOngoingCalibration {
136155
common
137156
.fltinr2()
138157
.write(|w| w.fltsd().bits(flt_divider as u8));
158+
159+
#[cfg(feature = "stm32h7")]
160+
let please_dont_forget_to_remove_this_once_pac_is_fixed = ();
161+
162+
#[cfg(not(feature = "stm32h7"))]
139163
common.eecr3().write(|w| w.eevsd().bits(eev_divider as u8));
140164

141165
#[cfg(feature = "stm32g4")]

src/external_event.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -328,8 +328,12 @@ macro_rules! impl_eev6_10_to_es {
328328

329329
let common = unsafe { &*HRTIM_COMMON::ptr() };
330330

331+
#[cfg(feature = "stm32h7")]
332+
let please_dont_forget_to_remove_this_once_pac_is_fixed = ();
333+
331334
// SAFETY: Thanks to, `HrTimCalibrated`, we know we have exclusive access to the register,
332335
// we also know no timers are started.
336+
#[cfg(not(feature = "stm32h7"))]
333337
unsafe {
334338
common.eecr2().modify(|_r, w| {
335339
w.$eeXsrc()

src/lib.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@ pub mod timer_eev_cfg;
1717
mod mcu;
1818

1919
#[cfg(feature = "stm32h7")]
20-
pub use stm32h7xx_hal as hal;
20+
#[path = "stm32h7.rs"]
21+
mod mcu;
2122

2223
#[cfg(feature = "stm32g4")]
2324
#[path = "stm32g4.rs"]
@@ -604,7 +605,7 @@ macro_rules! hrtim_hal {
604605
)
605606
}
606607

607-
#[cfg(feature = "stm32g4")] {
608+
#[cfg(not(feature = "stm32f3"))] {
608609
hrtim_finalize_body!(self, PreloadSource, $TIMX, [$($out)*],)
609610
}
610611
}
@@ -764,7 +765,7 @@ where
764765
)
765766
}
766767

767-
#[cfg(feature = "stm32g4")]
768+
#[cfg(not(feature = "stm32f3"))]
768769
{
769770
hrtim_finalize_body!(self, MasterPreloadSource, HRTIM_MASTER, [],)
770771
}

src/stm32h7.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
pub use hal::stm32;
2+
pub use stm32h7xx_hal as hal;
3+
4+
pub type GpioInputMode = hal::gpio::Input;
5+
6+
pub use hal::pwm::Alignment;
7+
8+
#[cfg(feature = "stm32h7")]
9+
pub use hal::pwm::Polarity;

0 commit comments

Comments
 (0)