#![no_main]
#![no_std]
use panic_halt as _;
use cortex_m_rt::entry;
use stm32f4xx_hal as hal;
use crate::hal::{pac, prelude::*, serial::Serial};
use core::fmt::Write;
#[entry]
fn main() -> ! {
let dp = pac::Peripherals::take().unwrap();
let cp = cortex_m::peripheral::Peripherals::take().unwrap();
let gpioa = dp.GPIOA.split();
let rcc = dp.RCC.constrain();
let clocks = rcc.cfgr.use_hse(8.mhz()).freeze();
let mut delay = hal::delay::Delay::new(cp.SYST, &clocks);
let tx_pin = gpioa.pa2.into_alternate();
let mut tx = Serial::tx(dp.USART2, tx_pin, 9600.bps(), &clocks).unwrap();
let mut value: u8 = 0;
loop {
writeln!(tx, "value: {:02}\r", value).unwrap();
value = value.wrapping_add(1);
delay.delay_ms(500_u32);
}
}