Skip to content

Commit

Permalink
Update blinky RTIC example to work with latest BSP changes
Browse files Browse the repository at this point in the history
  • Loading branch information
johngigantic committed Sep 13, 2023
1 parent 3acd71d commit 53b2ae0
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions boards/arduino_mkrzero/examples/blinky_rtic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,15 @@ use arduino_mkrzero as bsp;
use panic_halt as _;
#[cfg(feature = "use_semihosting")]
use panic_semihosting as _;
use rtic;
use rtic::app;

#[rtic::app(device = bsp::pac, peripherals = true, dispatchers = [EVSYS])]
#[app(device = bsp::pac, peripherals = true, dispatchers = [EVSYS])]
mod app {
use super::*;
use bsp::hal;
use hal::clock::{ClockGenId, ClockSource, GenericClockController};
use hal::gpio::{v2::PB08, Output, Pin, PushPull};
use hal::pac::Peripherals;
use hal::prelude::*;
use hal::rtc::{Count32Mode, Duration, Rtc};

#[local]
Expand All @@ -29,7 +29,7 @@ mod app {
struct Shared {
// The LED could be a local resource, since it is only used in one task
// But we want to showcase shared resources and locking
led: Pin<PB08, Output<PushPull>>,
led: bsp::pins::Led,
}

#[monotonic(binds = RTC, default = true)]
Expand All @@ -38,7 +38,7 @@ mod app {
#[init]
fn init(cx: init::Context) -> (Shared, Local, init::Monotonics) {
let mut peripherals: Peripherals = cx.device;
let mut pins = bsp::Pins::new(peripherals.PORT);
let pins = bsp::pins::Pins::new(peripherals.PORT);
let mut core: rtic::export::Peripherals = cx.core;
let mut clocks = GenericClockController::with_external_32kosc(
peripherals.GCLK,
Expand All @@ -53,7 +53,7 @@ mod app {
clocks.configure_standby(ClockGenId::GCLK2, true);
let rtc_clock = clocks.rtc(&rtc_clock_src).unwrap();
let rtc = Rtc::count32_mode(peripherals.RTC, rtc_clock.freq(), &mut peripherals.PM);
let led = pins.led_builtin.into_open_drain_output(&mut pins.port);
let led = bsp::pin_alias!(pins.led).into();

// We can use the RTC in standby for maximum power savings
core.SCB.set_sleepdeep();
Expand All @@ -67,7 +67,7 @@ mod app {
#[task(shared = [led])]
fn blink(mut cx: blink::Context) {
// If the LED were a local resource, the lock would not be necessary
cx.shared.led.lock(|led| led.toggle());
let _ = cx.shared.led.lock(|led| led.toggle());
blink::spawn_after(Duration::secs(3)).ok();
}
}

0 comments on commit 53b2ae0

Please sign in to comment.