-
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
boards/ek-lm4f120x: Change internal LED macro for C2Rust compatibility #20831
Merged
mguetschow
merged 2 commits into
RIOT-OS:master
from
chrysn-pull-requests:ek-lm4f120x-led-rust-const-avoidance
Aug 26, 2024
Merged
boards/ek-lm4f120x: Change internal LED macro for C2Rust compatibility #20831
mguetschow
merged 2 commits into
RIOT-OS:master
from
chrysn-pull-requests:ek-lm4f120x-led-rust-const-avoidance
Aug 26, 2024
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
github-actions
bot
added
Area: tests
Area: tests and testing framework
Area: boards
Area: Board ports
Area: examples
Area: Example Applications
labels
Aug 23, 2024
chrysn
added
CI: run tests
If set, CI server will run tests on hardware for the labeled PR
CI: ready for build
If set, CI server will compile all applications for all available boards for the labeled PR
and removed
CI: run tests
If set, CI server will run tests on hardware for the labeled PR
labels
Aug 23, 2024
chrysn
force-pushed
the
ek-lm4f120x-led-rust-const-avoidance
branch
from
August 23, 2024 11:31
e8f2168
to
121785b
Compare
C preprocessor defines in non-function form are assumed by C2Rust to be constant if they are an expression and not a statement; the LED_PORT was the only place in the code where that was wrong, and led to compiler errors due to the value not being constant. Altering the internal macro to use function form sidesteps that issue. The generally preferred alternative of using a `const` is unavailable in this case because the dereferencing operator is already part of the vendor header file cpu/stellaris_common/include/vendor/cortex-m4-def.h. The changed macro is documented as required by doccheck. The doccheck rule that grandfathered in the LED_PORT macro as allowed undocumented is not removed because it is also used in other board.h files.
chrysn
force-pushed
the
ek-lm4f120x-led-rust-const-avoidance
branch
from
August 23, 2024 11:48
121785b
to
b802a19
Compare
chrysn
commented
Aug 23, 2024
@@ -46,22 +46,26 @@ extern "C" { | |||
#define LED1_PIN GPIO_PIN(5, 2) | |||
#define LED2_PIN GPIO_PIN(5, 3) | |||
|
|||
#define LED_PORT (GPIO_PORTF_DATA_R) | |||
/** | |||
* @brief Port used for `LED0_ON` and similar implementations |
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.
This is LED0_ON
and not @ref LED0_ON
because Doxygen could not resolve that.
chrysn
requested review from
leandrolanzieri,
aabadie and
MichelRottleuthner
as code owners
August 23, 2024 11:49
mguetschow
approved these changes
Aug 26, 2024
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.
LGTM, thanks! No hardware to test it here though, either.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
Area: boards
Area: Board ports
Area: examples
Area: Example Applications
Area: tests
Area: tests and testing framework
CI: ready for build
If set, CI server will compile all applications for all available boards for the labeled PR
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Contribution description
With that applied, a bunch of BOARD_BLACKLIST entries can be removed (from all Rust Makefiles we have).
Testing procedure
I did not test LED blinking on that board as I don't have one, but the change should be sufficiently easy to verify on a theoretical level (supported by the compiler passing).