forked from stm32-rs/stm32h7xx-hal
-
Notifications
You must be signed in to change notification settings - Fork 0
/
vos0.rs
61 lines (52 loc) · 1.86 KB
/
vos0.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
//! Example that demonstrates the use of VOS0
//!
//! 7b3/7a3/7b0 support tested on a NUCLEO-H7A3ZI-Q board
#![deny(warnings)]
#![no_main]
#![no_std]
use cortex_m_rt::entry;
#[macro_use]
mod utilities;
use stm32h7xx_hal::{pac, prelude::*, rcc};
use log::info;
#[entry]
fn main() -> ! {
utilities::logger::init();
let dp = pac::Peripherals::take().expect("Cannot take peripherals");
// Constrain and Freeze power
info!("Setup PWR... ");
let pwr = dp.PWR.constrain();
let pwrcfg = example_power!(pwr).vos0(&dp.SYSCFG).freeze();
// Constrain and Freeze clock
//
// The PllConfigStrategy::Normal strategy uses the medium range VCO which
// has a maximum of 420 MHz. Switching to PllConfigStrategy::Iterative sets
// the VCO to wide range to allow this clock to reach 480 MHz
info!("Setup RCC... ");
let rcc = dp.RCC.constrain();
#[cfg(not(feature = "rm0455"))]
let rcc = rcc.sys_ck(480.MHz());
#[cfg(feature = "rm0455")] // 7b3/7a3/7b0 parts are limited to 280MHz
let rcc = rcc.sys_ck(280.MHz());
let ccdr = rcc
.pll1_strategy(rcc::PllConfigStrategy::Iterative)
.freeze(pwrcfg, &dp.SYSCFG);
info!("");
info!("stm32h7xx-hal example - VOS0");
info!("");
// HCLK
info!("hclk = {} MHz", ccdr.clocks.hclk().raw() as f32 / 1e6);
#[cfg(not(feature = "rm0455"))]
assert_eq!(ccdr.clocks.hclk().raw(), 240_000_000);
#[cfg(feature = "rm0455")] // 7b3/7a3/7b0 parts
assert_eq!(ccdr.clocks.hclk().raw(), 280_000_000);
// SYS_CK
info!("sys_ck = {} MHz", ccdr.clocks.sys_ck().raw() as f32 / 1e6);
#[cfg(not(feature = "rm0455"))]
assert_eq!(ccdr.clocks.sys_ck().raw(), 480_000_000);
#[cfg(feature = "rm0455")] // 7b3/7a3/7b0 parts
assert_eq!(ccdr.clocks.sys_ck().raw(), 280_000_000);
loop {
cortex_m::asm::nop()
}
}