Skip to content

GD32: Fast GPIO optimization #27845

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
May 8, 2025
Merged

Conversation

bmourit
Copy link
Contributor

@bmourit bmourit commented May 7, 2025

Description

Adding FORCE_INLINE to the fast GPIO functions gives us a couple benefits.
First, code folding will reduce these functions to their direct register accesses - which is ideal.
Second, it allows us to optimize away the pin-port map - reducing code size (~250 bytes or so) as well as eliminating all overhead.

This has been verified via decompilation.

The only down side is that the EEPROM (software IIC) seems to rely on this overhead to meet timing requirements, and since we now have zero overhead, writing to the EEPROM is broken.

I'll submit another PR with that fix.

Requirements

GD32 Board

Benefits

Zero overhead for IO and smaller code size.

Configurations

N/A

Related Issues

N/A

bmourit added 2 commits May 7, 2025 14:26
Adding FORCE_INLINE to the fast GPIO functions gives us a couple benefits.

First, code folding will reducing these functions to their direct register accesses - which is ideal.

Second, it allows us to optimize away the pin-port map - reducing code size (~250 bytes or so) as well as eliminating all overhead.

This has been verified via decompilation.

The only down side is that the EEPROM (software IIC) seems to rely on this overhead to meet timing requirements, and since we now have zero overhead, writing to the EEPROM is broken.

I'll submit another PR with that fix.
@thinkyhead thinkyhead merged commit fd11748 into MarlinFirmware:bugfix-2.1.x May 8, 2025
66 checks passed
EvilGremlin pushed a commit to EvilGremlin/Marlin that referenced this pull request May 15, 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.

2 participants