From 0dbd6f0f246c31c7264814bc01764e7181609e89 Mon Sep 17 00:00:00 2001 From: thalesfragoso Date: Mon, 15 Jul 2019 22:18:43 -0300 Subject: [PATCH] Fixes hclk calculation --- CHANGELOG.md | 2 ++ src/rcc.rs | 6 +++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 39a92bf9..5bb886f4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -24,6 +24,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/). ### Changed +- Fix hclk miscalculation + ## [v0.3.0] - 2019-04-27 ### Added diff --git a/src/rcc.rs b/src/rcc.rs index b826b306..d9bf8c78 100644 --- a/src/rcc.rs +++ b/src/rcc.rs @@ -204,7 +204,11 @@ impl CFGR { }) .unwrap_or(0b0111); - let hclk = sysclk / (1 << (hpre_bits - 0b0111)); + let hclk = if hpre_bits >= 0b1100 { + sysclk / (1 << (hpre_bits - 0b0110)) + } else { + sysclk / (1 << (hpre_bits - 0b0111)) + }; assert!(hclk <= 72_000_000);