This repository has been archived by the owner. It is now read-only.
Permalink
Branch: master
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
47 lines (37 sloc) 1.01 KB
//! Blinks an LED
#![deny(unsafe_code)]
#![deny(warnings)]
#![no_std]
#![no_main]
extern crate panic_halt;
use stm32f103xx_hal as hal;
use nb::block;
use crate::hal::{
prelude::*,
device,
timer::Timer,
};
use cortex_m_rt::entry;
#[entry]
fn main() -> ! {
let cp = cortex_m::Peripherals::take().unwrap();
let dp = device::Peripherals::take().unwrap();
let mut flash = dp.FLASH.constrain();
let mut rcc = dp.RCC.constrain();
// Try a different clock configuration
let clocks = rcc.cfgr.freeze(&mut flash.acr);
// let clocks = rcc.cfgr
// .sysclk(64.mhz())
// .pclk1(32.mhz())
// .freeze(&mut flash.acr);
let mut gpioc = dp.GPIOC.split(&mut rcc.apb2);
let mut led = gpioc.pc13.into_push_pull_output(&mut gpioc.crh);
// Try a different timer (even SYST)
let mut timer = Timer::syst(cp.SYST, 1.hz(), clocks);
loop {
block!(timer.wait()).unwrap();
led.set_high();
block!(timer.wait()).unwrap();
led.set_low();
}
}