Skip to content

Instantly share code, notes, and snippets.

@bobmcwhirter
Created November 30, 2021 16:31
Show Gist options
  • Save bobmcwhirter/342ebbf9e72523c36565b58cbbf308bb to your computer and use it in GitHub Desktop.
Save bobmcwhirter/342ebbf9e72523c36565b58cbbf308bb to your computer and use it in GitHub Desktop.
#![no_std]
#![no_main]
#![feature(trait_alias)]
#![feature(type_alias_impl_trait)]
#![allow(incomplete_features)]
#![feature(generic_associated_types)]
use bsp_blinky_app::{boot, App, BlinkyApp, Board, BlinkyDevice};
use bsp_blinky_app::{BlinkyBoard, BlinkyComponents};
use core::borrow::BorrowMut;
use drogue_device::DeviceContext;
use embassy_stm32::dbgmcu::Dbgmcu;
use embassy_stm32::exti::ExtiInput;
use embassy_stm32::gpio::{Input, Level, Output, Pull, Speed};
use embassy_stm32::Peripherals;
use defmt_rtt as _;
use drogue_device::drivers::led::{ActiveLow, Led};
use embassy::util::Forever;
use panic_probe as _;
use embassy_stm32::peripherals::{PC13, PE13, PH6, PH7};
struct Iot02a {
peripherals: Option<Peripherals>,
}
impl Iot02a {
fn new(p: Peripherals) -> Self {
Self {
peripherals: Some(p),
}
}
}
impl Board for Iot02a {}
impl BlinkyBoard for Iot02a {
type RedLed = Led<Output<'static, PH6>, ActiveLow>;
type ControlButton = ExtiInput<'static, PC13>;
fn components(&mut self) -> BlinkyComponents<Self> {
let p = self.peripherals.take().unwrap();
let button = Input::new(p.PC13, Pull::Down);
let button = ExtiInput::new(button, p.EXTI13);
BlinkyComponents {
red_led: Led::new(Output::new(p.PH6, Level::High, Speed::Low)),
control_button: button,
}
}
}
static DEVICE: DeviceContext<BlinkyDevice<Iot02a>> = DeviceContext::new();
#[embassy::main]
async fn main(spawner: embassy::executor::Spawner, p: Peripherals) {
unsafe {
Dbgmcu::enable_all();
}
boot::<BlinkyApp<_>, _, _>(&DEVICE, Iot02a::new(p), spawner).await;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment