Skip to content

Commit ae70262

Browse files
authored
Merge pull request #125 from msmouni/patch-2
Set PLLM, PLLN and PLLP
2 parents 3986d2e + abfcc6c commit ae70262

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

src/rcc.rs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -639,6 +639,21 @@ impl CFGR {
639639
return;
640640
}
641641

642+
// We check if (pllm, plln, pllp) allow to obtain the requested Sysclk,
643+
// so that we don't have to calculate them
644+
let p_ok = (sysclk as u64)
645+
== (base_clk as u64 * self.plln as u64
646+
/ self.pllm as u64
647+
/ match self.pllp {
648+
PLLP::Div2 => 2,
649+
PLLP::Div4 => 4,
650+
PLLP::Div6 => 6,
651+
PLLP::Div8 => 8,
652+
});
653+
if p_ok && q.is_none() {
654+
return;
655+
}
656+
642657
if let Some((m, n, p, q)) = CFGR::calculate_mnpq(base_clk, FreqRequest { p, q }) {
643658
self.pllm = m as u8;
644659
self.plln = n as u16;

0 commit comments

Comments
 (0)