Skip to content

Commit 44fe194

Browse files
committed
Add a debug format for erased pins
1 parent 3620e82 commit 44fe194

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

src/gpio.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1110,6 +1110,7 @@ pub mod erased {
11101110
PullUp, PushPull,
11111111
};
11121112
use crate::Never;
1113+
use core::fmt;
11131114
use core::marker::PhantomData;
11141115
use embedded_hal::digital::v2::{
11151116
toggleable, InputPin, OutputPin, StatefulOutputPin,
@@ -1368,4 +1369,15 @@ pub mod erased {
13681369
Ok(self.block().idr.read().bits() & (1 << self.pin_id()) == 0)
13691370
}
13701371
}
1372+
1373+
1374+
impl<MODE> fmt::Debug for ErasedPin<MODE> {
1375+
fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
1376+
formatter.write_fmt(format_args!(
1377+
"P({}{})",
1378+
char::from(self.port_id() + 'A' as u8),
1379+
self.pin_id()
1380+
))
1381+
}
1382+
}
13711383
}

0 commit comments

Comments
 (0)