aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRick Rogers <[email protected]>2025-07-25 15:03:37 -0400
committerRick Rogers <[email protected]>2025-07-25 15:03:37 -0400
commita5a9c02543fbe978c68a707654029552f6b7b00a (patch)
tree8a7ca2c4f4129f45d1a293b35be039182932a89f
parentc37fb51cfe25511b2222e92e37b80933079ed3fc (diff)
include proper pll divs/divt initialization
-rw-r--r--embassy-stm32/build.rs2
-rw-r--r--embassy-stm32/src/rcc/h.rs34
2 files changed, 34 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 c31b1bbd1..837210b6a 100644
--- a/embassy-stm32/src/rcc/h.rs
+++ b/embassy-stm32/src/rcc/h.rs
@@ -758,6 +758,12 @@ struct PllOutput {
758 q: Option<Hertz>, 758 q: Option<Hertz>,
759 #[allow(dead_code)] 759 #[allow(dead_code)]
760 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>,
761} 767}
762 768
763fn init_pll(num: usize, config: Option<Pll>, input: &PllInput) -> PllOutput { 769fn init_pll(num: usize, config: Option<Pll>, input: &PllInput) -> PllOutput {
@@ -776,6 +782,10 @@ fn init_pll(num: usize, config: Option<Pll>, input: &PllInput) -> PllOutput {
776 p: None, 782 p: None,
777 q: None, 783 q: None,
778 r: None, 784 r: None,
785 #[cfg(stm32h7rs)]
786 s: None,
787 #[cfg(stm32h7rs)]
788 t: None,
779 }; 789 };
780 }; 790 };
781 791
@@ -823,6 +833,10 @@ fn init_pll(num: usize, config: Option<Pll>, input: &PllInput) -> PllOutput {
823 }); 833 });
824 let q = config.divq.map(|div| vco_clk / div); 834 let q = config.divq.map(|div| vco_clk / div);
825 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);
826 840
827 #[cfg(stm32h5)] 841 #[cfg(stm32h5)]
828 RCC.pllcfgr(num).write(|w| { 842 RCC.pllcfgr(num).write(|w| {
@@ -849,6 +863,10 @@ fn init_pll(num: usize, config: Option<Pll>, input: &PllInput) -> PllOutput {
849 w.set_divpen(num, p.is_some()); 863 w.set_divpen(num, p.is_some());
850 w.set_divqen(num, q.is_some()); 864 w.set_divqen(num, q.is_some());
851 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());
852 }); 870 });
853 } 871 }
854 872
@@ -859,10 +877,24 @@ fn init_pll(num: usize, config: Option<Pll>, input: &PllInput) -> PllOutput {
859 w.set_pllr(config.divr.unwrap_or(PllDiv::DIV2)); 877 w.set_pllr(config.divr.unwrap_or(PllDiv::DIV2));
860 }); 878 });
861 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
862 RCC.cr().modify(|w| w.set_pllon(num, true)); 886 RCC.cr().modify(|w| w.set_pllon(num, true));
863 while !RCC.cr().read().pllrdy(num) {} 887 while !RCC.cr().read().pllrdy(num) {}
864 888
865 PllOutput { p, q, r } 889 PllOutput {
890 p,
891 q,
892 r,
893 #[cfg(stm32h7rs)]
894 s,
895 #[cfg(stm32h7rs)]
896 t,
897 }
866} 898}
867 899
868fn flash_setup(clk: Hertz, vos: VoltageScale) { 900fn flash_setup(clk: Hertz, vos: VoltageScale) {