Created
May 22, 2022 23:16
-
-
Save kinasmith/7ceca6df2b887f24325df7fb3526d717 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#![no_std] | |
#![no_main] | |
use cortex_m::peripheral; | |
use cortex_m_rt::entry; | |
use panic_halt as _; | |
use stm32f3xx_hal::{pac, delay, prelude::*}; | |
#[entry] | |
fn main() -> ! { | |
let dp = pac::Peripherals::take().unwrap(); | |
let mut flash = dp.FLASH.constrain(); | |
let mut rcc = dp.RCC.constrain(); | |
//CLK setting | |
let clk = rcc.cfgr | |
//.use_hse(8.MHz()) //Use external oscillator | |
//.bypass_hse() //Use external clock signal | |
//.enable_css() //Enable CSS (Clock Security System) | |
.hclk(64.MHz()) | |
.sysclk(64.MHz()) | |
.pclk1(32.MHz()) | |
.pclk2(64.MHz()) | |
.freeze(&mut flash.acr); //flash access wait setting | |
//GPIO setting | |
let mut gpiob = dp.GPIOB.split(&mut rcc.ahb); | |
let mut led = | |
gpiob | |
.pb3 | |
.into_push_pull_output(&mut gpiob.moder, &mut gpiob.otyper); | |
//delay setting | |
//let mut core = cortex_m::Peripherals::take().unwrap(); | |
let core = peripheral::Peripherals::take().unwrap(); | |
let systick = core.SYST; | |
let mut blocking = delay::Delay::new(systick, clk); | |
loop { | |
led.toggle().unwrap(); | |
blocking.delay_ms(100u32); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment