Skip to content

Commit

Permalink
Fix examples
Browse files Browse the repository at this point in the history
  • Loading branch information
9names committed Aug 6, 2023
1 parent 360c060 commit 4ce1741
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 20 deletions.
8 changes: 4 additions & 4 deletions examples/blinky.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
#![no_main]

use bl602_hal as hal;
use embedded_hal::delay::blocking::DelayMs;
use embedded_hal::digital::blocking::OutputPin;
use embedded_hal::delay::DelayUs;
use embedded_hal::digital::OutputPin;
use hal::{
clock::{Strict, SysclkFreq, UART_PLL_FREQ},
pac,
Expand All @@ -30,9 +30,9 @@ fn main() -> ! {

loop {
gpio5.set_high().unwrap();
d.delay_ms(1000).unwrap();
d.delay_ms(1000);

gpio5.set_low().unwrap();
d.delay_ms(1000).unwrap();
d.delay_ms(1000);
}
}
4 changes: 2 additions & 2 deletions examples/led_interrupt_switch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@

use bl602_hal as hal;
use core::mem::MaybeUninit;
use embedded_hal::digital::blocking::OutputPin;
use embedded_hal::digital::blocking::StatefulOutputPin;
use embedded_hal::digital::OutputPin;
use embedded_hal::digital::StatefulOutputPin;
use hal::{interrupts::*, pac, prelude::*};
use panic_halt as _;

Expand Down
6 changes: 3 additions & 3 deletions examples/led_timer_interrupt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ use bl602_hal as hal;
use core::cell::RefCell;
use core::ops::DerefMut;
use critical_section::{self, Mutex};
use embedded_hal::digital::blocking::{OutputPin, ToggleableOutputPin};
use embedded_hal::timer::nb::CountDown;
use embedded_hal::digital::{OutputPin, ToggleableOutputPin};
use embedded_hal_zero::timer::CountDown;
use embedded_time::{duration::*, rate::*};
use hal::{
clock::{Strict, SysclkFreq},
Expand Down Expand Up @@ -107,7 +107,7 @@ fn main() -> ! {
// a timer without needing to configure any match values or handle any interrupts:
loop {
// Start the timer's CountDown functionality. The countdown will last 3000ms.
timer_ch1.start(3_000u32.milliseconds()).ok();
timer_ch1.start(3_000u32.milliseconds());
// The .wait() function returns an error until the timer has finished counting down.
while timer_ch1.wait().is_err() {
// Stay in the while loop until the timer is done.
Expand Down
4 changes: 2 additions & 2 deletions examples/serial.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

use bl602_hal as hal;
use core::fmt::Write;
use embedded_hal::delay::blocking::DelayMs;
use embedded_hal::delay::DelayUs;
use hal::{
clock::{Strict, SysclkFreq, UART_PLL_FREQ},
pac,
Expand Down Expand Up @@ -44,6 +44,6 @@ fn main() -> ! {

loop {
serial.write_str("Hello Rust\r\n").ok();
d.delay_ms(1000).unwrap();
d.delay_ms(1000);
}
}
18 changes: 9 additions & 9 deletions examples/watchdog_example.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ use core::cell::RefCell;
use core::fmt::Write;
use core::ops::DerefMut;
use critical_section::{self, Mutex};
use embedded_hal::delay::blocking::DelayMs;
use embedded_hal::digital::blocking::{OutputPin, ToggleableOutputPin};
use embedded_hal::watchdog::blocking::{Enable, Watchdog};
use embedded_hal::delay::DelayUs;
use embedded_hal::digital::{OutputPin, ToggleableOutputPin};
use embedded_hal_zero::watchdog::{Watchdog, WatchdogEnable};
use embedded_time::{duration::*, rate::*};
use hal::{
clock::{Strict, SysclkFreq, UART_PLL_FREQ},
Expand Down Expand Up @@ -86,7 +86,7 @@ fn main() -> ! {

// Set up the watchdog timer to the slowest tick rate possible:
let timers = dp.TIMER.split();
let watchdog = timers
let mut watchdog = timers
.watchdog
.set_clock_source(WdtClockSource::Rc32Khz, 125.Hz());

Expand All @@ -112,7 +112,7 @@ fn main() -> ! {

// The watchdog timer doesn't begin counting ticks until it is started. We don't need to handle
// the error state, since the watchdog start function will never actually return an Err().
let watchdog = watchdog.start(10_u32.seconds()).unwrap();
watchdog.start(10_u32.seconds());

// Move the references to their UnsafeCells once initialized, and before interrupts are enabled:
critical_section::with(|cs| G_INTERRUPT_LED_PIN_R.borrow(cs).replace(Some(r_led_pin)));
Expand All @@ -126,10 +126,10 @@ fn main() -> ! {
// In order to use the watchdog once it has been moved into the RefCell, you must call free():
critical_section::with(|cs| {
if let Some(watchdog) = G_LED_TIMER.borrow(cs).borrow_mut().deref_mut() {
watchdog.feed().ok();
watchdog.feed();
}
});
d.delay_ms(20_000).ok();
d.delay_ms(20_000);
}
}

Expand All @@ -145,14 +145,14 @@ fn Watchdog(_: &mut TrapFrame) {
critical_section::with(|cs| {
if let Some(watchdog) = G_LED_TIMER.borrow(cs).borrow_mut().deref_mut() {
watchdog.clear_interrupt();
watchdog.feed().ok();
watchdog.feed();
}
});

// Toggle the red led whenever the interrupt is triggered:
critical_section::with(|cs| {
if let Some(led_pin) = G_INTERRUPT_LED_PIN_R.borrow(cs).borrow_mut().deref_mut() {
led_pin.toggle().ok();
led_pin.toggle();
}
});

Expand Down

0 comments on commit 4ce1741

Please sign in to comment.