diff options
| -rw-r--r-- | embassy-stm32/build.rs | 35 | ||||
| -rw-r--r-- | embassy-stm32/src/rcc/f013.rs | 14 | ||||
| -rw-r--r-- | embassy-stm32/src/rcc/mod.rs | 2 | ||||
| -rw-r--r-- | examples/stm32f334/src/bin/pwm.rs | 4 |
4 files changed, 30 insertions, 25 deletions
diff --git a/embassy-stm32/build.rs b/embassy-stm32/build.rs index a0b74c0b9..64d8afa13 100644 --- a/embassy-stm32/build.rs +++ b/embassy-stm32/build.rs | |||
| @@ -601,7 +601,7 @@ fn main() { | |||
| 601 | .iter() | 601 | .iter() |
| 602 | .map(|(_fieldset, fieldname, enum_name)| { | 602 | .map(|(_fieldset, fieldname, enum_name)| { |
| 603 | quote! { | 603 | quote! { |
| 604 | pub #fieldname: Option<crate::pac::rcc::vals::#enum_name> | 604 | pub #fieldname: Option<#enum_name> |
| 605 | } | 605 | } |
| 606 | }) | 606 | }) |
| 607 | .collect(); | 607 | .collect(); |
| @@ -627,23 +627,32 @@ fn main() { | |||
| 627 | }) | 627 | }) |
| 628 | .collect(); | 628 | .collect(); |
| 629 | 629 | ||
| 630 | let enum_names: BTreeSet<_> = rcc_cfgr_regs | ||
| 631 | .iter() | ||
| 632 | .map(|(_fieldset, _fieldname, enum_name)| enum_name) | ||
| 633 | .collect(); | ||
| 634 | |||
| 630 | g.extend(quote! { | 635 | g.extend(quote! { |
| 631 | #[derive(Clone, Copy)] | 636 | pub mod mux { |
| 632 | pub struct ClockMux { | 637 | #(pub use crate::pac::rcc::vals::#enum_names as #enum_names; )* |
| 633 | #( #struct_fields, )* | ||
| 634 | } | ||
| 635 | 638 | ||
| 636 | impl Default for ClockMux { | 639 | #[derive(Clone, Copy)] |
| 637 | fn default() -> Self { | 640 | pub struct ClockMux { |
| 638 | Self { | 641 | #( #struct_fields, )* |
| 639 | #( #field_names: None, )* | 642 | } |
| 643 | |||
| 644 | impl Default for ClockMux { | ||
| 645 | fn default() -> Self { | ||
| 646 | Self { | ||
| 647 | #( #field_names: None, )* | ||
| 648 | } | ||
| 640 | } | 649 | } |
| 641 | } | 650 | } |
| 642 | } | ||
| 643 | 651 | ||
| 644 | impl ClockMux { | 652 | impl ClockMux { |
| 645 | pub fn init(self) { | 653 | pub fn init(self) { |
| 646 | #( #inits )* | 654 | #( #inits )* |
| 655 | } | ||
| 647 | } | 656 | } |
| 648 | } | 657 | } |
| 649 | }); | 658 | }); |
diff --git a/embassy-stm32/src/rcc/f013.rs b/embassy-stm32/src/rcc/f013.rs index 86af4bd68..de209272d 100644 --- a/embassy-stm32/src/rcc/f013.rs +++ b/embassy-stm32/src/rcc/f013.rs | |||
| @@ -97,10 +97,9 @@ pub struct Config { | |||
| 97 | pub adc: AdcClockSource, | 97 | pub adc: AdcClockSource, |
| 98 | #[cfg(all(stm32f3, not(rcc_f37), adc3_common))] | 98 | #[cfg(all(stm32f3, not(rcc_f37), adc3_common))] |
| 99 | pub adc34: AdcClockSource, | 99 | pub adc34: AdcClockSource, |
| 100 | #[cfg(stm32f334)] | 100 | |
| 101 | pub hrtim: HrtimClockSource, | ||
| 102 | #[cfg(clock_mux)] | 101 | #[cfg(clock_mux)] |
| 103 | pub mux: crate::rcc::ClockMux, | 102 | pub mux: crate::rcc::mux::ClockMux, |
| 104 | 103 | ||
| 105 | pub ls: super::LsConfig, | 104 | pub ls: super::LsConfig, |
| 106 | } | 105 | } |
| @@ -128,8 +127,7 @@ impl Default for Config { | |||
| 128 | adc: AdcClockSource::Hclk(AdcHclkPrescaler::Div1), | 127 | adc: AdcClockSource::Hclk(AdcHclkPrescaler::Div1), |
| 129 | #[cfg(all(stm32f3, not(rcc_f37), adc3_common))] | 128 | #[cfg(all(stm32f3, not(rcc_f37), adc3_common))] |
| 130 | adc34: AdcClockSource::Hclk(AdcHclkPrescaler::Div1), | 129 | adc34: AdcClockSource::Hclk(AdcHclkPrescaler::Div1), |
| 131 | #[cfg(stm32f334)] | 130 | |
| 132 | hrtim: HrtimClockSource::BusClk, | ||
| 133 | #[cfg(clock_mux)] | 131 | #[cfg(clock_mux)] |
| 134 | mux: Default::default(), | 132 | mux: Default::default(), |
| 135 | } | 133 | } |
| @@ -350,7 +348,8 @@ pub(crate) unsafe fn init(config: Config) { | |||
| 350 | } | 348 | } |
| 351 | }; | 349 | }; |
| 352 | 350 | ||
| 353 | #[cfg(stm32f334)] | 351 | /* |
| 352 | TODO: Maybe add something like this to clock_mux? How can we autogenerate the data for this? | ||
| 354 | let hrtim = match config.hrtim { | 353 | let hrtim = match config.hrtim { |
| 355 | // Must be configured after the bus is ready, otherwise it won't work | 354 | // Must be configured after the bus is ready, otherwise it won't work |
| 356 | HrtimClockSource::BusClk => None, | 355 | HrtimClockSource::BusClk => None, |
| @@ -366,6 +365,7 @@ pub(crate) unsafe fn init(config: Config) { | |||
| 366 | Some(pll * 2u32) | 365 | Some(pll * 2u32) |
| 367 | } | 366 | } |
| 368 | }; | 367 | }; |
| 368 | */ | ||
| 369 | 369 | ||
| 370 | #[cfg(clock_mux)] | 370 | #[cfg(clock_mux)] |
| 371 | config.mux.init(); | 371 | config.mux.init(); |
| @@ -384,8 +384,6 @@ pub(crate) unsafe fn init(config: Config) { | |||
| 384 | adc: Some(adc), | 384 | adc: Some(adc), |
| 385 | #[cfg(all(stm32f3, not(rcc_f37), adc3_common))] | 385 | #[cfg(all(stm32f3, not(rcc_f37), adc3_common))] |
| 386 | adc34: Some(adc34), | 386 | adc34: Some(adc34), |
| 387 | #[cfg(stm32f334)] | ||
| 388 | hrtim: hrtim, | ||
| 389 | rtc: rtc, | 387 | rtc: rtc, |
| 390 | hsi48: hsi48, | 388 | hsi48: hsi48, |
| 391 | #[cfg(any(rcc_f1, rcc_f1cl, stm32f3))] | 389 | #[cfg(any(rcc_f1, rcc_f1cl, stm32f3))] |
diff --git a/embassy-stm32/src/rcc/mod.rs b/embassy-stm32/src/rcc/mod.rs index 24516d426..b5a8bc2a4 100644 --- a/embassy-stm32/src/rcc/mod.rs +++ b/embassy-stm32/src/rcc/mod.rs | |||
| @@ -32,7 +32,7 @@ mod _version; | |||
| 32 | pub use _version::*; | 32 | pub use _version::*; |
| 33 | 33 | ||
| 34 | #[cfg(clock_mux)] | 34 | #[cfg(clock_mux)] |
| 35 | pub use crate::_generated::ClockMux; | 35 | pub use crate::_generated::mux as mux; |
| 36 | pub use crate::_generated::Clocks; | 36 | pub use crate::_generated::Clocks; |
| 37 | 37 | ||
| 38 | #[cfg(feature = "low-power")] | 38 | #[cfg(feature = "low-power")] |
diff --git a/examples/stm32f334/src/bin/pwm.rs b/examples/stm32f334/src/bin/pwm.rs index cf5eb7b26..7c6d6cd71 100644 --- a/examples/stm32f334/src/bin/pwm.rs +++ b/examples/stm32f334/src/bin/pwm.rs | |||
| @@ -28,9 +28,7 @@ async fn main(_spawner: Spawner) { | |||
| 28 | config.rcc.apb1_pre = APBPrescaler::DIV2; | 28 | config.rcc.apb1_pre = APBPrescaler::DIV2; |
| 29 | config.rcc.apb2_pre = APBPrescaler::DIV1; | 29 | config.rcc.apb2_pre = APBPrescaler::DIV1; |
| 30 | 30 | ||
| 31 | // TODO: The two lines here do the same thing | 31 | config.rcc.mux.hrtim1sw = Some(embassy_stm32::rcc::mux::Timsw::PLL1_P); |
| 32 | config.rcc.hrtim = HrtimClockSource::PllClk; | ||
| 33 | config.rcc.mux.hrtim1sw = Some(embassy_stm32::pac::rcc::vals::Timsw::PLL1_P); | ||
| 34 | } | 32 | } |
| 35 | let p = embassy_stm32::init(config); | 33 | let p = embassy_stm32::init(config); |
| 36 | 34 | ||
