aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBrian Cully <bjc@kublai.com>2022-10-28 16:31:22 -0400
committerBrian Cully <bjc@kublai.com>2022-10-28 16:31:22 -0400
commita9808211aeb98545d431a18e4a2fa8e3b2bd8218 (patch)
tree0c04a83ba17a9b6107ef47dabd251e9c8fdc62c3
parentfc890e991ed960c0f2f052f2664fc07a005f4ed3 (diff)
downloadluchie-a9808211aeb98545d431a18e4a2fa8e3b2bd8218.tar.gz
luchie-a9808211aeb98545d431a18e4a2fa8e3b2bd8218.zip
led: remove module, it's unnecessary
-rw-r--r--src/led.rs50
-rwxr-xr-xsrc/main.rs10
2 files changed, 4 insertions, 56 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();
- }
- }
-}
diff --git a/src/main.rs b/src/main.rs
index 1697001..8c2bac1 100755
--- a/src/main.rs
+++ b/src/main.rs
@@ -4,11 +4,9 @@
//extern crate panic_semihosting;
mod cirque;
-mod led;
mod log;
use cirque::Cirque;
-use led::LED;
use cortex_m::{
asm::{bkpt, wfi},
@@ -43,7 +41,8 @@ fn main() -> ! {
assert!(clocks.usbclk_valid());
let mut gpiob = dp.GPIOB.split();
- let mut led = LED::new(gpiob.pb2, &mut gpiob.crl);
+ let mut led = gpiob.pb2.into_push_pull_output(&mut gpiob.crl);
+ led.set_low();
let mut afio = dp.AFIO.constrain();
let mut gpioa = dp.GPIOA.split();
@@ -141,7 +140,7 @@ fn main() -> ! {
match serial.read(&mut buf) {
Ok(count) if count > 0 => {
- led.on();
+ led.set_high();
// Echo back in upper case
for c in buf[0..count].iter_mut() {
@@ -159,11 +158,10 @@ fn main() -> ! {
_ => {}
}
}
+ led.set_low();
}
_ => {}
}
-
- led.off();
}
}