2024-02-27 12:25:07 +01:00
|
|
|
#![deny(unsafe_code)]
|
|
|
|
#![deny(warnings)]
|
|
|
|
#![no_main]
|
|
|
|
#![no_std]
|
|
|
|
|
|
|
|
use embassy_stm32::gpio::{Level, Output, Speed};
|
|
|
|
use rtic::app;
|
2024-04-11 00:00:38 +02:00
|
|
|
use rtic_monotonics::systick::prelude::*;
|
2024-02-27 12:25:07 +01:00
|
|
|
use {defmt_rtt as _, panic_probe as _};
|
|
|
|
|
2024-04-11 00:00:38 +02:00
|
|
|
systick_monotonic!(Mono, 1_000);
|
|
|
|
|
2024-02-27 12:25:07 +01:00
|
|
|
pub mod pac {
|
|
|
|
pub use embassy_stm32::pac::Interrupt as interrupt;
|
|
|
|
pub use embassy_stm32::pac::*;
|
|
|
|
}
|
|
|
|
|
|
|
|
#[app(device = pac, peripherals = false, dispatchers = [SPI1])]
|
|
|
|
mod app {
|
|
|
|
use super::*;
|
|
|
|
|
|
|
|
#[shared]
|
|
|
|
struct Shared {}
|
|
|
|
|
|
|
|
#[local]
|
|
|
|
struct Local {}
|
|
|
|
|
|
|
|
#[init]
|
|
|
|
fn init(cx: init::Context) -> (Shared, Local) {
|
|
|
|
// Initialize the systick interrupt & obtain the token to prove that we did
|
2024-04-11 00:00:38 +02:00
|
|
|
Mono::start(cx.core.SYST, 25_000_000);
|
2024-02-27 12:25:07 +01:00
|
|
|
|
|
|
|
let p = embassy_stm32::init(Default::default());
|
2024-02-27 13:34:02 +01:00
|
|
|
defmt::info!("Hello World!");
|
2024-02-27 12:25:07 +01:00
|
|
|
|
|
|
|
let mut led = Output::new(p.PC6, Level::High, Speed::Low);
|
2024-02-27 13:34:02 +01:00
|
|
|
defmt::info!("high");
|
2024-02-27 12:25:07 +01:00
|
|
|
led.set_high();
|
|
|
|
|
|
|
|
// Schedule the blinking task
|
|
|
|
blink::spawn(led).ok();
|
|
|
|
|
|
|
|
(Shared {}, Local {})
|
|
|
|
}
|
|
|
|
|
|
|
|
#[task()]
|
|
|
|
async fn blink(_cx: blink::Context, mut led: Output<'static, embassy_stm32::peripherals::PC6>) {
|
|
|
|
let mut state = true;
|
|
|
|
loop {
|
2024-02-27 13:34:02 +01:00
|
|
|
defmt::info!("blink");
|
2024-02-27 12:25:07 +01:00
|
|
|
if state {
|
|
|
|
led.set_high();
|
|
|
|
} else {
|
|
|
|
led.set_low();
|
|
|
|
}
|
|
|
|
state = !state;
|
2024-04-11 00:00:38 +02:00
|
|
|
Mono::delay(1000.millis()).await;
|
2024-02-27 12:25:07 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|