Skip to content

Commit efc9438

Browse files
nicolas-robinburrbull
authored andcommitted
add an option to allow overclocking
1 parent fea4bb0 commit efc9438

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,14 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
1515
- Add dac
1616
- Fix flash error flag clearing
1717
- Clarify README for windows users
18+
- Add an option to allow overclocking [#494]
1819

1920
### Added
2021

2122
- Allow to set HSE bypass bit in `RCC` clock configuration register to use an external clock input on the `OSC_IN` pin
2223
- support `embedded-hal-1.0`
24+
25+
[#494]: https://github.com/stm32-rs/stm32f1xx-hal/pull/494
2326

2427
## [v0.10.0] - 2022-12-12
2528

src/rcc.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -507,6 +507,7 @@ pub struct Config {
507507
#[cfg(any(feature = "stm32f103", feature = "connectivity"))]
508508
pub usbpre: UsbPre,
509509
pub adcpre: AdcPre,
510+
pub allow_overclock: bool,
510511
}
511512

512513
impl Default for Config {
@@ -521,6 +522,7 @@ impl Default for Config {
521522
#[cfg(any(feature = "stm32f103", feature = "connectivity"))]
522523
usbpre: UsbPre::Div15,
523524
adcpre: AdcPre::Div2,
525+
allow_overclock: false,
524526
}
525527
}
526528
}
@@ -681,6 +683,7 @@ impl Config {
681683
#[cfg(any(feature = "stm32f103", feature = "connectivity"))]
682684
usbpre,
683685
adcpre: apre_bits,
686+
allow_overclock: false,
684687
}
685688
}
686689

@@ -724,11 +727,13 @@ impl Config {
724727
);
725728

726729
assert!(
727-
sysclk <= 72_000_000
730+
self.allow_overclock ||
731+
(sysclk <= 72_000_000
728732
&& hclk <= 72_000_000
729733
&& pclk1 <= 36_000_000
730734
&& pclk2 <= 72_000_000
731735
&& adcclk <= 14_000_000
736+
)
732737
);
733738

734739
Clocks {
@@ -763,6 +768,7 @@ fn rcc_config_usb() {
763768
#[cfg(any(feature = "stm32f103", feature = "connectivity"))]
764769
usbpre: UsbPre::Div1,
765770
adcpre: AdcPre::Div8,
771+
allow_overclock: false,
766772
};
767773
assert_eq!(config, config_expected);
768774

0 commit comments

Comments
 (0)