Skip to content

Commit

Permalink
Fixed an issue that caused incorrect settings when the SPI clock was …
Browse files Browse the repository at this point in the history
…less than 244141Hz. (#1633)
  • Loading branch information
aizaki77 authored Jun 27, 2024
1 parent f5b7a91 commit 8b0146c
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/rp2_common/hardware_spi/spi.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 8b0146c

Please sign in to comment.