rotor-control-stm32/src/main.rs

45 lines
1.2 KiB
Rust

#![no_std]
#![no_main]
#![feature(type_alias_impl_trait)]
use core::fmt::Write;
use defmt::panic;
use defmt_rtt as _;
use panic_probe as _;
use embassy_executor::Spawner;
use embassy_stm32::gpio::{Level, Output, Speed};
use embassy_stm32::time::Hertz;
use embassy_stm32::Config;
use embassy_time::{Duration, Timer};
mod display;
use display::display_task;
mod usb;
use usb::usb_task;
#[embassy_executor::main]
async fn main(spawner: Spawner) {
let mut config = Config::default();
config.rcc.hse = Some(Hertz(8_000_000));
config.rcc.sys_ck = Some(Hertz(48_000_000));
config.rcc.pclk1 = Some(Hertz(24_000_000));
let mut p = embassy_stm32::init(config);
defmt::info!("Startup");
{
// BluePill board has a pull-up resistor on the D+ line.
// Pull the D+ pin down to send a RESET condition to the USB bus.
// This forced reset is needed only for development, without it host
// will not reset your device when you upload new firmware.
let _dp = Output::new(&mut p.PA12, Level::Low, Speed::Low);
Timer::after(Duration::from_millis(10)).await;
}
spawner.spawn(usb_task(p.USB, p.PA12, p.PA11)).unwrap();
spawner.spawn(display_task(p.I2C1, p.PB6, p.PB7)).unwrap();
}