diff --git a/Cargo.toml b/Cargo.toml index 63c9962..f099c99 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "vorago-reb1" -version = "0.1.0" +version = "0.1.1" authors = ["Robin Mueller "] edition = "2021" description = "Board Support Crate for the Vorago REB1 development board" @@ -20,5 +20,5 @@ panic-rtt-target = { version = "0.1", features = ["cortex-m"] } rtt-target = { version = "0.3", features = ["cortex-m"] } [dependencies.va108xx-hal] -version = "0.1" +version = "0.2" features = ["rt"] diff --git a/examples/blinky-leds.rs b/examples/blinky-leds.rs index dfb40be..add25fe 100644 --- a/examples/blinky-leds.rs +++ b/examples/blinky-leds.rs @@ -9,7 +9,7 @@ use cortex_m_rt::entry; use embedded_hal::digital::v2::ToggleableOutputPin; use panic_halt as _; -use va108xx_hal::{pac, prelude::*}; +use va108xx_hal::{gpio::pins::PinsA, pac, prelude::*}; use vorago_reb1::leds::Leds; // REB LED pin definitions. All on port A @@ -27,7 +27,7 @@ enum LibType { #[entry] fn main() -> ! { let mut dp = pac::Peripherals::take().unwrap(); - let porta = dp.PORTA.split(&mut dp.SYSCONFIG).unwrap(); + let lib_type = LibType::Bsp; match lib_type { @@ -60,15 +60,10 @@ fn main() -> ! { } } LibType::Hal => { - let mut led1 = porta - .pa10 - .into_push_pull_output(&mut dp.IOCONFIG, &mut dp.PORTA); - let mut led2 = porta - .pa7 - .into_push_pull_output(&mut dp.IOCONFIG, &mut dp.PORTA); - let mut led3 = porta - .pa6 - .into_push_pull_output(&mut dp.IOCONFIG, &mut dp.PORTA); + let pins = PinsA::new(&mut dp.SYSCONFIG, Some(dp.IOCONFIG), dp.PORTA); + let mut led1 = pins.pa10.into_push_pull_output(); + let mut led2 = pins.pa7.into_push_pull_output(); + let mut led3 = pins.pa6.into_push_pull_output(); for _ in 0..10 { led1.set_low().ok(); led2.set_low().ok(); @@ -89,7 +84,7 @@ fn main() -> ! { } } LibType::Bsp => { - let mut leds = Leds::new(porta, &mut dp.IOCONFIG, &mut dp.PORTA); + let mut leds = Leds::new(PinsA::new(&mut dp.SYSCONFIG, Some(dp.IOCONFIG), dp.PORTA)); loop { for _ in 0..10 { // Blink all LEDs quickly diff --git a/src/leds.rs b/src/leds.rs index 75be733..fe04e2b 100644 --- a/src/leds.rs +++ b/src/leds.rs @@ -1,25 +1,22 @@ use va108xx_hal::{ - gpio::{ - porta::{Parts, PA10, PA6, PA7}, - Output, Pin, PushPull, - }, - pac::{IOCONFIG, PORTA}, + gpio::dynpins::DynPin, + gpio::pins::{Pin, PinsA, PushPullOutput, PA10, PA6, PA7}, prelude::*, }; -pub type LD2 = PA10>; -pub type LD3 = PA7>; -pub type LD4 = PA6>; +pub type LD2 = Pin; +pub type LD3 = Pin; +pub type LD4 = Pin; pub struct Leds { leds: [Led; 3], } impl Leds { - pub fn new(led_parts: Parts, iocfg: &mut IOCONFIG, porta: &mut PORTA) -> Self { - let led2 = led_parts.pa10.into_push_pull_output(iocfg, porta); - let led3 = led_parts.pa7.into_push_pull_output(iocfg, porta); - let led4 = led_parts.pa6.into_push_pull_output(iocfg, porta); + pub fn new(led_parts: PinsA) -> Self { + let led2 = led_parts.pa10.into_push_pull_output(); + let led3 = led_parts.pa7.into_push_pull_output(); + let led4 = led_parts.pa6.into_push_pull_output(); Leds { leds: [led2.into(), led3.into(), led4.into()], } @@ -55,7 +52,7 @@ impl core::ops::IndexMut for Leds { } pub struct Led { - pin: Pin>, + pin: DynPin, } macro_rules! ctor { @@ -64,7 +61,7 @@ macro_rules! ctor { impl From<$ldx> for Led { fn from(led: $ldx) -> Self { Led { - pin: led.downgrade(), + pin: led.into() } } }