aboutsummaryrefslogtreecommitdiffstats
path: root/src/blink.rs
diff options
context:
space:
mode:
authorBrian Cully <bjc@kublai.com>2022-08-11 13:40:04 -0400
committerBrian Cully <bjc@kublai.com>2022-08-11 13:40:04 -0400
commit7846e30a25dfbbb2794035894d4b9e5c0f1ef41d (patch)
tree9ad8ee61fdcccd6200396d4f9164b4ad4d823d69 /src/blink.rs
parent8c1cb71bbe54301b711519267d40bf854f6fcf1f (diff)
downloadluchie-7846e30a25dfbbb2794035894d4b9e5c0f1ef41d.tar.gz
luchie-7846e30a25dfbbb2794035894d4b9e5c0f1ef41d.zip
usb peripheral now starting ‘connect()’
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)
}
}