tinygo/src/machine/machine_rp2040_resets.go
Ayke van Laethem 77ec9b6369 all: update build constraints to Go 1.17
Do it all at once in preparation for Go 1.18 support.

To make this commit, I've simply modified the `fmt-check` Makefile
target to rewrite files instead of listing the differences. So this is a
fully mechanical change, it should not have introduced any errors.
2022-02-04 07:49:46 +01:00

44 строки
971 Б
Go

//go:build rp2040
// +build rp2040
package machine
import (
"device/rp"
"runtime/volatile"
"unsafe"
)
// RESETS_RESET_Msk is bitmask to reset all peripherals
//
// TODO: This field is not available in the device file.
const RESETS_RESET_Msk = 0x01ffffff
type resetsType struct {
reset volatile.Register32
wdSel volatile.Register32
resetDone volatile.Register32
}
var resets = (*resetsType)(unsafe.Pointer(rp.RESETS))
// resetBlock resets hardware blocks specified
// by the bit pattern in bits.
func resetBlock(bits uint32) {
resets.reset.SetBits(bits)
}
// unresetBlock brings hardware blocks specified by the
// bit pattern in bits out of reset.
func unresetBlock(bits uint32) {
resets.reset.ClearBits(bits)
}
// unresetBlockWait brings specified hardware blocks
// specified by the bit pattern in bits
// out of reset and wait for completion.
func unresetBlockWait(bits uint32) {
unresetBlock(bits)
for !resets.resetDone.HasBits(bits) {
}
}