aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTyler Gilbert <[email protected]>2024-01-03 10:46:45 -0600
committerTyler Gilbert <[email protected]>2024-01-03 10:46:45 -0600
commit31bf1278072bdb865aa7d8d361152fe47957ce08 (patch)
tree3660e53af8fb354ac5d7594d25c9a3455251fc2c
parent3b6eaf414a92114037a40dcb3ce37a4191c57a2b (diff)
Update STM32 RCC U5 to support P and Q dividers
-rw-r--r--embassy-stm32/src/rcc/u5.rs18
-rw-r--r--examples/stm32u5/src/bin/usb_serial.rs2
2 files changed, 20 insertions, 0 deletions
diff --git a/embassy-stm32/src/rcc/u5.rs b/embassy-stm32/src/rcc/u5.rs
index 81bdec881..0321d51f7 100644
--- a/embassy-stm32/src/rcc/u5.rs
+++ b/embassy-stm32/src/rcc/u5.rs
@@ -45,6 +45,18 @@ pub struct PllConfig {
45 /// The multiplied clock – `source` divided by `m` times `n` – must be between 128 and 544 45 /// The multiplied clock – `source` divided by `m` times `n` – must be between 128 and 544
46 /// MHz. The upper limit may be lower depending on the `Config { voltage_range }`. 46 /// MHz. The upper limit may be lower depending on the `Config { voltage_range }`.
47 pub n: Plln, 47 pub n: Plln,
48 /// The divider for the P output.
49 ///
50 /// When used to drive the system clock, `source` divided by `m` times `n` divided by `r`
51 /// must not exceed 160 MHz. System clocks above 55 MHz require a non-default
52 /// `Config { voltage_range }`.
53 pub p: Plldiv,
54 /// The divider for the Q output.
55 ///
56 /// When used to drive the system clock, `source` divided by `m` times `n` divided by `r`
57 /// must not exceed 160 MHz. System clocks above 55 MHz require a non-default
58 /// `Config { voltage_range }`.
59 pub q: Plldiv,
48 /// The divider for the R output. 60 /// The divider for the R output.
49 /// 61 ///
50 /// When used to drive the system clock, `source` divided by `m` times `n` divided by `r` 62 /// When used to drive the system clock, `source` divided by `m` times `n` divided by `r`
@@ -60,6 +72,8 @@ impl PllConfig {
60 source: PllSource::HSI, 72 source: PllSource::HSI,
61 m: Pllm::DIV1, 73 m: Pllm::DIV1,
62 n: Plln::MUL10, 74 n: Plln::MUL10,
75 p: Plldiv::DIV3,
76 q: Plldiv::DIV2,
63 r: Plldiv::DIV1, 77 r: Plldiv::DIV1,
64 } 78 }
65 } 79 }
@@ -70,6 +84,8 @@ impl PllConfig {
70 source: PllSource::MSIS(Msirange::RANGE_48MHZ), 84 source: PllSource::MSIS(Msirange::RANGE_48MHZ),
71 m: Pllm::DIV3, 85 m: Pllm::DIV3,
72 n: Plln::MUL10, 86 n: Plln::MUL10,
87 p: Plldiv::DIV3,
88 q: Plldiv::DIV2,
73 r: Plldiv::DIV1, 89 r: Plldiv::DIV1,
74 } 90 }
75 } 91 }
@@ -301,6 +317,8 @@ pub(crate) unsafe fn init(config: Config) {
301 RCC.pll1divr().modify(|w| { 317 RCC.pll1divr().modify(|w| {
302 // Set the VCO multiplier 318 // Set the VCO multiplier
303 w.set_plln(pll.n); 319 w.set_plln(pll.n);
320 w.set_pllp(pll.p);
321 w.set_pllq(pll.q);
304 // Set the R output divisor 322 // Set the R output divisor
305 w.set_pllr(pll.r); 323 w.set_pllr(pll.r);
306 }); 324 });
diff --git a/examples/stm32u5/src/bin/usb_serial.rs b/examples/stm32u5/src/bin/usb_serial.rs
index 44d1df4f1..dca34fd0e 100644
--- a/examples/stm32u5/src/bin/usb_serial.rs
+++ b/examples/stm32u5/src/bin/usb_serial.rs
@@ -26,6 +26,8 @@ async fn main(_spawner: Spawner) {
26 source: PllSource::HSI, 26 source: PllSource::HSI,
27 m: Pllm::DIV2, 27 m: Pllm::DIV2,
28 n: Plln::MUL10, 28 n: Plln::MUL10,
29 p: Plldiv::DIV1,
30 q: Plldiv::DIV1,
29 r: Plldiv::DIV1, 31 r: Plldiv::DIV1,
30 }); 32 });
31 config.rcc.hsi48 = Some(Hsi48Config { sync_from_usb: true }); // needed for USB 33 config.rcc.hsi48 = Some(Hsi48Config { sync_from_usb: true }); // needed for USB