aboutsummaryrefslogtreecommitdiffstats
path: root/src/blink.rs
diff options
context:
space:
mode:
authorBrian Cully <bjc@kublai.com>2022-08-08 15:05:31 -0400
committerBrian Cully <bjc@kublai.com>2022-08-08 15:05:31 -0400
commit8c1cb71bbe54301b711519267d40bf854f6fcf1f (patch)
tree7e912bd78631aba9d9ca6e66ada804dc9f402f5a /src/blink.rs
parent6afea5e58e47b345adaa0f556184f75599503521 (diff)
downloadluchie-8c1cb71bbe54301b711519267d40bf854f6fcf1f.tar.gz
luchie-8c1cb71bbe54301b711519267d40bf854f6fcf1f.zip
use ‘nb’ crate instead of custom type
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)
}
}
}