This commit is contained in:
Drahoslav 2017-11-14 22:33:04 +01:00
parent b604d03178
commit cdcd97f287

View File

@ -294,7 +294,6 @@ func PullMode(pin Pin, pull Pull) {
} }
// Set clock speed for given pin // Set clock speed for given pin
// //
// freq should be in range 4688Hz - 19.2MHz to prevent unexpected behavior // freq should be in range 4688Hz - 19.2MHz to prevent unexpected behavior
@ -338,7 +337,8 @@ func SetClock(pin Pin, freq int) {
const src = 0x01 // oscilator const src = 0x01 // oscilator
clkMem[clkCtlReg] = PASSWORD | src // stop gpio clock clkMem[clkCtlReg] = PASSWORD | src // stop gpio clock
for clkMem[clkCtlReg] & busy != 0 {} // ... and wait for clkMem[clkCtlReg]&busy != 0 {
} // ... and wait
clkMem[clkDivReg] = PASSWORD | (divi << 12) | divf // set dividers clkMem[clkDivReg] = PASSWORD | (divi << 12) | divf // set dividers
clkMem[clkCtlReg] = PASSWORD | enab | src // start clock clkMem[clkCtlReg] = PASSWORD | enab | src // start clock
@ -402,10 +402,10 @@ func memMap (fd uintptr, offset int64) (mem []uint32, mem8 []byte, err error) {
func Close() error { func Close() error {
memlock.Lock() memlock.Lock()
defer memlock.Unlock() defer memlock.Unlock()
if err := syscall.Munmap(gpioMem8) { if err := syscall.Munmap(gpioMem8); err != nil {
return err return err
} }
if err := syscall.Munmap(clkMem8) { if err := syscall.Munmap(clkMem8); err != nil {
return err return err
} }
return nil return nil