You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The existence of a crate::rcc::Clocks value is supposed to assert that
the MCU clocks have been configured and that they cannot be changed
anymore. That works by consuming the only instance of CFGR in the
corresponding function and then returning a Clocks value.
However, having crate::rcc::config::Config::get_clocks public implies
that external code can, at any time, generate a Clocks value: by simply
constructing a Config instance (all fields are public) and calling the
function.
```rust
#![no_std]
#![no_main]
use panic_halt as _;
use stm32f1xx_hal as hal;
use cortex_m_rt::entry;
#[entry]
fn main() -> ! {
let clocks: hal::rcc::Clocks = hal::rcc::Config{
hse: Some(8000000),
pllmul: Some(8),
hpre: hal::rcc::HPre::DIV1,
ppre1: hal::rcc::PPre::DIV2,
ppre2: hal::rcc::PPre::DIV1,
adcpre: hal::rcc::AdcPre::DIV8,
usbpre: hal::rcc::UsbPre::DIV1,
}.get_clocks();
loop{}
}
```
This is a breaking change, obviously, but there are no non-breaking
alternatives.
Fixes#437.
0 commit comments