Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

generic: port: Fix toggle() for dynamic pins #501

Merged
merged 1 commit into from
Jan 28, 2024
Merged

Conversation

Rahix
Copy link
Owner

@Rahix Rahix commented Jan 28, 2024

During commit 063f845 ("generic: simplify port macro via paste!"), an accidental change was introduced where out_toggle() for dynamic pins wrote to the PORT register instead of the PIN register. This meant that toggle() for dynamic pins no longer worked.

Fix this regression by making out_toggle() write to PIN again.

Fixes #499.

During commit 063f845 ("generic: simplify port macro via
`paste!`"), an accidental change was introduced where out_toggle() for
dynamic pins wrote to the `PORT` register instead of the `PIN` register.
This meant that toggle() for dynamic pins no longer worked.

Fix this regression by making out_toggle() write to `PIN` again.

Fixes: 063f845 ("generic: simplify port macro via `paste!`")
@Rahix Rahix added the bug Something isn't working label Jan 28, 2024
Copy link
Owner Author

@Rahix Rahix left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verified on ATmega328P.

@Rahix Rahix merged commit 4dbd683 into main Jan 28, 2024
23 checks passed
@Rahix Rahix deleted the fix-dynamic-toggle branch January 28, 2024 16:47
@andber1 andber1 mentioned this pull request Mar 10, 2025
@andber1
Copy link

andber1 commented Mar 10, 2025

@Rahix While debugging a toggle problem on an AtMega16 (see #642) I came across this PR. I did not understand how the w.bits(self.mask) toggles a bit. Shouldn't it be w.bits(r.bits() ^ self.mask)? And why is the PIN register the right one? Doesn't the PORT register control the output state? I need to change the code in my PR exactly the opposite way as you did and I am not sure why these two places are so different.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

"uno-timer" example no longer works
2 participants