From 1379eb4e707e2b60b381a7288a586657dc539dfc Mon Sep 17 00:00:00 2001 From: pennae Date: Wed, 17 May 2023 02:46:38 +0200 Subject: [PATCH] rp/clocks: handle fractional gpout dividers --- embassy-rp/src/clocks.rs | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/embassy-rp/src/clocks.rs b/embassy-rp/src/clocks.rs index 6d389cace..85d4d289b 100644 --- a/embassy-rp/src/clocks.rs +++ b/embassy-rp/src/clocks.rs @@ -821,11 +821,10 @@ impl<'d, T: GpoutPin> Gpout<'d, T> { }; let div = unsafe { c.clk_gpout_div(self.gpout.number()).read() }; - let int = if div.int() == 0 { 65536 } else { div.int() }; - // TODO handle fractional clock div - let _frac = div.frac(); + let int = if div.int() == 0 { 65536 } else { div.int() } as u64; + let frac = div.frac() as u64; - base / int + ((base as u64 * 256) / (int * 256 + frac)) as u32 } }