From 343f63f5e364fffdb751ba7e3e637405c40dd56d Mon Sep 17 00:00:00 2001 From: Jan Niehusmann Date: Sat, 19 Oct 2024 20:15:21 +0000 Subject: [PATCH] implement Debug support for the GPIO structures (RP235x) This is a port of #861 to rp235x-hal --- rp235x-hal/src/gpio/func.rs | 4 ++++ rp235x-hal/src/gpio/mod.rs | 2 ++ rp235x-hal/src/gpio/pin.rs | 1 + rp235x-hal/src/gpio/pull.rs | 1 + rp235x-hal/src/sio.rs | 3 +++ 5 files changed, 11 insertions(+) diff --git a/rp235x-hal/src/gpio/func.rs b/rp235x-hal/src/gpio/func.rs index 544330fed..21bab59ee 100644 --- a/rp235x-hal/src/gpio/func.rs +++ b/rp235x-hal/src/gpio/func.rs @@ -85,6 +85,7 @@ macro_rules! pin_func { ($($fn:ident $(as $alias:ident)?),*) => { $(paste! { /// Type-level `variant` for pin [`Function`]. + #[derive(Debug)] pub struct [](pub(super) ()); impl Function for [] {} impl func_sealed::Function for [] { @@ -111,6 +112,7 @@ pin_func!(Xip, Spi, Uart, I2c as I2C, Pwm, Pio0, Pio1, Pio2, Clock, Usb, UartAux //============================================================================== /// Type-level `variant` for pin [`Function`]. +#[derive(Debug)] pub struct FunctionSio(PhantomData); impl Function for FunctionSio {} impl func_sealed::Function for FunctionSio { @@ -133,12 +135,14 @@ pub trait SioConfig { } /// Type-level `variant` for SIO configuration. +#[derive(Debug)] pub enum SioInput {} impl SioConfig for SioInput { #[allow(missing_docs)] const DYN: DynSioConfig = DynSioConfig::Input; } /// Type-level `variant` for SIO configuration. +#[derive(Debug)] pub enum SioOutput {} impl SioConfig for SioOutput { #[allow(missing_docs)] diff --git a/rp235x-hal/src/gpio/mod.rs b/rp235x-hal/src/gpio/mod.rs index f68f369d8..6861acec2 100644 --- a/rp235x-hal/src/gpio/mod.rs +++ b/rp235x-hal/src/gpio/mod.rs @@ -175,6 +175,7 @@ pub enum OutputOverride { /// Represents a pin, with a given ID (e.g. Gpio3), a given function (e.g. FunctionUart) and a given pull type /// (e.g. pull-down). +#[derive(Debug)] pub struct Pin { id: I, function: F, @@ -1115,6 +1116,7 @@ macro_rules! gpio { (struct: $bank:ident $prefix:ident $($PXi:ident, $id:expr, $func:ident, $pull_type:ident),*) => { paste::paste!{ /// Collection of all the individual [`Pin`]s + #[derive(Debug)] pub struct Pins { _io: [], _pads: [], diff --git a/rp235x-hal/src/gpio/pin.rs b/rp235x-hal/src/gpio/pin.rs index bc669297f..20db6d46e 100644 --- a/rp235x-hal/src/gpio/pin.rs +++ b/rp235x-hal/src/gpio/pin.rs @@ -88,6 +88,7 @@ macro_rules! pin_ids { paste::paste!{ $( #[doc = "Type level variant for the pin `" $name "` in bank `" $prefix "`."] + #[derive(Debug)] pub struct [<$prefix $name>] (pub(crate) ()); impl crate::typelevel::Sealed for [<$prefix $name>] {} impl PinId for [<$prefix $name>] { diff --git a/rp235x-hal/src/gpio/pull.rs b/rp235x-hal/src/gpio/pull.rs index fcd1d9b26..ee004595b 100644 --- a/rp235x-hal/src/gpio/pull.rs +++ b/rp235x-hal/src/gpio/pull.rs @@ -47,6 +47,7 @@ macro_rules! pin_pull_type { ($($pull_type:ident),*) => { $(paste! { /// Type-level `variant` of [`PullType`]. + #[derive(Debug)] pub struct [](pub(super) ()); impl PullType for [] {} impl pull_sealed::PullType for [] { diff --git a/rp235x-hal/src/sio.rs b/rp235x-hal/src/sio.rs index 825612c03..15bf2455b 100644 --- a/rp235x-hal/src/sio.rs +++ b/rp235x-hal/src/sio.rs @@ -40,16 +40,19 @@ pub enum CoreId { } /// Marker struct for ownership of SIO gpio bank0 +#[derive(Debug)] pub struct SioGpioBank0 { _private: (), } /// Marker struct for ownership of SIO FIFO +#[derive(Debug)] pub struct SioFifo { _private: (), } /// Marker struct for ownership of SIO gpio qspi +#[derive(Debug)] pub struct SioGpioQspi { _private: (), }