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

stm32xx-sys: fix typo in EXTI pin configuration #1717

Merged
merged 1 commit into from
Apr 3, 2024

Conversation

cbiffle
Copy link
Collaborator

@cbiffle cbiffle commented Apr 3, 2024

In the Giant Scary Nested Match we had to write to be able to address the EXTI register array as an array through the PAC, I typo'd the number base being used to select the field within the register, by reusing 2 from the line above. This is the base 2 logarithm of the number we actually wanted, 4, because the operations are shift and mod, respectively.

Wheeee

Anyway, this fixes the situation where EXTI configuration of any pin p such that p % 4 = 2 or 3 on any port other than A mysteriously senses a different pin in port A instead.

In the Giant Scary Nested Match we had to write to be able to address
the EXTI register array as an array through the PAC, I typo'd the number
base being used to select the field within the register, by reusing 2
from the line above. This is the _base 2 logarithm_ of the number we
actually wanted, 4, because the operations are shift and mod,
respectively.

Wheeee

Anyway, this fixes the situation where EXTI configuration of any pin p
such that p % 4 = 2 or 3 on any port other than A mysteriously senses
a different pin in port A instead.
@cbiffle cbiffle requested a review from hawkw April 3, 2024 20:38
@cbiffle cbiffle enabled auto-merge (rebase) April 3, 2024 20:42
Copy link
Member

@hawkw hawkw left a comment

Choose a reason for hiding this comment

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

welp. good catch! assuming you've tested that looking at Pn14 on a Nucleo no longer results in us getting IRQs for SWD_CLK, this looks good to me!

@@ -398,7 +398,7 @@ fn main() -> ! {
// Process entries that are filled in...
if let &Some(ExtiDispatch { port, .. }) = entry {
let register = i >> 2;
let slot = i % 2;
let slot = i & 0b11;
Copy link
Member

Choose a reason for hiding this comment

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

i waffled on whether & 0b11 or % 4 expresses intent more clearly --- i'm now mildly leaning towards % 4 based on the observation that there are 4 bitfields per register. but, it doesn't actually matter.

I do think that it might be nice if the register and slot calculation was below the comment describing what we're doing --- it's possible i didn't notice this in the review because i was too top-to-bottom in my reading habits, and didn't think to go back and look at the calculations after reading the comment explaining what they were doing. but, whether or not that would have prevented this is probably not really worth thinking too hard about 🤷‍♀️

@cbiffle cbiffle merged commit 7f7308b into master Apr 3, 2024
103 checks passed
@cbiffle cbiffle deleted the cbiffle/fix-exti-typo branch April 3, 2024 20:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants