From 620d5f0e0c3274bafafbde0cb8182ca77588ee0b Mon Sep 17 00:00:00 2001 From: Wilfried Chauveau Date: Wed, 10 Nov 2021 10:27:46 +0000 Subject: [PATCH] Use the PIOn peripherals in pin functions rather than creating an enum. (#193) This allows the `FuncionPio?` to be inferred from the `pac::PIO?` used. This change shall be transparent for anyone using the `FunctionPio?` aliases. --- rp2040-hal/src/gpio/pin.rs | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/rp2040-hal/src/gpio/pin.rs b/rp2040-hal/src/gpio/pin.rs index 1da9edf..fbd14b2 100644 --- a/rp2040-hal/src/gpio/pin.rs +++ b/rp2040-hal/src/gpio/pin.rs @@ -307,7 +307,21 @@ macro_rules! function { }; } -function!(Spi, Xip, Uart, I2C, Pwm, Pio0, Pio1, Clock, UsbAux); +function!(Spi, Xip, Uart, I2C, Pwm, Clock, UsbAux); + +impl Sealed for pac::PIO0 {} +impl FunctionConfig for pac::PIO0 { + const DYN: DynFunction = DynFunction::Pio0; +} +/// Type-level variant of [`PinMode`] for alternate peripheral function `pac::PIO0` +pub type FunctionPio0 = Function; + +impl Sealed for pac::PIO1 {} +impl FunctionConfig for pac::PIO1 { + const DYN: DynFunction = DynFunction::Pio1; +} +/// Type-level variant of [`PinMode`] for alternate peripheral function `pac::PIO1` +pub type FunctionPio1 = Function; //============================================================================== // Pin modes @@ -977,7 +991,7 @@ macro_rules! gpio { } } - $( impl super::ValidPinMode for super::Function {} )+ + $( impl super::ValidPinMode for super::[] {} )+ } } }