cpu: mips_pic32_common: Refactor GPIO peripheral#12475
cpu: mips_pic32_common: Refactor GPIO peripheral#12475benpicco merged 3 commits intoRIOT-OS:masterfrom
Conversation
|
Murdock is not happy. |
|
It seems that PIC32MX470F512H does not have PORTA. Sigh... |
Signed-off-by: Francois Berder <[email protected]>
Signed-off-by: Francois Berder <[email protected]>
1f82742 to
6100bf8
Compare
|
This PR is now ready for review |
Signed-off-by: Francois Berder <[email protected]>
6100bf8 to
237f736
Compare
benpicco
left a comment
There was a problem hiding this comment.
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.
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.
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.
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.
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