Merge pull request #367 from embassy-rs/metapac-cleanup

stm32-metapac cleanups
This commit is contained in:
Dario Nieuwenhuis
2021-08-20 00:05:08 +02:00
committed by GitHub
59 changed files with 507 additions and 917 deletions

View File

@ -12,7 +12,7 @@ use embassy_stm32::Peripherals;
#[path = "../example_common.rs"]
mod example_common;
#[embassy::main(config = "example_common::config()")]
#[embassy::main]
async fn main(_spawner: Spawner, _p: Peripherals) -> ! {
loop {
Timer::after(Duration::from_secs(1)).await;

View File

@ -6,13 +6,6 @@ use panic_probe as _;
pub use defmt::*;
use core::sync::atomic::{AtomicUsize, Ordering};
use embassy_stm32::Config;
pub fn config() -> Config {
let mut config = Config::default();
config.rcc.enable_debug_wfe = true;
config
}
defmt::timestamp! {"{=u64}", {
static COUNT: AtomicUsize = AtomicUsize::new(0);

View File

@ -8,7 +8,6 @@
mod example_common;
use embassy::executor::Spawner;
use embassy::time::{Duration, Timer};
use embassy_stm32::dbgmcu::Dbgmcu;
use embassy_stm32::gpio::{Level, Output, Speed};
use embassy_stm32::Peripherals;
use embedded_hal::digital::v2::OutputPin;
@ -18,10 +17,6 @@ use example_common::*;
async fn main(_spawner: Spawner, p: Peripherals) {
info!("Hello World!");
unsafe {
Dbgmcu::enable_all();
}
let mut led = Output::new(p.PB7, Level::High, Speed::Low);
loop {

View File

@ -7,7 +7,6 @@
#[path = "../example_common.rs"]
mod example_common;
use cortex_m_rt::entry;
use embassy_stm32::dbgmcu::Dbgmcu;
use embassy_stm32::gpio::{Input, Level, Output, Pull, Speed};
use embedded_hal::digital::v2::{InputPin, OutputPin};
use example_common::*;
@ -16,10 +15,6 @@ use example_common::*;
fn main() -> ! {
info!("Hello World!");
unsafe {
Dbgmcu::enable_all();
}
let p = embassy_stm32::init(Default::default());
let button = Input::new(p.PC13, Pull::Down);

View File

@ -7,7 +7,6 @@
#[path = "../example_common.rs"]
mod example_common;
use embassy::executor::Spawner;
use embassy_stm32::dbgmcu::Dbgmcu;
use embassy_stm32::exti::ExtiInput;
use embassy_stm32::gpio::{Input, Pull};
use embassy_stm32::Peripherals;
@ -18,10 +17,6 @@ use example_common::*;
async fn main(_spawner: Spawner, p: Peripherals) {
info!("Hello World!");
unsafe {
Dbgmcu::enable_all();
}
let button = Input::new(p.PC13, Pull::Down);
let mut button = ExtiInput::new(button, p.EXTI13);

View File

@ -10,7 +10,6 @@ mod example_common;
use cortex_m_rt::entry;
use embassy_stm32::can::filter::Mask32;
use embassy_stm32::can::{Can, Frame, StandardId};
use embassy_stm32::dbgmcu::Dbgmcu;
use embassy_stm32::gpio::{Input, Pull};
use example_common::*;
@ -18,10 +17,6 @@ use example_common::*;
fn main() -> ! {
info!("Hello World!");
unsafe {
Dbgmcu::enable_all();
}
let mut p = embassy_stm32::init(Default::default());
// The next two lines are a workaround for testing without transceiver.

View File

@ -17,7 +17,6 @@ mod example_common;
fn config() -> Config {
let mut config = Config::default();
config.rcc.sys_ck = Some(Hertz(84_000_000));
config.rcc.enable_debug_wfe = true;
config
}

View File

@ -8,7 +8,6 @@
mod example_common;
use cortex_m_rt::entry;
use embassy_stm32::dbgmcu::Dbgmcu;
use embassy_stm32::dma::NoDma;
use embassy_stm32::gpio::{Level, Output, Speed};
use embassy_stm32::spi::{Config, Spi};
@ -21,10 +20,6 @@ use example_common::*;
fn main() -> ! {
info!("Hello World, dude!");
unsafe {
Dbgmcu::enable_all();
}
let p = embassy_stm32::init(Default::default());
let mut spi = Spi::new(

View File

@ -9,7 +9,6 @@ mod example_common;
use core::fmt::Write;
use core::str::from_utf8;
use embassy::executor::Spawner;
use embassy_stm32::dbgmcu::Dbgmcu;
use embassy_stm32::spi::{Config, Spi};
use embassy_stm32::time::Hertz;
use embassy_stm32::Peripherals;
@ -21,10 +20,6 @@ use heapless::String;
async fn main(_spawner: Spawner, p: Peripherals) {
info!("Hello World!");
unsafe {
Dbgmcu::enable_all();
}
let mut spi = Spi::new(
p.SPI1,
p.PB3,

View File

@ -7,7 +7,6 @@
#[path = "../example_common.rs"]
mod example_common;
use cortex_m_rt::entry;
use embassy_stm32::dbgmcu::Dbgmcu;
use embassy_stm32::dma::NoDma;
use embassy_stm32::usart::{Config, Uart};
use embedded_hal::blocking::serial::Write;
@ -17,10 +16,6 @@ use example_common::*;
fn main() -> ! {
info!("Hello World!");
unsafe {
Dbgmcu::enable_all();
}
let p = embassy_stm32::init(Default::default());
let config = Config::default();

View File

@ -8,7 +8,6 @@
mod example_common;
use core::fmt::Write;
use embassy::executor::Spawner;
use embassy_stm32::dbgmcu::Dbgmcu;
use embassy_stm32::dma::NoDma;
use embassy_stm32::usart::{Config, Uart};
use embassy_stm32::Peripherals;
@ -20,10 +19,6 @@ use heapless::String;
async fn main(_spawner: Spawner, p: Peripherals) {
info!("Hello World!");
unsafe {
Dbgmcu::enable_all();
}
let config = Config::default();
let mut usart = Uart::new(p.USART3, p.PD9, p.PD8, p.DMA1_CH3, NoDma, config);

View File

@ -8,7 +8,6 @@
mod example_common;
use embassy::executor::Spawner;
use embassy::time::{Duration, Timer};
use embassy_stm32::dbgmcu::Dbgmcu;
use embassy_stm32::gpio::{Level, Output, Speed};
use embassy_stm32::Peripherals;
use embedded_hal::digital::v2::OutputPin;
@ -18,8 +17,6 @@ use example_common::*;
async fn main(_spawner: Spawner, p: Peripherals) {
info!("Hello World!");
unsafe { Dbgmcu::enable_all() };
let mut led = Output::new(p.PB14, Level::High, Speed::Low);
loop {

View File

@ -7,7 +7,6 @@
#[path = "../example_common.rs"]
mod example_common;
use embassy::executor::Spawner;
use embassy_stm32::dbgmcu::Dbgmcu;
use embassy_stm32::exti::ExtiInput;
use embassy_stm32::gpio::{Input, Pull};
use embassy_stm32::Peripherals;
@ -18,10 +17,6 @@ use example_common::*;
async fn main(_spawner: Spawner, p: Peripherals) {
info!("Hello World!");
unsafe {
Dbgmcu::enable_all();
}
let button = Input::new(p.PC13, Pull::Down);
let mut button = ExtiInput::new(button, p.EXTI13);

View File

@ -19,10 +19,6 @@ fn main() -> ! {
let p = embassy_stm32::init(config());
unsafe {
Dbgmcu::enable_all();
}
let mut dac = Dac::new(p.DAC1, p.PA4, NoPin);
loop {
@ -33,7 +29,6 @@ fn main() -> ! {
}
}
use embassy_stm32::dbgmcu::Dbgmcu;
use micromath::F32Ext;
fn to_sine_wave(v: u8) -> u8 {

View File

@ -19,7 +19,6 @@ use embassy_macros::interrupt_take;
use embassy_net::{
Config as NetConfig, Ipv4Address, Ipv4Cidr, StackResources, StaticConfigurator, TcpSocket,
};
use embassy_stm32::dbgmcu::Dbgmcu;
use embassy_stm32::eth::lan8742a::LAN8742A;
use embassy_stm32::eth::{Ethernet, State};
use embassy_stm32::rng::Random;
@ -96,10 +95,6 @@ fn main() -> ! {
info!("Setup RCC...");
unsafe {
Dbgmcu::enable_all();
}
let p = embassy_stm32::init(config());
let rng = Random::new(p.RNG);

View File

@ -17,7 +17,6 @@ use example_common::*;
use core::str::from_utf8;
use cortex_m_rt::entry;
use embassy_stm32::dbgmcu::Dbgmcu;
use embassy_stm32::peripherals::SPI3;
use embassy_stm32::time::U32Ext;
use heapless::String;
@ -43,10 +42,6 @@ static EXECUTOR: Forever<Executor> = Forever::new();
fn main() -> ! {
info!("Hello World!");
unsafe {
Dbgmcu::enable_all();
}
let p = embassy_stm32::init(config());
let spi = spi::Spi::new(

View File

@ -16,7 +16,6 @@ use example_common::*;
use core::str::from_utf8;
use cortex_m_rt::entry;
use embassy_stm32::dbgmcu::Dbgmcu;
use embassy_stm32::peripherals::{DMA1_CH3, DMA1_CH4, SPI3};
use embassy_stm32::spi;
use heapless::String;
@ -39,10 +38,6 @@ static EXECUTOR: Forever<Executor> = Forever::new();
fn main() -> ! {
info!("Hello World!");
unsafe {
Dbgmcu::enable_all();
}
let p = embassy_stm32::init(config());
let spi = spi::Spi::new(

View File

@ -14,7 +14,6 @@ use embassy_stm32::usart::{Config, Uart};
use example_common::*;
use cortex_m_rt::entry;
use embassy_stm32::dbgmcu::Dbgmcu;
#[embassy::task]
async fn main_task() {
@ -39,10 +38,6 @@ static EXECUTOR: Forever<Executor> = Forever::new();
fn main() -> ! {
info!("Hello World!");
unsafe {
Dbgmcu::enable_all();
}
let executor = EXECUTOR.put(Executor::new());
executor.run(|spawner| {

View File

@ -9,7 +9,6 @@ mod example_common;
use core::fmt::Write;
use embassy::executor::Executor;
use embassy::util::Forever;
use embassy_stm32::dbgmcu::Dbgmcu;
use embassy_stm32::dma::NoDma;
use embassy_stm32::usart::{Config, Uart};
use embassy_traits::uart::Write as _Write;
@ -41,10 +40,6 @@ static EXECUTOR: Forever<Executor> = Forever::new();
fn main() -> ! {
info!("Hello World!");
unsafe {
Dbgmcu::enable_all();
}
let executor = EXECUTOR.put(Executor::new());
executor.run(|spawner| {

View File

@ -27,7 +27,7 @@ defmt = "0.2.0"
defmt-rtt = "0.2.0"
cortex-m = "0.7.1"
cortex-m-rt = "0.6.14"
cortex-m-rt = "0.7.0"
embedded-hal = { version = "0.2.4" }
panic-probe = { version = "0.2.0", features= ["print-defmt"] }
futures = { version = "0.3.8", default-features = false, features = ["async-await"] }

View File

@ -10,17 +10,14 @@ mod example_common;
use embassy::executor::Spawner;
use embassy::time::{Duration, Timer};
use embassy_stm32::gpio::{Level, Output, Speed};
use embassy_stm32::rcc::Rcc;
use embassy_stm32::Peripherals;
use embedded_hal::digital::v2::OutputPin;
use example_common::*;
#[embassy::main]
async fn main(_spawner: Spawner, mut p: Peripherals) {
async fn main(_spawner: Spawner, p: Peripherals) {
info!("Hello World!");
Rcc::new(p.RCC).enable_debug_wfe(&mut p.DBGMCU, true);
let mut led = Output::new(p.PB5, Level::High, Speed::Low);
loop {

View File

@ -6,22 +6,16 @@
#[path = "../example_common.rs"]
mod example_common;
use embassy_stm32::{
gpio::{Input, Level, Output, Pull, Speed},
rcc::*,
};
use embassy::executor::Spawner;
use embassy_stm32::gpio::{Input, Level, Output, Pull, Speed};
use embassy_stm32::Peripherals;
use embedded_hal::digital::v2::{InputPin, OutputPin};
use example_common::*;
use cortex_m_rt::entry;
#[entry]
fn main() -> ! {
#[embassy::main]
async fn main(_spawner: Spawner, p: Peripherals) {
info!("Hello World!");
let mut p = embassy_stm32::init(Default::default());
Rcc::new(p.RCC).enable_debug_wfe(&mut p.DBGMCU, true);
let button = Input::new(p.PB2, Pull::Up);
let mut led1 = Output::new(p.PA5, Level::High, Speed::Low);
let mut led2 = Output::new(p.PB5, Level::High, Speed::Low);

View File

@ -17,7 +17,6 @@ use example_common::*;
#[embassy::main]
async fn main(_spawner: Spawner, mut p: Peripherals) {
let mut rcc = rcc::Rcc::new(p.RCC);
rcc.enable_debug_wfe(&mut p.DBGMCU, true);
// Enables SYSCFG
let _ = rcc.enable_hsi48(&mut p.SYSCFG, p.CRS);

View File

@ -7,25 +7,21 @@
#[path = "../example_common.rs"]
mod example_common;
use embassy::executor::Spawner;
use embassy_stm32::gpio::{Level, Output, Speed};
use embedded_hal::digital::v2::OutputPin;
use example_common::*;
use cortex_m_rt::entry;
use embassy_stm32::dma::NoDma;
use embassy_stm32::rcc;
use embassy_stm32::spi::{Config, Spi};
use embassy_stm32::time::Hertz;
use embassy_stm32::Peripherals;
use embedded_hal::blocking::spi::Transfer;
#[entry]
fn main() -> ! {
#[embassy::main]
async fn main(_spawner: Spawner, p: Peripherals) {
info!("Hello World, folks!");
let mut p = embassy_stm32::init(Default::default());
let mut rcc = rcc::Rcc::new(p.RCC);
rcc.enable_debug_wfe(&mut p.DBGMCU, true);
let mut spi = Spi::new(
p.SPI1,
p.PB3,
@ -40,7 +36,7 @@ fn main() -> ! {
let mut cs = Output::new(p.PA15, Level::High, Speed::VeryHigh);
loop {
let mut buf = [0x0A; 4];
let mut buf = [0x0Au8; 4];
unwrap!(cs.set_low());
unwrap!(spi.transfer(&mut buf));
unwrap!(cs.set_high());

View File

@ -11,14 +11,11 @@ use example_common::*;
use embassy::executor::Spawner;
use embassy_stm32::usart::{Config, Uart};
use embassy_stm32::{rcc, Peripherals};
use embassy_stm32::Peripherals;
use embassy_traits::uart::{Read, Write};
#[embassy::main]
async fn main(_spawner: Spawner, mut p: Peripherals) {
let mut rcc = rcc::Rcc::new(p.RCC);
rcc.enable_debug_wfe(&mut p.DBGMCU, true);
async fn main(_spawner: Spawner, p: Peripherals) {
let mut usart = Uart::new(
p.USART1,
p.PB7,

View File

@ -15,13 +15,10 @@ use embassy::io::{AsyncBufReadExt, AsyncWriteExt};
use embassy_stm32::dma::NoDma;
use embassy_stm32::interrupt;
use embassy_stm32::usart::{BufferedUart, Config, State, Uart};
use embassy_stm32::{rcc, Peripherals};
use embassy_stm32::Peripherals;
#[embassy::main]
async fn main(_spawner: Spawner, mut p: Peripherals) {
let mut rcc = rcc::Rcc::new(p.RCC);
rcc.enable_debug_wfe(&mut p.DBGMCU, true);
async fn main(_spawner: Spawner, p: Peripherals) {
static mut TX_BUFFER: [u8; 8] = [0; 8];
static mut RX_BUFFER: [u8; 256] = [0; 256];

View File

@ -26,7 +26,7 @@ defmt = "0.2.0"
defmt-rtt = "0.2.0"
cortex-m = "0.7.1"
cortex-m-rt = "0.6.14"
cortex-m-rt = "0.7.0"
embedded-hal = { version = "0.2.4" }
panic-probe = { version = "0.2.0", features= ["print-defmt"] }
futures = { version = "0.3.8", default-features = false, features = ["async-await"] }

View File

@ -9,7 +9,6 @@ mod example_common;
use embassy::time::Delay;
use embassy_stm32::adc::{Adc, Resolution};
use embassy_stm32::dbgmcu::Dbgmcu;
use embassy_stm32::pac;
use example_common::*;
@ -18,8 +17,6 @@ fn main() -> ! {
info!("Hello World!");
unsafe {
Dbgmcu::enable_all();
pac::RCC.ccipr().modify(|w| {
w.set_adcsel(0b11);
});

View File

@ -8,7 +8,6 @@
mod example_common;
use embassy::executor::Spawner;
use embassy::time::{Duration, Timer};
use embassy_stm32::dbgmcu::Dbgmcu;
use embassy_stm32::gpio::{Level, Output, Speed};
use embassy_stm32::Peripherals;
use embedded_hal::digital::v2::OutputPin;
@ -18,10 +17,6 @@ use example_common::*;
async fn main(_spawner: Spawner, p: Peripherals) {
info!("Hello World!");
unsafe {
Dbgmcu::enable_all();
}
let mut led = Output::new(p.PB14, Level::High, Speed::Low);
loop {

View File

@ -6,7 +6,6 @@
#[path = "../example_common.rs"]
mod example_common;
use embassy_stm32::dbgmcu::Dbgmcu;
use embassy_stm32::gpio::{Input, Pull};
use embedded_hal::digital::v2::InputPin;
use example_common::*;
@ -15,10 +14,6 @@ use example_common::*;
fn main() -> ! {
info!("Hello World!");
unsafe {
Dbgmcu::enable_all();
}
let p = embassy_stm32::init(Default::default());
let button = Input::new(p.PC13, Pull::Up);

View File

@ -7,7 +7,6 @@
#[path = "../example_common.rs"]
mod example_common;
use embassy::executor::Spawner;
use embassy_stm32::dbgmcu::Dbgmcu;
use embassy_stm32::exti::ExtiInput;
use embassy_stm32::gpio::{Input, Pull};
use embassy_stm32::Peripherals;
@ -18,10 +17,6 @@ use example_common::*;
async fn main(_spawner: Spawner, p: Peripherals) {
info!("Hello World!");
unsafe {
Dbgmcu::enable_all();
}
let button = Input::new(p.PC13, Pull::Up);
let mut button = ExtiInput::new(button, p.EXTI13);

View File

@ -8,7 +8,6 @@
mod example_common;
use embassy_stm32::dac::{Channel, Dac, Value};
use embassy_stm32::dbgmcu::Dbgmcu;
use embassy_stm32::gpio::NoPin;
use embassy_stm32::pac;
use example_common::*;
@ -18,8 +17,6 @@ fn main() -> ! {
info!("Hello World!");
unsafe {
Dbgmcu::enable_all();
pac::RCC.apb1enr1().modify(|w| {
w.set_dac1en(true);
});

View File

@ -7,7 +7,6 @@
#[path = "../example_common.rs"]
mod example_common;
use embassy_stm32::dbgmcu::Dbgmcu;
use embassy_stm32::dma::NoDma;
use embassy_stm32::gpio::{Level, Output, Speed};
use embassy_stm32::spi::{Config, Spi};
@ -20,10 +19,6 @@ use example_common::*;
fn main() -> ! {
info!("Hello World!");
unsafe {
Dbgmcu::enable_all();
}
let p = embassy_stm32::init(Default::default());
let mut spi = Spi::new(

View File

@ -8,7 +8,6 @@
mod example_common;
use embassy::executor::Spawner;
use embassy_stm32::dbgmcu::Dbgmcu;
use embassy_stm32::gpio::{Input, Level, Output, Pull, Speed};
use embassy_stm32::spi::{Config, Spi};
use embassy_stm32::time::Hertz;
@ -21,10 +20,6 @@ use example_common::*;
async fn main(_spawner: Spawner, p: Peripherals) {
info!("Hello World!");
unsafe {
Dbgmcu::enable_all();
}
let mut spi = Spi::new(
p.SPI3,
p.PC10,

View File

@ -7,7 +7,6 @@
#[path = "../example_common.rs"]
mod example_common;
use embassy_stm32::dbgmcu::Dbgmcu;
use embassy_stm32::dma::NoDma;
use embassy_stm32::usart::{Config, Uart};
use embedded_hal::blocking::serial::Write;
@ -17,10 +16,6 @@ use example_common::*;
fn main() -> ! {
info!("Hello World!");
unsafe {
Dbgmcu::enable_all();
}
let p = embassy_stm32::init(Default::default());
let config = Config::default();

View File

@ -8,7 +8,6 @@
mod example_common;
use core::fmt::Write;
use embassy::executor::Spawner;
use embassy_stm32::dbgmcu::Dbgmcu;
use embassy_stm32::dma::NoDma;
use embassy_stm32::usart::{Config, Uart};
use embassy_stm32::Peripherals;
@ -20,10 +19,6 @@ use heapless::String;
async fn main(_spawner: Spawner, p: Peripherals) {
info!("Hello World!");
unsafe {
Dbgmcu::enable_all();
}
let config = Config::default();
let mut usart = Uart::new(p.UART4, p.PA1, p.PA0, p.DMA1_CH3, NoDma, config);

View File

@ -8,7 +8,6 @@
mod example_common;
use embassy::executor::Spawner;
use embassy::time::{Duration, Timer};
use embassy_stm32::dbgmcu::Dbgmcu;
use embassy_stm32::gpio::{Level, Output, Speed};
use embassy_stm32::Peripherals;
use embedded_hal::digital::v2::OutputPin;
@ -18,8 +17,6 @@ use example_common::*;
async fn main(_spawner: Spawner, p: Peripherals) {
info!("Hello World!");
unsafe { Dbgmcu::enable_all() };
let mut led = Output::new(p.PB0, Level::High, Speed::Low);
loop {

View File

@ -0,0 +1,31 @@
#![no_std]
#![no_main]
#![feature(trait_alias)]
#![feature(type_alias_impl_trait)]
#![allow(incomplete_features)]
#[path = "../example_common.rs"]
mod example_common;
use embassy::executor::Spawner;
use embassy_stm32::exti::ExtiInput;
use embassy_stm32::gpio::{Input, Pull};
use embassy_stm32::Peripherals;
use embassy_traits::gpio::{WaitForFallingEdge, WaitForRisingEdge};
use example_common::*;
#[embassy::main]
async fn main(_spawner: Spawner, p: Peripherals) {
info!("Hello World!");
let button = Input::new(p.PC4, Pull::Up);
let mut button = ExtiInput::new(button, p.EXTI4);
info!("Press the USER button...");
loop {
button.wait_for_falling_edge().await;
info!("Pressed!");
button.wait_for_rising_edge().await;
info!("Released!");
}
}

View File

@ -8,7 +8,6 @@
mod example_common;
use embassy::executor::Spawner;
use embassy::time::{Duration, Timer};
use embassy_stm32::dbgmcu::Dbgmcu;
use embassy_stm32::gpio::{Level, Output, Speed};
use embassy_stm32::Peripherals;
use embedded_hal::digital::v2::OutputPin;
@ -18,8 +17,6 @@ use example_common::*;
async fn main(_spawner: Spawner, p: Peripherals) {
info!("Hello World!");
unsafe { Dbgmcu::enable_all() };
let mut led = Output::new(p.PB15, Level::High, Speed::Low);
loop {

View File

@ -6,10 +6,7 @@
#[path = "../example_common.rs"]
mod example_common;
use embassy_stm32::{
dbgmcu::Dbgmcu,
gpio::{Input, Level, Output, Pull, Speed},
};
use embassy_stm32::gpio::{Input, Level, Output, Pull, Speed};
use embedded_hal::digital::v2::{InputPin, OutputPin};
use example_common::*;
@ -21,8 +18,6 @@ fn main() -> ! {
let p = embassy_stm32::init(Default::default());
unsafe { Dbgmcu::enable_all() };
let button = Input::new(p.PA0, Pull::Up);
let mut led1 = Output::new(p.PB15, Level::High, Speed::Low);
let mut led2 = Output::new(p.PB9, Level::High, Speed::Low);

View File

@ -7,7 +7,6 @@
#[path = "../example_common.rs"]
mod example_common;
use embassy::executor::Spawner;
use embassy_stm32::dbgmcu::Dbgmcu;
use embassy_stm32::exti::ExtiInput;
use embassy_stm32::gpio::{Input, Pull};
use embassy_stm32::Peripherals;
@ -18,8 +17,6 @@ use example_common::*;
async fn main(_spawner: Spawner, p: Peripherals) {
info!("Hello World!");
unsafe { Dbgmcu::enable_all() };
let button = Input::new(p.PA0, Pull::Up);
let mut button = ExtiInput::new(button, p.EXTI0);