mirror of
https://github.com/stianeikeland/go-rpio.git
synced 2025-02-09 02:34:56 +01:00
Fix divf computation
This commit is contained in:
parent
9b13a0969b
commit
0122f1902d
5
rpio.go
5
rpio.go
|
@ -191,7 +191,8 @@ func (pin Pin) PullOff() {
|
||||||
}
|
}
|
||||||
|
|
||||||
// PinMode sets the mode (direction) of a given pin (Input, Output or Clock)
|
// PinMode sets the mode (direction) of a given pin (Input, Output or Clock)
|
||||||
// Clock is possible only for some pins (bcm 4, 5, 6)
|
//
|
||||||
|
// Clock is possible only for some pins (bcm 4, 5, 6, 20, 21)
|
||||||
func PinMode(pin Pin, mode Mode) {
|
func PinMode(pin Pin, mode Mode) {
|
||||||
|
|
||||||
// Pin fsel register, 0 or 1 depending on bank
|
// Pin fsel register, 0 or 1 depending on bank
|
||||||
|
@ -310,7 +311,7 @@ func SetFreq(pin Pin, freq int) {
|
||||||
const maxUint12 = 4095
|
const maxUint12 = 4095
|
||||||
|
|
||||||
divi := uint32(source / freq)
|
divi := uint32(source / freq)
|
||||||
divf := uint32(((source % freq) << 12) / source)
|
divf := uint32(((source % freq) << 12) / freq)
|
||||||
|
|
||||||
divi &= maxUint12
|
divi &= maxUint12
|
||||||
divf &= maxUint12
|
divf &= maxUint12
|
||||||
|
|
Loading…
Reference in New Issue
Block a user