From 0c4eb964b015961e3c90e45ef498f6c7f89eddba Mon Sep 17 00:00:00 2001 From: Brian Cully Date: Tue, 25 Oct 2022 12:20:32 -0400 Subject: convert to gd32f303 (stm32f103) bluepill variant --- src/led.rs | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) (limited to 'src/led.rs') diff --git a/src/led.rs b/src/led.rs index 536121b..788ec81 100644 --- a/src/led.rs +++ b/src/led.rs @@ -1,17 +1,23 @@ -use gd32vf103xx_hal::{ - gpio::{Floating, Input, Output, PushPull, Pxx, State, gpioa::PA7}, +use stm32f1xx_hal::{ + gpio::{Cr, CRL, Floating, Input, Output, PushPull, gpiob::PB2}, }; -use embedded_hal::digital::v2::OutputPin; + +enum State { + Low, + High, +} + +type LEDPin = PB2; pub struct LED { - pin: Pxx>, + pin: LEDPin>, state: State, } impl LED { - pub fn new(pin: PA7>) -> Self { - let mut p = pin.into_push_pull_output().downgrade(); - p.set_low().ok(); + pub fn new(pin: LEDPin>, cr: &mut Cr) -> Self { + let mut p = pin.into_push_pull_output(cr); + p.set_low(); Self { pin: p, state: State::Low } } @@ -24,12 +30,12 @@ impl LED { pub fn on(&mut self) { self.state = State::High; - self.pin.set_high().ok(); + self.pin.set_high(); } pub fn off(&mut self) { self.state = State::Low; - self.pin.set_low().ok(); + self.pin.set_low(); } pub fn toggle(&mut self) { -- cgit v1.2.3