Skip to content
Snippets Groups Projects
Unverified Commit 8b0146c1 authored by aizaki77's avatar aizaki77 Committed by GitHub
Browse files

Fixed an issue that caused incorrect settings when the SPI clock was less than 244141Hz. (#1633)

parent f5b7a913
No related branches found
No related tags found
No related merge requests found
......@@ -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
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment