From 122535c02ab334c8460e6838db4421e20d1bc1f8 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Thu, 17 Oct 2024 16:16:04 +0200 Subject: [PATCH] implement Debug support for the GPIO structures --- rp2040-hal/src/gpio/func.rs | 4 ++++ rp2040-hal/src/gpio/mod.rs | 2 ++ rp2040-hal/src/gpio/pin.rs | 1 + rp2040-hal/src/gpio/pull.rs | 1 + rp2040-hal/src/sio.rs | 5 +++++ 5 files changed, 13 insertions(+) diff --git a/rp2040-hal/src/gpio/func.rs b/rp2040-hal/src/gpio/func.rs index f988bbb85..1c9f0d91b 100644 --- a/rp2040-hal/src/gpio/func.rs +++ b/rp2040-hal/src/gpio/func.rs @@ -80,6 +80,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 [] { @@ -106,6 +107,7 @@ pin_func!(Xip, Spi, Uart, I2c as I2C, Pwm, Pio0, Pio1, Clock, Usb, Null); //============================================================================== /// Type-level `variant` for pin [`Function`]. +#[derive(Debug)] pub struct FunctionSio(PhantomData); impl Function for FunctionSio {} impl func_sealed::Function for FunctionSio { @@ -128,12 +130,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/rp2040-hal/src/gpio/mod.rs b/rp2040-hal/src/gpio/mod.rs index 71a346682..d37469c44 100644 --- a/rp2040-hal/src/gpio/mod.rs +++ b/rp2040-hal/src/gpio/mod.rs @@ -158,6 +158,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, @@ -1081,6 +1082,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/rp2040-hal/src/gpio/pin.rs b/rp2040-hal/src/gpio/pin.rs index 1f3689555..bcdb89872 100644 --- a/rp2040-hal/src/gpio/pin.rs +++ b/rp2040-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/rp2040-hal/src/gpio/pull.rs b/rp2040-hal/src/gpio/pull.rs index e120bd8bd..d98e0f81a 100644 --- a/rp2040-hal/src/gpio/pull.rs +++ b/rp2040-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/rp2040-hal/src/sio.rs b/rp2040-hal/src/sio.rs index 13fbfcc0e..b817ffb0c 100644 --- a/rp2040-hal/src/sio.rs +++ b/rp2040-hal/src/sio.rs @@ -35,26 +35,31 @@ 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: (), } /// Marker struct for ownership of divide/modulo module +#[derive(Debug)] pub struct HwDivider { _private: (), } /// Result of divide/modulo operation +#[derive(Debug)] pub struct DivResult { /// The quotient of divide/modulo operation pub quotient: T,