aboutsummaryrefslogtreecommitdiffstats
path: root/src/blink.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/blink.rs')
-rw-r--r--src/blink.rs15
1 files changed, 9 insertions, 6 deletions
diff --git a/src/blink.rs b/src/blink.rs
index 7c992d7..8e17b21 100644
--- a/src/blink.rs
+++ b/src/blink.rs
@@ -1,13 +1,16 @@
-use crate::{PollResult, led::LED};
-
use gd32vf103xx_hal::prelude::_embedded_hal_timer_CountDown;
+use core::convert::Infallible;
+
use gd32vf103xx_hal::{
eclic::{self, EclicExt},
pac::{self, Interrupt},
time::Hertz,
timer,
};
+use nb;
+
+use crate::led::LED;
enum State {
WaitForTimer,
@@ -33,21 +36,21 @@ impl Task {
Self { timer, frequency, led, state: State::ToggleLED }
}
- pub fn poll(&mut self) -> PollResult {
+ pub fn poll(&mut self) -> nb::Result<(), Infallible> {
match self.state {
State::WaitForTimer => {
if let Ok(_) = self.timer.wait() {
self.state = State::ToggleLED;
- PollResult::Ok
+ Ok(())
} else {
- PollResult::WouldBlock
+ Err(nb::Error::WouldBlock)
}
},
State::ToggleLED => {
self.led.toggle();
self.timer.start(self.frequency);
self.state = State::WaitForTimer;
- PollResult::WouldBlock
+ Err(nb::Error::WouldBlock)
}
}
}