aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorpennae <[email protected]>2023-05-17 02:25:28 +0200
committerpennae <[email protected]>2023-05-17 21:36:19 +0200
commit1b3d9a0aeffd9e0619126c3b2dc42520cc2b4209 (patch)
treee5db184b391a4252dad5db3cdfd68c8e89034047
parentf79d8cb2d3998662eb4555d424cc75f3899a3151 (diff)
rp/clocks: compactify pll setup
we don't need to preserve existing bits of the pll pwr register, so let's only write and save a few instructions.
-rw-r--r--embassy-rp/src/clocks.rs9
1 files changed, 7 insertions, 2 deletions
diff --git a/embassy-rp/src/clocks.rs b/embassy-rp/src/clocks.rs
index 9e581f105..cfc94f844 100644
--- a/embassy-rp/src/clocks.rs
+++ b/embassy-rp/src/clocks.rs
@@ -634,10 +634,12 @@ unsafe fn configure_pll(p: pac::pll::Pll, input_freq: u32, config: PllConfig) ->
634 p.fbdiv_int().write(|w| w.set_fbdiv_int(config.fbdiv)); 634 p.fbdiv_int().write(|w| w.set_fbdiv_int(config.fbdiv));
635 635
636 // Turn on PLL 636 // Turn on PLL
637 p.pwr().modify(|w| { 637 let pwr = p.pwr().write(|w| {
638 w.set_dsmpd(true); // "nothing is achieved by setting this low"
638 w.set_pd(false); 639 w.set_pd(false);
639 w.set_vcopd(false); 640 w.set_vcopd(false);
640 w.set_postdivpd(true); 641 w.set_postdivpd(true);
642 *w
641 }); 643 });
642 644
643 // Wait for PLL to lock 645 // Wait for PLL to lock
@@ -650,7 +652,10 @@ unsafe fn configure_pll(p: pac::pll::Pll, input_freq: u32, config: PllConfig) ->
650 }); 652 });
651 653
652 // Turn on post divider 654 // Turn on post divider
653 p.pwr().modify(|w| w.set_postdivpd(false)); 655 p.pwr().write(|w| {
656 *w = pwr;
657 w.set_postdivpd(false);
658 });
654 659
655 vco_freq / ((config.post_div1 * config.post_div2) as u32) 660 vco_freq / ((config.post_div1 * config.post_div2) as u32)
656} 661}