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.
Pull Request Overview
The nRF52 SPI implementation's get_rate() method has been returning the actual register content instead of the converted SPI operating frequency.
This PR fixes this issue specifically. However, because the
Frequency
enum relates to twou32
s, namely the register content and the actual frequency, usingFrom<>
traits are confusing which is likely how the bug was introduced originally. Those traits are replaced with methods indicating their purpose.The back-conversion of the register content to a frequency may fail if the register contains an invalid value. As the reset value is valid and all other values written should be valid too, this should work. Nonetheless, a
.expect()
must be introduced.Testing Strategy
Tested on nRF52DK.
Output on latest master:
Output with this PR:
Verifying the actual SPI rate will need to wait for me to get my logic analyzer.
TODO or Help Wanted
nRF52840
also supports 16 and 32 Mbps SPI rates. Those should probably be implemented using compile features on the chip crate. Can we do it in this PR as well, or should I open a new one?Documentation Updated
/docs
, or no updates are required.Formatting
make formatall
.