8000 Fix some pin definitions for Adafruit QT Py RP2040 by Kealper · Pull Request #397 · earlephilhower/arduino-pico · GitHub
[go: up one dir, main page]

Skip to content

Fix some pin definitions for Adafruit QT Py RP2040 #397

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

Merged
merged 2 commits into from
Dec 30, 2021

Conversation

Kealper
Copy link
Contributor
@Kealper Kealper commented Dec 30, 2021

This PR corrects the pin definitions for pins A0, A1, A2, and A3 on the Adafruit QT Py RP2040.

On this board, the four pins above are reversed compared to what's defined in the common pin configuration. The current way this PR is fixing this is to just use preprocessor #define in the board-specific variants/adafruit_qtpy/pins_arduino.h to override the static const declarations from variants/generic/common.h of those four pins. This method appears to work fine and compiles without warnings while keeping the general board variant style alive.

Another option for correcting this problem would be to copy all the pin definitions from variants/generic/common.h into the board's specific file with the required changes and just not include that common.h in it, but that way doesn't fit the style of how other boards are defined, so is this method in the PR okay with you, or would you prefer it be done more like this other method?

Reverse pin definitions for A0 through A3
Copy link
Owner
@earlephilhower earlephilhower left a comment

Choose a reason for hiding this comment

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

Thanks for the fix!

You bring up a good question for which I really don't have a good answer.

However, I'm thinking the best way to do this is to modify common to allow overrides w/a "well known" #define __PIN_A0 XXX

So common.h would be something like:

#ifdef __PIN_A0
const int A0 = __PIN_A0;
#else
const int A0 = (26u);
....

or

#ifndef __PIN_A0
#define __PIN_A0 (26u)
#endif
....
const int A0 = __PIN_A0;
...

And your patch would be

#define __PIN_A0 (29u)
....
#include "../generic/common.h"

Does that seem reasonable?

Allows for more consistency on overrides for A0-A3 on boards that require it
Copy link
Owner
@earlephilhower earlephilhower left a comment

Choose a reason for hiding this comment

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

Thanks for the update! I think this way will be better in the long run.

@Kealper
Copy link
Contributor Author
Kealper commented Dec 30, 2021

I think that way of modifying common to create a bit of a "standardized" method of overriding A0-A3 is the best way to go about this as well, since it provides a way for future variants that might need them changed to go about that this way instead of everyone coming up with different solutions down the road.

@earlephilhower earlephilhower merged commit 5b270aa into earlephilhower:master Dec 30, 2021
@dhalbert
Copy link
Contributor

Tagging @ladyada for interest.

@Kealper Kealper deleted the fix-qtpy-pin-defs branch December 30, 2021 20:50
@ladyada
Copy link
Contributor
ladyada commented Dec 30, 2021

awesome!

schkovich pushed a commit to schkovich/arduino-pico that referenced this pull request May 24, 2025
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.

4 participants
0