tinygo/src/examples/systick/systick.go
Ayke van Laethem cbaa58a2d9 all: change //go:export to //export
This is the kind that is used in Go (actually CGo) for exporting
functions. I think it's best to use //export instead of our custom
//go:export pragma, for consistency (they are equivalent in TinyGo).
Therefore I've updated all instances to the standard format (except for
two that are updated in https://github.com/tinygo-org/tinygo/pull/1024).

No smoke tests changed (when comparing the output hash), except for some
wasm tests that include DWARF debug info and tend to be flaky anyway.
2020-04-05 16:16:57 +02:00

28 строки
394 Б
Go

package main
import (
"device/arm"
"machine"
)
func main() {
machine.LED.Configure(machine.PinConfig{Mode: machine.PinOutput})
// timer fires 10 times per second
arm.SetupSystemTimer(machine.CPUFrequency() / 10)
for {
}
}
var led_state bool
//export SysTick_Handler
func timer_isr() {
if led_state {
machine.LED.Low()
} else {
machine.LED.High()
}
led_state = !led_state
}