-
Notifications
You must be signed in to change notification settings - Fork 2k
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
cpu: mips_pic32_common: Refactor GPIO peripheral #12475
cpu: mips_pic32_common: Refactor GPIO peripheral #12475
Conversation
Murdock is not happy. |
It seems that PIC32MX470F512H does not have PORTA. Sigh... |
Signed-off-by: Francois Berder <18538310+francois-berder@users.noreply.github.com>
Signed-off-by: Francois Berder <18538310+francois-berder@users.noreply.github.com>
1f82742
to
6100bf8
Compare
This PR is now ready for review |
Signed-off-by: Francois Berder <18538310+francois-berder@users.noreply.github.com>
6100bf8
to
237f736
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code looks good, I trust in your testing.
/** | ||
* @brief Override GPIO pin selection macro | ||
*/ | ||
#define GPIO_PIN(x,y) ((x << 4) | (y & 0xf)) | ||
#define GPIO_PIN(x, y) (((_PORTB_BASE_ADDRESS & 0xFFFFF000) + (x << 8)) | y) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I know it doesn't make a difference, but it would feel nicer if you used _PORTA_BASE_ADDRESS
here.
Never mind, PIC32MX470F512H does not have PORTA.
#define ODCxSET(P) ((P)[0x48/0x4]) | ||
#define ANSELxCLR(P) ((P)[0x04/0x4]) | ||
#define TRISxCLR(P) ((P)[0x14/0x4]) | ||
#define TRISxSET(P) ((P)[0x18/0x4]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using a struct for this would be a more orthodox solution, but with all those gaps I see how this is easier to handle.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I thought about that but it went against one of the mains reasons for refactoring GPIO peripheral: avoiding storing base addresses to reduce the size of the firmware.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If it's a compile-time constant the compiler will also optimize it away if you are using a struct.
Contribution description
This PR simplifies the code of the GPIO peripheral.
Testing procedure
I modified hello-world example to toggle, switch on/off LEDs. UART should keep working.
Issues/PRs references
None