Skip to content

Commit

Permalink
Add RTIC example with late resources
Browse files Browse the repository at this point in the history
As proposed by Mitch in #64. As of this commit, the Teensy CLI loader
does not reject the *.hex file. See the previous commit for details.
  • Loading branch information
mciantyre committed Jun 29, 2020
1 parent 6f3fa5c commit 31b140c
Showing 1 changed file with 13 additions and 23 deletions.
36 changes: 13 additions & 23 deletions examples/rtic_led.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,38 +11,28 @@
#![no_std]
#![no_main]

extern crate panic_halt;

use embedded_hal::digital::v2::OutputPin;
use embedded_hal::digital::v2::ToggleableOutputPin;
use panic_halt as _;
use teensy4_bsp as bsp;

#[rtic::app(device = teensy4_bsp, peripherals = true, monotonic = rtic::cyccnt::CYCCNT)]
#[rtic::app(device = teensy4_bsp, peripherals = true)]
const APP: () = {
#[init(schedule = [dummy])]
fn init(cx: init::Context) {
// Cortex-M peripherals
let _core = cx.core;

// Device-specific peripherals
let mut device: bsp::Peripherals = cx.device;

let mut led = bsp::configure_led(&mut device.gpr, device.pins.p13);
led.set_high().unwrap();
struct Resources {
led: bsp::LED,
}

#[task]
fn dummy(_: dummy::Context) {

#[init]
fn init(mut cx: init::Context) -> init::LateResources {
// Prepare the LED.
let led = bsp::configure_led(&mut cx.device.gpr, cx.device.pins.p13);
init::LateResources { led }
}

#[idle]
fn idle(_: idle::Context) -> ! {
#[idle(resources = [led])]
fn idle(cx: idle::Context) -> ! {
cx.resources.led.toggle().unwrap();
loop {
core::sync::atomic::spin_loop_hint();
}
}

extern "C" {
fn LPUART8();
}
};

0 comments on commit 31b140c

Please # to comment.