Skip to content

Commit

Permalink
cargo fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
jannic committed Sep 5, 2022
1 parent c007bdb commit 1190f01
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 36 deletions.
13 changes: 7 additions & 6 deletions boards/rp-pico-w/examples/pico_w_blinky.rs
Original file line number Diff line number Diff line change
Expand Up @@ -120,21 +120,20 @@ async fn run(spawner: Spawner, pins: rp_pico_w::Pins, state: &'static cyw43::Sta

let pwr = pins.wl_on.into_push_pull_output();

#[cfg(not(feature="fix_fw"))]
#[cfg(not(feature = "fix_fw"))]
let fw = include_bytes!("firmware/43439A0.bin");
#[cfg(not(feature="fix_fw"))]
#[cfg(not(feature = "fix_fw"))]
let clm = include_bytes!("firmware/43439A0_clm.bin");

// To make flashing faster for development, you may want to flash the firmwares independently
// at hardcoded addresses, instead of baking them into the program with `include_bytes!`:
// probe-rs-cli download 43439A0.bin --format bin --chip RP2040 --base-address 0x10100000
// probe-rs-cli download 43439A0.clm_blob --format bin --chip RP2040 --base-address 0x10140000
#[cfg(feature="fix_fw")]
#[cfg(feature = "fix_fw")]
let fw = unsafe { core::slice::from_raw_parts(0x10100000 as *const u8, 224190) };
#[cfg(feature="fix_fw")]
#[cfg(feature = "fix_fw")]
let clm = unsafe { core::slice::from_raw_parts(0x10140000 as *const u8, 4752) };


use embassy_futures::yield_now;
yield_now().await;

Expand All @@ -151,7 +150,9 @@ async fn run(spawner: Spawner, pins: rp_pico_w::Pins, state: &'static cyw43::Sta
info!("init net net device done");

if option_env!("WIFI_PASSWORD").is_some() {
control.join_wpa2(env!("WIFI_NETWORK"), option_env!("WIFI_PASSWORD").unwrap()).await;
control
.join_wpa2(env!("WIFI_NETWORK"), option_env!("WIFI_PASSWORD").unwrap())
.await;
} else {
control.join_open(env!("WIFI_NETWORK")).await;
}
Expand Down
60 changes: 30 additions & 30 deletions boards/rp-pico-w/src/embassy_time_driver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ use rp2040_hal::pac;
use rp2040_hal::pac::interrupt;
use rp2040_hal::timer::Alarm;
use rp2040_hal::timer::Alarm0;
use rp2040_hal::timer::Timer;
use rp2040_hal::timer::ScheduleAlarmError;
use rp2040_hal::timer::Instant;
use rp2040_hal::timer::ScheduleAlarmError;
use rp2040_hal::timer::Timer;

use defmt::*;

Expand Down Expand Up @@ -132,33 +132,35 @@ impl TimerDriver {
.as_mut()
.unwrap()
.schedule_at(min_timestamp)
{
Result::Err(ScheduleAlarmError::AlarmTooSoon)
=> {
// If alarm timestamp has passed, trigger it instantly.
// This disarms it.
trace!("timestamp has passed, trigger now! timestamp {} <= now {}", min_timestamp.ticks(), now.ticks());
self.trigger_alarm(n, cs);
},
Result::Err(ScheduleAlarmError::AlarmTooLate)
=> {
// Duration >72 minutes. Reschedule 1 hour later.
trace!("reschedule in 1h");
self
.alarm
.borrow(cs)
.borrow_mut()
.deref_mut()
.as_mut()
.unwrap()
.schedule(MicrosDurationU32::hours(1)).unwrap();
},
Ok(_) => {
trace!("min: {}, now: {}", min_timestamp.ticks(), now.ticks());
trace!("alarm armed for {}", (min_timestamp - now).ticks());
},
Err(_) => core::panic!("Unknown error scheduling an alarm"),
{
Result::Err(ScheduleAlarmError::AlarmTooSoon) => {
// If alarm timestamp has passed, trigger it instantly.
// This disarms it.
trace!(
"timestamp has passed, trigger now! timestamp {} <= now {}",
min_timestamp.ticks(),
now.ticks()
);
self.trigger_alarm(n, cs);
}
Result::Err(ScheduleAlarmError::AlarmTooLate) => {
// Duration >72 minutes. Reschedule 1 hour later.
trace!("reschedule in 1h");
self.alarm
.borrow(cs)
.borrow_mut()
.deref_mut()
.as_mut()
.unwrap()
.schedule(MicrosDurationU32::hours(1))
.unwrap();
}
Ok(_) => {
trace!("min: {}, now: {}", min_timestamp.ticks(), now.ticks());
trace!("alarm armed for {}", (min_timestamp - now).ticks());
}
Err(_) => core::panic!("Unknown error scheduling an alarm"),
}
}

fn check_alarm(&self) {
Expand Down Expand Up @@ -236,12 +238,10 @@ pub unsafe fn init(mut timer: Timer) {
a.timestamp.set(NO_ALARM);
}
});

}

#[interrupt]
unsafe fn TIMER_IRQ_0() {
trace!("Interrupt!");
DRIVER.check_alarm()
}

0 comments on commit 1190f01

Please sign in to comment.