fix(GPIO): Alternative Function numbers were inverted#543
Conversation
jorgesg82
left a comment
There was a problem hiding this comment.
They are not inverted I think. The AF0 is the LSB. Check the function valid_af:
inline constexpr bool valid_af(const AlternateFunction af) const {
if (af == AlternateFunction::NO_AF)
return true;
return ((1 << static_cast<uint8_t>(af)) & afs) != 0;
}There was a problem hiding this comment.
Pull request overview
Copilot reviewed 1 out of 1 changed files in this pull request and generated no new comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
What I meant with inverted is with respect to the casting made in the build method, alternate functions have a 1 to 1 correspondence (AF10 == 10) so currently the casting doesn't interpret correctly the alternate function. |
|
From my point of view, the instantiated pins in Inc/HALAL/Models/Pin.hpp, the AlternateFunction enum, and the valid_af function match one with each other. I think the only thing that does NOT match with the rest is the cast in the build function, so changing that to match with the others will be the less disturbing fix, don't you think? Otherwise you will have to invert the enum, to modify the valid_af function, and to change all the bitmaps (that would be for sure the most painful thing of them) |
Yeah, that's true, will do that, I'll also add a comment to the enum clarifying that |
victor-Lopez25
left a comment
There was a problem hiding this comment.
I like returning std::size_t in inscribe since it allows doing more interesting things elsewhere but remember to change the wiki for it
Yeah, will do the moment this pr is approved |
Already implemented what was asked in the review exactly as it was requested
Just what the title says + Make inscribes return std::size_t (the result of the add operation) so that they are easier to use from higher domains