diff options
| -rw-r--r-- | embassy-stm32/build.rs | 2 | ||||
| -rw-r--r-- | embassy-stm32/src/rcc/h.rs | 43 | ||||
| -rw-r--r-- | examples/stm32h7rs/src/bin/blinky.rs | 2 | ||||
| -rw-r--r-- | examples/stm32h7rs/src/bin/eth.rs | 2 | ||||
| -rw-r--r-- | examples/stm32h7rs/src/bin/usb_serial.rs | 2 | ||||
| -rw-r--r-- | examples/stm32h7rs/src/bin/xspi_memory_mapped.rs | 2 | ||||
| -rw-r--r-- | tests/stm32/src/common.rs | 2 |
7 files changed, 53 insertions, 2 deletions
diff --git a/embassy-stm32/build.rs b/embassy-stm32/build.rs index 73860c64a..753f94fa6 100644 --- a/embassy-stm32/build.rs +++ b/embassy-stm32/build.rs | |||
| @@ -1599,7 +1599,7 @@ fn main() { | |||
| 1599 | for e in rcc_registers.ir.enums { | 1599 | for e in rcc_registers.ir.enums { |
| 1600 | fn is_rcc_name(e: &str) -> bool { | 1600 | fn is_rcc_name(e: &str) -> bool { |
| 1601 | match e { | 1601 | match e { |
| 1602 | "Pllp" | "Pllq" | "Pllr" | "Pllm" | "Plln" | "Prediv1" | "Prediv2" => true, | 1602 | "Pllp" | "Pllq" | "Pllr" | "Plldivst" | "Pllm" | "Plln" | "Prediv1" | "Prediv2" => true, |
| 1603 | "Timpre" | "Pllrclkpre" => false, | 1603 | "Timpre" | "Pllrclkpre" => false, |
| 1604 | e if e.ends_with("pre") || e.ends_with("pres") || e.ends_with("div") || e.ends_with("mul") => true, | 1604 | e if e.ends_with("pre") || e.ends_with("pres") || e.ends_with("div") || e.ends_with("mul") => true, |
| 1605 | _ => false, | 1605 | _ => false, |
diff --git a/embassy-stm32/src/rcc/h.rs b/embassy-stm32/src/rcc/h.rs index 383f48874..837210b6a 100644 --- a/embassy-stm32/src/rcc/h.rs +++ b/embassy-stm32/src/rcc/h.rs | |||
| @@ -1,5 +1,8 @@ | |||
| 1 | use core::ops::RangeInclusive; | 1 | use core::ops::RangeInclusive; |
| 2 | 2 | ||
| 3 | #[cfg(stm32h7rs)] | ||
| 4 | use stm32_metapac::rcc::vals::Plldivst; | ||
| 5 | |||
| 3 | use crate::pac; | 6 | use crate::pac; |
| 4 | pub use crate::pac::rcc::vals::{ | 7 | pub use crate::pac::rcc::vals::{ |
| 5 | Hsidiv as HSIPrescaler, Plldiv as PllDiv, Pllm as PllPreDiv, Plln as PllMul, Pllsrc as PllSource, Sw as Sysclk, | 8 | Hsidiv as HSIPrescaler, Plldiv as PllDiv, Pllm as PllPreDiv, Plln as PllMul, Pllsrc as PllSource, Sw as Sysclk, |
| @@ -78,6 +81,12 @@ pub struct Pll { | |||
| 78 | pub divq: Option<PllDiv>, | 81 | pub divq: Option<PllDiv>, |
| 79 | /// PLL R division factor. If None, PLL R output is disabled. | 82 | /// PLL R division factor. If None, PLL R output is disabled. |
| 80 | pub divr: Option<PllDiv>, | 83 | pub divr: Option<PllDiv>, |
| 84 | #[cfg(stm32h7rs)] | ||
| 85 | /// PLL S division factor. If None, PLL S output is disabled. | ||
| 86 | pub divs: Option<Plldivst>, | ||
| 87 | #[cfg(stm32h7rs)] | ||
| 88 | /// PLL T division factor. If None, PLL T output is disabled. | ||
| 89 | pub divt: Option<Plldivst>, | ||
| 81 | } | 90 | } |
| 82 | 91 | ||
| 83 | fn apb_div_tim(apb: &APBPrescaler, clk: Hertz, tim: TimerPrescaler) -> Hertz { | 92 | fn apb_div_tim(apb: &APBPrescaler, clk: Hertz, tim: TimerPrescaler) -> Hertz { |
| @@ -749,6 +758,12 @@ struct PllOutput { | |||
| 749 | q: Option<Hertz>, | 758 | q: Option<Hertz>, |
| 750 | #[allow(dead_code)] | 759 | #[allow(dead_code)] |
| 751 | r: Option<Hertz>, | 760 | r: Option<Hertz>, |
| 761 | #[cfg(stm32h7rs)] | ||
| 762 | #[allow(dead_code)] | ||
| 763 | s: Option<Hertz>, | ||
| 764 | #[cfg(stm32h7rs)] | ||
| 765 | #[allow(dead_code)] | ||
| 766 | t: Option<Hertz>, | ||
| 752 | } | 767 | } |
| 753 | 768 | ||
| 754 | fn init_pll(num: usize, config: Option<Pll>, input: &PllInput) -> PllOutput { | 769 | fn init_pll(num: usize, config: Option<Pll>, input: &PllInput) -> PllOutput { |
| @@ -767,6 +782,10 @@ fn init_pll(num: usize, config: Option<Pll>, input: &PllInput) -> PllOutput { | |||
| 767 | p: None, | 782 | p: None, |
| 768 | q: None, | 783 | q: None, |
| 769 | r: None, | 784 | r: None, |
| 785 | #[cfg(stm32h7rs)] | ||
| 786 | s: None, | ||
| 787 | #[cfg(stm32h7rs)] | ||
| 788 | t: None, | ||
| 770 | }; | 789 | }; |
| 771 | }; | 790 | }; |
| 772 | 791 | ||
| @@ -814,6 +833,10 @@ fn init_pll(num: usize, config: Option<Pll>, input: &PllInput) -> PllOutput { | |||
| 814 | }); | 833 | }); |
| 815 | let q = config.divq.map(|div| vco_clk / div); | 834 | let q = config.divq.map(|div| vco_clk / div); |
| 816 | let r = config.divr.map(|div| vco_clk / div); | 835 | let r = config.divr.map(|div| vco_clk / div); |
| 836 | #[cfg(stm32h7rs)] | ||
| 837 | let s = config.divs.map(|div| vco_clk / div); | ||
| 838 | #[cfg(stm32h7rs)] | ||
| 839 | let t = config.divt.map(|div| vco_clk / div); | ||
| 817 | 840 | ||
| 818 | #[cfg(stm32h5)] | 841 | #[cfg(stm32h5)] |
| 819 | RCC.pllcfgr(num).write(|w| { | 842 | RCC.pllcfgr(num).write(|w| { |
| @@ -840,6 +863,10 @@ fn init_pll(num: usize, config: Option<Pll>, input: &PllInput) -> PllOutput { | |||
| 840 | w.set_divpen(num, p.is_some()); | 863 | w.set_divpen(num, p.is_some()); |
| 841 | w.set_divqen(num, q.is_some()); | 864 | w.set_divqen(num, q.is_some()); |
| 842 | w.set_divren(num, r.is_some()); | 865 | w.set_divren(num, r.is_some()); |
| 866 | #[cfg(stm32h7rs)] | ||
| 867 | w.set_divsen(num, s.is_some()); | ||
| 868 | #[cfg(stm32h7rs)] | ||
| 869 | w.set_divten(num, t.is_some()); | ||
| 843 | }); | 870 | }); |
| 844 | } | 871 | } |
| 845 | 872 | ||
| @@ -850,10 +877,24 @@ fn init_pll(num: usize, config: Option<Pll>, input: &PllInput) -> PllOutput { | |||
| 850 | w.set_pllr(config.divr.unwrap_or(PllDiv::DIV2)); | 877 | w.set_pllr(config.divr.unwrap_or(PllDiv::DIV2)); |
| 851 | }); | 878 | }); |
| 852 | 879 | ||
| 880 | #[cfg(stm32h7rs)] | ||
| 881 | RCC.plldivr2(num).write(|w| { | ||
| 882 | w.set_plls(config.divs.unwrap_or(Plldivst::DIV2)); | ||
| 883 | w.set_pllt(config.divt.unwrap_or(Plldivst::DIV2)); | ||
| 884 | }); | ||
| 885 | |||
| 853 | RCC.cr().modify(|w| w.set_pllon(num, true)); | 886 | RCC.cr().modify(|w| w.set_pllon(num, true)); |
| 854 | while !RCC.cr().read().pllrdy(num) {} | 887 | while !RCC.cr().read().pllrdy(num) {} |
| 855 | 888 | ||
| 856 | PllOutput { p, q, r } | 889 | PllOutput { |
| 890 | p, | ||
| 891 | q, | ||
| 892 | r, | ||
| 893 | #[cfg(stm32h7rs)] | ||
| 894 | s, | ||
| 895 | #[cfg(stm32h7rs)] | ||
| 896 | t, | ||
| 897 | } | ||
| 857 | } | 898 | } |
| 858 | 899 | ||
| 859 | fn flash_setup(clk: Hertz, vos: VoltageScale) { | 900 | fn flash_setup(clk: Hertz, vos: VoltageScale) { |
diff --git a/examples/stm32h7rs/src/bin/blinky.rs b/examples/stm32h7rs/src/bin/blinky.rs index 137c585b7..5fd50fb15 100644 --- a/examples/stm32h7rs/src/bin/blinky.rs +++ b/examples/stm32h7rs/src/bin/blinky.rs | |||
| @@ -25,6 +25,8 @@ async fn main(_spawner: Spawner) { | |||
| 25 | divp: Some(PllDiv::DIV2), | 25 | divp: Some(PllDiv::DIV2), |
| 26 | divq: None, | 26 | divq: None, |
| 27 | divr: None, | 27 | divr: None, |
| 28 | divs: None, | ||
| 29 | divt: None, | ||
| 28 | }); | 30 | }); |
| 29 | config.rcc.sys = Sysclk::PLL1_P; // 600 Mhz | 31 | config.rcc.sys = Sysclk::PLL1_P; // 600 Mhz |
| 30 | config.rcc.ahb_pre = AHBPrescaler::DIV2; // 300 Mhz | 32 | config.rcc.ahb_pre = AHBPrescaler::DIV2; // 300 Mhz |
diff --git a/examples/stm32h7rs/src/bin/eth.rs b/examples/stm32h7rs/src/bin/eth.rs index 6d246bb09..d8002e9ba 100644 --- a/examples/stm32h7rs/src/bin/eth.rs +++ b/examples/stm32h7rs/src/bin/eth.rs | |||
| @@ -41,6 +41,8 @@ async fn main(spawner: Spawner) -> ! { | |||
| 41 | divp: Some(PllDiv::DIV2), | 41 | divp: Some(PllDiv::DIV2), |
| 42 | divq: None, | 42 | divq: None, |
| 43 | divr: None, | 43 | divr: None, |
| 44 | divs: None, | ||
| 45 | divt: None, | ||
| 44 | }); | 46 | }); |
| 45 | config.rcc.sys = Sysclk::PLL1_P; // 400 Mhz | 47 | config.rcc.sys = Sysclk::PLL1_P; // 400 Mhz |
| 46 | config.rcc.ahb_pre = AHBPrescaler::DIV2; // 200 Mhz | 48 | config.rcc.ahb_pre = AHBPrescaler::DIV2; // 200 Mhz |
diff --git a/examples/stm32h7rs/src/bin/usb_serial.rs b/examples/stm32h7rs/src/bin/usb_serial.rs index 56a9884af..23abc3e2f 100644 --- a/examples/stm32h7rs/src/bin/usb_serial.rs +++ b/examples/stm32h7rs/src/bin/usb_serial.rs | |||
| @@ -40,6 +40,8 @@ async fn main(_spawner: Spawner) { | |||
| 40 | divp: Some(PllDiv::DIV1), //600 MHz | 40 | divp: Some(PllDiv::DIV1), //600 MHz |
| 41 | divq: Some(PllDiv::DIV2), // 300 MHz | 41 | divq: Some(PllDiv::DIV2), // 300 MHz |
| 42 | divr: Some(PllDiv::DIV2), // 300 MHz | 42 | divr: Some(PllDiv::DIV2), // 300 MHz |
| 43 | divs: None, | ||
| 44 | divt: None, | ||
| 43 | }); | 45 | }); |
| 44 | config.rcc.sys = Sysclk::PLL1_P; // 600 MHz | 46 | config.rcc.sys = Sysclk::PLL1_P; // 600 MHz |
| 45 | config.rcc.ahb_pre = AHBPrescaler::DIV2; // 300 MHz | 47 | config.rcc.ahb_pre = AHBPrescaler::DIV2; // 300 MHz |
diff --git a/examples/stm32h7rs/src/bin/xspi_memory_mapped.rs b/examples/stm32h7rs/src/bin/xspi_memory_mapped.rs index 59045ca2e..4c1b450b4 100644 --- a/examples/stm32h7rs/src/bin/xspi_memory_mapped.rs +++ b/examples/stm32h7rs/src/bin/xspi_memory_mapped.rs | |||
| @@ -36,6 +36,8 @@ async fn main(_spawner: Spawner) { | |||
| 36 | divp: Some(PllDiv::DIV2), | 36 | divp: Some(PllDiv::DIV2), |
| 37 | divq: None, | 37 | divq: None, |
| 38 | divr: None, | 38 | divr: None, |
| 39 | divs: None, | ||
| 40 | divt: None, | ||
| 39 | }); | 41 | }); |
| 40 | config.rcc.sys = Sysclk::PLL1_P; // 600 Mhz | 42 | config.rcc.sys = Sysclk::PLL1_P; // 600 Mhz |
| 41 | config.rcc.ahb_pre = AHBPrescaler::DIV2; // 300 Mhz | 43 | config.rcc.ahb_pre = AHBPrescaler::DIV2; // 300 Mhz |
diff --git a/tests/stm32/src/common.rs b/tests/stm32/src/common.rs index a4d8048ce..cb63b3374 100644 --- a/tests/stm32/src/common.rs +++ b/tests/stm32/src/common.rs | |||
| @@ -681,6 +681,8 @@ pub fn config() -> Config { | |||
| 681 | divp: Some(PllDiv::DIV2), // 600Mhz | 681 | divp: Some(PllDiv::DIV2), // 600Mhz |
| 682 | divq: Some(PllDiv::DIV25), // 48Mhz | 682 | divq: Some(PllDiv::DIV25), // 48Mhz |
| 683 | divr: None, | 683 | divr: None, |
| 684 | divs: None, | ||
| 685 | divt: None, | ||
| 684 | }); | 686 | }); |
| 685 | config.rcc.sys = Sysclk::PLL1_P; // 600 Mhz | 687 | config.rcc.sys = Sysclk::PLL1_P; // 600 Mhz |
| 686 | config.rcc.ahb_pre = AHBPrescaler::DIV2; // 300 Mhz | 688 | config.rcc.ahb_pre = AHBPrescaler::DIV2; // 300 Mhz |
