Merge pull request #2396 from tyler-gilbert/update-rcc-u5-with-sai-support

Update STM32 RCC U5 to support P and Q dividers
This commit is contained in:
Dario Nieuwenhuis 2024-01-03 17:12:50 +00:00 committed by GitHub
commit 87ac51d656
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 18 additions and 0 deletions

View file

@ -45,6 +45,16 @@ pub struct PllConfig {
/// The multiplied clock `source` divided by `m` times `n` must be between 128 and 544
/// MHz. The upper limit may be lower depending on the `Config { voltage_range }`.
pub n: Plln,
/// The divider for the P output.
///
/// The P output is one of several options
/// that can be used to feed the SAI/MDF/ADF Clock mux's.
pub p: Plldiv,
/// The divider for the Q output.
///
/// The Q ouput is one of severals options that can be used to feed the 48MHz clocks
/// and the OCTOSPI clock. It may also be used on the MDF/ADF clock mux's.
pub q: Plldiv,
/// The divider for the R output.
///
/// When used to drive the system clock, `source` divided by `m` times `n` divided by `r`
@ -60,6 +70,8 @@ impl PllConfig {
source: PllSource::HSI,
m: Pllm::DIV1,
n: Plln::MUL10,
p: Plldiv::DIV3,
q: Plldiv::DIV2,
r: Plldiv::DIV1,
}
}
@ -70,6 +82,8 @@ impl PllConfig {
source: PllSource::MSIS(Msirange::RANGE_48MHZ),
m: Pllm::DIV3,
n: Plln::MUL10,
p: Plldiv::DIV3,
q: Plldiv::DIV2,
r: Plldiv::DIV1,
}
}
@ -301,6 +315,8 @@ pub(crate) unsafe fn init(config: Config) {
RCC.pll1divr().modify(|w| {
// Set the VCO multiplier
w.set_plln(pll.n);
w.set_pllp(pll.p);
w.set_pllq(pll.q);
// Set the R output divisor
w.set_pllr(pll.r);
});

View file

@ -26,6 +26,8 @@ async fn main(_spawner: Spawner) {
source: PllSource::HSI,
m: Pllm::DIV2,
n: Plln::MUL10,
p: Plldiv::DIV1,
q: Plldiv::DIV1,
r: Plldiv::DIV1,
});
config.rcc.hsi48 = Some(Hsi48Config { sync_from_usb: true }); // needed for USB