mirror of
https://github.com/rtic-rs/rtic.git
synced 2024-11-27 14:04:56 +01:00
8c23e178f3
* Rework timer_queue and monotonic architecture Goals: * make Monotonic purely internal * make Monotonic purely tick passed, no fugit involved * create a wrapper struct in the user's code via a macro that then converts the "now" from the tick based monotonic to a fugit based timestamp We need to proxy the delay functions of the timer queue anyway, so we could simply perform the conversion in those proxy functions. * Update cargo.lock * Update readme of rtic-time * CI: ESP32: Redact esp_image: Too volatile * Fixup: Changelog double entry rebase mistake --------- Co-authored-by: Henrik Tjäder <henrik@tjaders.com>
60 lines
1.4 KiB
Rust
60 lines
1.4 KiB
Rust
#![deny(unsafe_code)]
|
|
#![deny(warnings)]
|
|
#![no_main]
|
|
#![no_std]
|
|
|
|
use embassy_stm32::gpio::{Level, Output, Speed};
|
|
use rtic::app;
|
|
use rtic_monotonics::systick::prelude::*;
|
|
use {defmt_rtt as _, panic_probe as _};
|
|
|
|
systick_monotonic!(Mono, 1_000);
|
|
|
|
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
|
|
Mono::start(cx.core.SYST, 25_000_000);
|
|
|
|
let p = embassy_stm32::init(Default::default());
|
|
defmt::info!("Hello World!");
|
|
|
|
let mut led = Output::new(p.PC6, Level::High, Speed::Low);
|
|
defmt::info!("high");
|
|
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 {
|
|
defmt::info!("blink");
|
|
if state {
|
|
led.set_high();
|
|
} else {
|
|
led.set_low();
|
|
}
|
|
state = !state;
|
|
Mono::delay(1000.millis()).await;
|
|
}
|
|
}
|
|
}
|