aboutsummaryrefslogtreecommitdiffstats
path: root/src/blink.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/blink.rs')
-rw-r--r--src/blink.rs10
1 files changed, 6 insertions, 4 deletions
diff --git a/src/blink.rs b/src/blink.rs
index 8e17b21..bb53845 100644
--- a/src/blink.rs
+++ b/src/blink.rs
@@ -6,7 +6,7 @@ use gd32vf103xx_hal::{
eclic::{self, EclicExt},
pac::{self, Interrupt},
time::Hertz,
- timer,
+ timer::{Event, Timer},
};
use nb;
@@ -18,20 +18,20 @@ enum State {
}
pub struct Task {
- timer: timer::Timer<pac::TIMER6>,
+ timer: Timer<pac::TIMER6>,
frequency: Hertz,
led: LED,
state: State,
}
impl Task {
- pub fn new(mut timer: timer::Timer<pac::TIMER6>, frequency: Hertz, led: LED) -> Self {
+ pub fn new(mut timer: Timer<pac::TIMER6>, frequency: Hertz, led: LED) -> Self {
pac::ECLIC::setup(Interrupt::TIMER6, eclic::TriggerType::RisingEdge, eclic::Level::L0, eclic::Priority::P3);
unsafe { pac::ECLIC::unmask(Interrupt::TIMER6); }
if !pac::ECLIC::is_enabled(Interrupt::TIMER6) {
panic!("timer6 interrupt not enabled");
}
- timer.listen(timer::Event::Update);
+ timer.listen(Event::Update);
Self { timer, frequency, led, state: State::ToggleLED }
}
@@ -41,6 +41,7 @@ impl Task {
State::WaitForTimer => {
if let Ok(_) = self.timer.wait() {
self.state = State::ToggleLED;
+ // self.timer.unlisten(Event::Update);
Ok(())
} else {
Err(nb::Error::WouldBlock)
@@ -50,6 +51,7 @@ impl Task {
self.led.toggle();
self.timer.start(self.frequency);
self.state = State::WaitForTimer;
+ // self.timer.listen(Event::Update);
Err(nb::Error::WouldBlock)
}
}