mirror of
https://github.com/raspberrypi/pico-sdk.git
synced 2025-02-05 18:40:21 +00:00
Fixed an issue that caused incorrect settings when the SPI clock was less than 244141Hz. (#1633)
This commit is contained in:
parent
f5b7a9135b
commit
8b0146c142
@ -51,7 +51,7 @@ uint spi_set_baudrate(spi_inst_t *spi, uint baudrate) {
|
||||
// Find smallest prescale value which puts output frequency in range of
|
||||
// post-divide. Prescale is an even number from 2 to 254 inclusive.
|
||||
for (prescale = 2; prescale <= 254; prescale += 2) {
|
||||
if (freq_in < (prescale + 2) * 256 * (uint64_t) baudrate)
|
||||
if (freq_in < prescale * 256 * (uint64_t) baudrate)
|
||||
break;
|
||||
}
|
||||
invalid_params_if(SPI, prescale > 254); // Frequency too low
|
||||
|
Loading…
x
Reference in New Issue
Block a user