mirror of
https://github.com/tinygo-org/tinygo.git
synced 2026-08-15 00:13:43 +00:00
device/arm: add system timer registers (#654)
* device/arm: add system timer registers Add SYST registers and bit definitions to device/arm. Add a setup function. Add an example that uses it to blink an LED.
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
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.CPU_FREQUENCY / 10)
|
||||
|
||||
for {
|
||||
}
|
||||
}
|
||||
|
||||
var led_state bool
|
||||
|
||||
//go:export SysTick_Handler
|
||||
func timer_isr() {
|
||||
if led_state {
|
||||
machine.LED.Low()
|
||||
} else {
|
||||
machine.LED.High()
|
||||
}
|
||||
led_state = !led_state
|
||||
}
|
||||
Reference in New Issue
Block a user