mirror of
https://github.com/rtic-rs/rtic.git
synced 2024-11-29 15:04:32 +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.2 KiB
Rust
60 lines
1.2 KiB
Rust
#![deny(unsafe_code)]
|
|
#![deny(warnings)]
|
|
#![no_main]
|
|
#![no_std]
|
|
|
|
#[panic_handler]
|
|
fn panic(_: &::core::panic::PanicInfo) -> ! {
|
|
::teensy4_panic::sos()
|
|
}
|
|
|
|
use teensy4_bsp::{board, hal};
|
|
|
|
use rtic_monotonics::imxrt::prelude::*;
|
|
imxrt_gpt1_monotonic!(Mono, board::PERCLK_FREQUENCY);
|
|
|
|
#[rtic::app(device = teensy4_bsp, dispatchers = [LPSPI1])]
|
|
mod app {
|
|
use super::*;
|
|
|
|
#[shared]
|
|
struct Shared {}
|
|
|
|
#[local]
|
|
struct Local {
|
|
led: board::Led,
|
|
}
|
|
|
|
#[init]
|
|
fn init(cx: init::Context) -> (Shared, Local) {
|
|
let board::Resources {
|
|
pins,
|
|
mut gpio2,
|
|
mut gpt1,
|
|
..
|
|
} = board::t40(cx.device);
|
|
|
|
// Initialize Monotonic
|
|
gpt1.set_clock_source(hal::gpt::ClockSource::PeripheralClock);
|
|
Mono::start(gpt1.release());
|
|
|
|
// Setup LED
|
|
let led = board::led(&mut gpio2, pins.p13);
|
|
led.set();
|
|
|
|
// Schedule the blinking task
|
|
blink::spawn().ok();
|
|
|
|
(Shared {}, Local { led })
|
|
}
|
|
|
|
#[task(local = [led])]
|
|
async fn blink(cx: blink::Context) {
|
|
let blink::LocalResources { led, .. } = cx.local;
|
|
|
|
loop {
|
|
led.toggle();
|
|
Mono::delay(1000.millis()).await;
|
|
}
|
|
}
|
|
}
|