Skip to content

Commit

Permalink
Fix writing to pin groups
Browse files Browse the repository at this point in the history
Fixes WritePinHList::write_mask. Before, it always returned 0, making
all writes to pin groups ineffective.
  • Loading branch information
jannic committed Jun 30, 2024
1 parent 6263d70 commit 74b64b3
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion rp2040-hal/src/gpio/pin_group.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,15 @@ impl<P: PinId, M: PullType, T: WritePinHList> WritePinHList
for HCons<Pin<P, FunctionSioInput, M>, T>
{
fn write_mask(&self) -> u32 {
// This is an input pin, so don't include it in write_mask
self.tail.write_mask()
}
}
impl<P: PinId, M: PullType, T: WritePinHList> WritePinHList
for HCons<Pin<P, FunctionSioOutput, M>, T>
{
fn write_mask(&self) -> u32 {
self.tail.write_mask()
(1 << self.head.id().num) | self.tail.write_mask()
}
}

Expand Down Expand Up @@ -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();
Expand All @@ -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();
Expand Down

0 comments on commit 74b64b3

Please sign in to comment.