fix(rp2): possible integer overflow while computing factors for SPI baudrate

Incorrect factors are calculated for baudrates which are a bit
larger than integer multiples of 4194304.
For example for baudrates of 8_400_000 or 58_800_000.
Fixed the same way in newer versions of the RPI SDK.
This commit is contained in:
Olaf Flebbe
2025-10-06 23:05:15 +02:00
committed by Ayke
parent aedaf7d925
commit 3be7100e89
+1 -1
View File
@@ -108,7 +108,7 @@ func (spi *SPI) SetBaudRate(br uint32) error {
var prescale, postdiv uint32
freq := CPUFrequency()
for prescale = 2; prescale < 255; prescale += 2 {
if freq < (prescale+2)*256*br {
if uint64(freq) < uint64((prescale+2)*256)*uint64(br) {
break
}
}