#![no_std] #![no_main] // We need to use cortex_m here so the linker can find it's critical-section, but we import is as // an underscore since we don't directly use any of its symbols. extern crate cortex_m; // The entry import gives us a macro to indicate where the microcontroller should start the // program, and also sets up the FPU on our Cortex-M4F. use cortex_m_rt::entry; use hal::{pac, prelude::*, rcc::Config}; // Provides functions that allow printing back to probe-rs. use panic_rtt_target as _; // use rtt_target::{rprintln, rtt_init_print}; // Start here, and don't ever return from this function. #[entry] fn main() -> ! { let dp = pac::Peripherals::take().unwrap(); // Configure the clock. let mut rcc = dp.RCC.freeze(Config::hsi16()); // Acquire the GPIOA peripheral. This also enables the clock for GPIOA in // the RCC register. let gpioa = dp.GPIOA.split(&mut rcc); // Configure PA1 as output. let mut led = gpioa.pa3.into_push_pull_output(); loop { // Set the LED high one million times in a row. for _ in 0..1_000_000 { led.set_high().unwrap(); } // Set the LED low one million times in a row. for _ in 0..1_000_000 { led.set_low().unwrap(); } } }