Files
tinygo/src/machine/machine_rp2040_watchdog.go
T
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

29 lines
644 B
Go

//go:build rp2040
// +build rp2040
package machine
import (
"device/rp"
"runtime/volatile"
"unsafe"
)
type watchdogType struct {
ctrl volatile.Register32
load volatile.Register32
reason volatile.Register32
scratch [8]volatile.Register32
tick volatile.Register32
}
var watchdog = (*watchdogType)(unsafe.Pointer(rp.WATCHDOG))
// startTick starts the watchdog tick.
// cycles needs to be a divider that when applied to the xosc input,
// produces a 1MHz clock. So if the xosc frequency is 12MHz,
// this will need to be 12.
func (wd *watchdogType) startTick(cycles uint32) {
wd.tick.Set(cycles | rp.WATCHDOG_TICK_ENABLE)
}