diff options
| author | Rick Rogers <[email protected]> | 2025-07-25 15:03:37 -0400 |
|---|---|---|
| committer | Rick Rogers <[email protected]> | 2025-07-25 15:03:37 -0400 |
| commit | a5a9c02543fbe978c68a707654029552f6b7b00a (patch) | |
| tree | 8a7ca2c4f4129f45d1a293b35be039182932a89f /embassy-stm32/src/rcc | |
| parent | c37fb51cfe25511b2222e92e37b80933079ed3fc (diff) | |
include proper pll divs/divt initialization
Diffstat (limited to 'embassy-stm32/src/rcc')
| -rw-r--r-- | embassy-stm32/src/rcc/h.rs | 34 |
1 files changed, 33 insertions, 1 deletions
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 | ||
| 763 | fn init_pll(num: usize, config: Option<Pll>, input: &PllInput) -> PllOutput { | 769 | fn 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 | ||
| 868 | fn flash_setup(clk: Hertz, vos: VoltageScale) { | 900 | fn flash_setup(clk: Hertz, vos: VoltageScale) { |
