Merge pull request #80 from tmsmr/master

Fix incorrect core_freq for Raspberry Pi 4, Raspberry Pi 400 and CM4
This commit is contained in:
Drahoslav Bednář 2021-12-01 19:11:01 +01:00 committed by GitHub
commit ab13b61116
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

7
spi.go
View File

@ -61,8 +61,11 @@ func SpiEnd(dev SpiDev) {
// Param speed may be as big as 125MHz in theory, but // Param speed may be as big as 125MHz in theory, but
// only values up to 31.25MHz are considered relayable. // only values up to 31.25MHz are considered relayable.
func SpiSpeed(speed int) { func SpiSpeed(speed int) {
const baseFreq = 250 * 1000000 coreFreq := 250 * 1000000
cdiv := uint32(baseFreq / speed) if isBCM2711() {
coreFreq = 550 * 1000000
}
cdiv := uint32(coreFreq / speed)
setSpiDiv(cdiv) setSpiDiv(cdiv)
} }