init basic examples and setup
This commit is contained in:
37
examples/blinky-basic/src/main.rs
Normal file
37
examples/blinky-basic/src/main.rs
Normal file
@@ -0,0 +1,37 @@
|
||||
#![deny(unsafe_code)]
|
||||
#![no_std]
|
||||
#![no_main]
|
||||
|
||||
use cortex_m_rt::entry;
|
||||
use defmt::info;
|
||||
use defmt_rtt as _;
|
||||
use panic_probe as _;
|
||||
use stm32f1xx_hal::{pac, prelude::*};
|
||||
|
||||
const ON_MS: u16 = 500;
|
||||
const OFF_MS: u16 = 500;
|
||||
|
||||
#[entry]
|
||||
fn main() -> ! {
|
||||
let dp = pac::Peripherals::take().unwrap();
|
||||
let cp = cortex_m::Peripherals::take().unwrap();
|
||||
|
||||
let mut rcc = dp.RCC.constrain();
|
||||
let mut gpioc = dp.GPIOC.split(&mut rcc);
|
||||
|
||||
// Splitting the GPIO block gives this function ownership of the LED pin.
|
||||
let mut led = gpioc.pc13.into_push_pull_output(&mut gpioc.crh);
|
||||
let mut delay = cp.SYST.delay(&rcc.clocks);
|
||||
|
||||
info!("blinky-basic: PC13 LED is assumed active-low");
|
||||
|
||||
loop {
|
||||
led.set_low();
|
||||
info!("led on");
|
||||
delay.delay_ms(ON_MS);
|
||||
|
||||
led.set_high();
|
||||
info!("led off");
|
||||
delay.delay_ms(OFF_MS);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user