led: remove

This commit is contained in:
Astro 2020-03-09 23:58:46 +01:00
parent 2f50071afa
commit 60a9c72bf0
2 changed files with 0 additions and 58 deletions

View File

@ -1,46 +0,0 @@
use embedded_hal::digital::v2::OutputPin;
use stm32f4xx_hal::gpio::{
Output, PushPull,
gpiob::{PB0, PB7, PB14},
};
type GreenPin = PB0<Output<PushPull>>;
type BluePin = PB7<Output<PushPull>>;
type RedPin = PB14<Output<PushPull>>;
pub struct Led<PIN> {
pin: PIN,
}
impl<PIN: OutputPin> Led<PIN> {
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<GreenPin> {
pub fn green(pin: GreenPin) -> Self {
Self::new(pin)
}
}
impl Led<BluePin> {
pub fn blue(pin: BluePin) -> Self {
Self::new(pin)
}
}
impl Led<RedPin> {
pub fn red(pin: RedPin) -> Self {
Self::new(pin)
}
}

View File

@ -32,8 +32,6 @@ mod net;
mod server; mod server;
use server::Server; use server::Server;
mod timer; mod timer;
mod led;
use led::Led;
/// Interval at which to sample the ADC input and broadcast to all /// Interval at which to sample the ADC input and broadcast to all
/// clients. /// clients.
@ -93,10 +91,6 @@ fn main() -> ! {
let gpioc = dp.GPIOC.split(); let gpioc = dp.GPIOC.split();
let gpiog = dp.GPIOG.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"); info!("ADC init");
let mut adc_input = AdcInput::new(dp.ADC1, gpioa.pa3); let mut adc_input = AdcInput::new(dp.ADC1, gpioa.pa3);
@ -126,21 +120,17 @@ fn main() -> ! {
loop { loop {
let now = timer::now().0; let now = timer::now().0;
let instant = Instant::from_millis(i64::from(now)); let instant = Instant::from_millis(i64::from(now));
led_blue.on();
cortex_m::interrupt::free(net::clear_pending); cortex_m::interrupt::free(net::clear_pending);
server.poll(instant) server.poll(instant)
.unwrap_or_else(|e| { .unwrap_or_else(|e| {
warn!("poll: {:?}", e); warn!("poll: {:?}", e);
}); });
led_blue.off();
let now = timer::now().0; let now = timer::now().0;
if now - last_output >= OUTPUT_INTERVAL { if now - last_output >= OUTPUT_INTERVAL {
led_red.on();
let adc_value = adc_input.read(); let adc_value = adc_input.read();
writeln!(server, "t={},pa3={}\r", now, adc_value).unwrap(); writeln!(server, "t={},pa3={}\r", now, adc_value).unwrap();
last_output = now; last_output = now;
led_red.off();
} }
// Update watchdog // Update watchdog
@ -148,10 +138,8 @@ fn main() -> ! {
cortex_m::interrupt::free(|cs| { cortex_m::interrupt::free(|cs| {
if !net::is_pending(cs) { if !net::is_pending(cs) {
led_green.on();
// Wait for interrupts // Wait for interrupts
wfi(); wfi();
led_green.off();
} }
}); });
} }