aboutsummaryrefslogtreecommitdiffstats
path: root/src/led.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/led.rs')
-rw-r--r--src/led.rs50
1 files changed, 0 insertions, 50 deletions
diff --git a/src/led.rs b/src/led.rs
deleted file mode 100644
index ba32fe0..0000000
--- a/src/led.rs
+++ /dev/null
@@ -1,50 +0,0 @@
-use stm32f1xx_hal::gpio::{gpiob::PB2, Cr, Floating, Input, Output, PushPull, CRL};
-
-enum State {
- Low,
- High,
-}
-
-type LEDPin<MODE> = PB2<MODE>;
-
-pub struct LED {
- pin: LEDPin<Output<PushPull>>,
- state: State,
-}
-
-#[allow(unused)]
-impl LED {
- pub fn new(pin: LEDPin<Input<Floating>>, cr: &mut Cr<CRL, 'B'>) -> Self {
- let mut p = pin.into_push_pull_output(cr);
- p.set_low();
- Self {
- pin: p,
- state: State::Low,
- }
- }
-
- pub fn is_on(&self) -> bool {
- match self.state {
- State::High => true,
- State::Low => false,
- }
- }
-
- pub fn on(&mut self) {
- self.state = State::High;
- self.pin.set_high();
- }
-
- pub fn off(&mut self) {
- self.state = State::Low;
- self.pin.set_low();
- }
-
- pub fn toggle(&mut self) {
- if self.is_on() {
- self.off();
- } else {
- self.on();
- }
- }
-}