Skip to content

Commit

Permalink
Merge pull request #812 from jannic/fix-pin-group-write
Browse files Browse the repository at this point in the history
Fix writing to pin groups
  • Loading branch information
ithinuel authored Jun 30, 2024
2 parents 6263d70 + 74b64b3 commit 1da07a0
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 1da07a0

Please sign in to comment.