From 2b2c7c8d6c64af3e6637f3447a00d0c8d4b99373 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 10 Feb 2025 16:37:49 +0100 Subject: [PATCH] added explicit converters --- va108xx-hal/src/gpio/dynpin.rs | 10 ++++++++++ va108xx-hal/src/gpio/pin.rs | 8 +++++++- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/va108xx-hal/src/gpio/dynpin.rs b/va108xx-hal/src/gpio/dynpin.rs index aff2872..620b257 100644 --- a/va108xx-hal/src/gpio/dynpin.rs +++ b/va108xx-hal/src/gpio/dynpin.rs @@ -59,6 +59,7 @@ use super::{ pin::{FilterType, InterruptEdge, InterruptLevel, Pin, PinId, PinMode, PinState}, reg::RegisterInterface, + InputDynPinAsync, }; use crate::{clock::FilterClkSel, enable_interrupt, pac, FunSel, IrqCfg}; @@ -529,6 +530,15 @@ impl DynPin { } Err(InvalidPinTypeError) } + + /// Convert the pin into an async pin. The pin can be converted back by calling + /// [InputDynPinAsync::release] + pub fn into_async_input( + self, + irq: crate::pac::Interrupt, + ) -> Result { + InputDynPinAsync::new(self, irq) + } } //================================================================================================== diff --git a/va108xx-hal/src/gpio/pin.rs b/va108xx-hal/src/gpio/pin.rs index e482adf..81b16bc 100644 --- a/va108xx-hal/src/gpio/pin.rs +++ b/va108xx-hal/src/gpio/pin.rs @@ -72,7 +72,7 @@ //! and [`StatefulOutputPin`]. use super::dynpin::{DynAlternate, DynGroup, DynInput, DynOutput, DynPinId, DynPinMode}; use super::reg::RegisterInterface; -use super::DynPin; +use super::{DynPin, InputPinAsync}; use crate::{ pac::{Irqsel, Porta, Portb, Sysconfig}, typelevel::Sealed, @@ -575,6 +575,12 @@ impl AsMut

for SpecificPin

{ //================================================================================================== impl Pin> { + /// Convert the pin into an async pin. The pin can be converted back by calling + /// [InputPinAsync::release] + pub fn into_async_input(self, irq: crate::pac::Interrupt) -> InputPinAsync { + InputPinAsync::new(self, irq) + } + pub fn interrupt_edge( &mut self, edge_type: InterruptEdge,