-
Notifications
You must be signed in to change notification settings - Fork 14
/
blinky_hal.rs
44 lines (34 loc) · 1.13 KB
/
blinky_hal.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
#![no_main]
#![no_std]
use cortex_m::asm;
use cortex_m_rt::entry;
use panic_semihosting as _;
use daisy_bsp::hal;
use hal::rcc::PllConfigStrategy;
use hal::{pac, prelude::*};
#[entry]
fn main() -> ! {
let dp = pac::Peripherals::take().unwrap();
// - power & clocks -------------------------------------------------------
let pwr = dp.PWR.constrain();
let pwrcfg = pwr.vos0(&dp.SYSCFG).freeze();
let ccdr = dp
.RCC
.constrain()
.use_hse(16.MHz()) // external crystal @ 16 MHz
.pll1_strategy(PllConfigStrategy::Iterative) // pll1 drives system clock
.sys_ck(480.MHz()) // system clock @ 480 MHz
.freeze(pwrcfg, &dp.SYSCFG);
// - pins -----------------------------------------------------------------
let gpioc = dp.GPIOC.split(ccdr.peripheral.GPIOC);
let mut led_user = gpioc.pc7.into_push_pull_output();
// - main loop ------------------------------------------------------------
loop {
loop {
led_user.set_high();
asm::delay(480_000_000);
led_user.set_low();
asm::delay(480_000_000);
}
}
}