feat(PeriphDrivers): Add new MXC_SPI_GetAndClearFlags API#1541
Merged
ttmut merged 1 commit intoApr 16, 2026
Merged
Conversation
bd3c4e5 to
50d63a1
Compare
Add new MXC_SPI_GetAndClearFlags to simultaneously retrieve the current interrupt flags, and clear only the returned flags. This avoids accidentally clearing flags that have been set since a call to get the current flags using the existing MXC_SPI_ClearFlags API. Signed-off-by: Pete Johanson <pete.johanson@analog.com>
50d63a1 to
4e21e1a
Compare
ttmut
approved these changes
Apr 16, 2026
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Description
Add new MXC_SPI_GetAndClearFlags to simultaneously retrieve the current interrupt flags, and clear only the returned flags. This avoids accidentally clearing flags that have been set since a call to get the current flags using the existing MXC_SPI_ClearFlags API.
This is needed to fix a race condition discovered in the Zephyr MAX32 SPI driver. In particular, the ISR there is fetching the flags, then clearing the flags (via
MXC_SPI_ClearFlags), which can lead to missed flags if a flag is set between the call to get the flags, and clear them: https://github.com/zephyrproject-rtos/zephyr/blob/acc53653b4707aa40c22aec8c33f1d733e5e670f/drivers/spi/spi_max32.c#L1064Testing here on MAX32666 (where flake was most prevalent due to this race condition) confirms that moving to the new API eliminates all flake.
Checklist Before Requesting Review