From 74b64b341c6f30a8a66439762757ced7370e8eda Mon Sep 17 00:00:00 2001 From: Jan Niehusmann Date: Sun, 30 Jun 2024 13:11:39 +0000 Subject: [PATCH] Fix writing to pin groups Fixes WritePinHList::write_mask. Before, it always returned 0, making all writes to pin groups ineffective. --- rp2040-hal/src/gpio/pin_group.rs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/rp2040-hal/src/gpio/pin_group.rs b/rp2040-hal/src/gpio/pin_group.rs index 99a63bb91..ab2fbda0c 100644 --- a/rp2040-hal/src/gpio/pin_group.rs +++ b/rp2040-hal/src/gpio/pin_group.rs @@ -42,6 +42,7 @@ impl WritePinHList for HCons, T> { fn write_mask(&self) -> u32 { + // This is an input pin, so don't include it in write_mask self.tail.write_mask() } } @@ -49,7 +50,7 @@ impl WritePinHList for HCons, T> { fn write_mask(&self) -> u32 { - self.tail.write_mask() + (1 << self.head.id().num) | self.tail.write_mask() } } @@ -144,6 +145,9 @@ where } /// Write this set of pins all at the same time. + /// + /// This only affects output pins. Input pins in the + /// set are ignored. pub fn set(&mut self, state: PinState) { use super::pin::pin_sealed::PinIdOps; let mask = self.0.write_mask(); @@ -156,6 +160,9 @@ where } /// Toggles this set of pins all at the same time. + /// + /// This only affects output pins. Input pins in the + /// set are ignored. pub fn toggle(&mut self) { use super::pin::pin_sealed::PinIdOps; let mask = self.0.write_mask();