From 60a9c72bf09ffaa5fc72e6a5e0eefcc6f8827bf3 Mon Sep 17 00:00:00 2001 From: Astro Date: Mon, 9 Mar 2020 23:58:46 +0100 Subject: [PATCH] led: remove --- src/led.rs | 46 ---------------------------------------------- src/main.rs | 12 ------------ 2 files changed, 58 deletions(-) delete mode 100644 src/led.rs diff --git a/src/led.rs b/src/led.rs deleted file mode 100644 index feccba5..0000000 --- a/src/led.rs +++ /dev/null @@ -1,46 +0,0 @@ -use embedded_hal::digital::v2::OutputPin; -use stm32f4xx_hal::gpio::{ - Output, PushPull, - gpiob::{PB0, PB7, PB14}, -}; - -type GreenPin = PB0>; -type BluePin = PB7>; -type RedPin = PB14>; - -pub struct Led { - pin: PIN, -} - -impl Led { - fn new(pin: PIN) -> Self { - Led { pin } - } - - pub fn on(&mut self) { - let _ = self.pin.set_high(); - } - - pub fn off(&mut self) { - let _ = self.pin.set_low(); - } -} - - -impl Led { - pub fn green(pin: GreenPin) -> Self { - Self::new(pin) - } -} - -impl Led { - pub fn blue(pin: BluePin) -> Self { - Self::new(pin) - } -} - -impl Led { - pub fn red(pin: RedPin) -> Self { - Self::new(pin) - } -} diff --git a/src/main.rs b/src/main.rs index 0643c67..4631bab 100644 --- a/src/main.rs +++ b/src/main.rs @@ -32,8 +32,6 @@ mod net; mod server; use server::Server; mod timer; -mod led; -use led::Led; /// Interval at which to sample the ADC input and broadcast to all /// clients. @@ -93,10 +91,6 @@ fn main() -> ! { let gpioc = dp.GPIOC.split(); let gpiog = dp.GPIOG.split(); - let mut led_green = Led::green(gpiob.pb0.into_push_pull_output()); - let mut led_blue = Led::blue(gpiob.pb7.into_push_pull_output()); - let mut led_red = Led::red(gpiob.pb14.into_push_pull_output()); - info!("ADC init"); let mut adc_input = AdcInput::new(dp.ADC1, gpioa.pa3); @@ -126,21 +120,17 @@ fn main() -> ! { loop { let now = timer::now().0; let instant = Instant::from_millis(i64::from(now)); - led_blue.on(); cortex_m::interrupt::free(net::clear_pending); server.poll(instant) .unwrap_or_else(|e| { warn!("poll: {:?}", e); }); - led_blue.off(); let now = timer::now().0; if now - last_output >= OUTPUT_INTERVAL { - led_red.on(); let adc_value = adc_input.read(); writeln!(server, "t={},pa3={}\r", now, adc_value).unwrap(); last_output = now; - led_red.off(); } // Update watchdog @@ -148,10 +138,8 @@ fn main() -> ! { cortex_m::interrupt::free(|cs| { if !net::is_pending(cs) { - led_green.on(); // Wait for interrupts wfi(); - led_green.off(); } }); }