nrf: give more flexibility in picking SPI speeds #1446
Merged
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.
Instead of only allowing a limited number of speeds, use the provided
speed as an upper bound on the allowed speed. The reasoning is that
picking a higher speed than requrested will likely result in malfunction
while picking a lower speed will usually only result in slower
operation.
This behavior matches the ESP32 at least.
Tested on a SK9822 LED strip with an nrf52832.
It was inspired by code like this: https://github.com/tinygo-org/drivers/pull/208/files#diff-3ea9b9d98ece4f5cf1c374d3876eeda73d4b9fc617d1bc3431cd988af2bfeaebL41
Also, this behavior should allow more flexibility in configuring SPI peripherals: a driver or program should pick the maximum speed allowed by the driver instead of configuring a specific speed per chip (for portable code).