github.com/tinygo-org/tinygo@v0.31.3-0.20240404173401-90b0bf646c27/src/examples/systick/systick.go (about) 1 package main 2 3 import ( 4 "device/arm" 5 "machine" 6 ) 7 8 var timerCh = make(chan struct{}, 1) 9 10 func main() { 11 machine.LED.Configure(machine.PinConfig{Mode: machine.PinOutput}) 12 13 // timer fires 10 times per second 14 arm.SetupSystemTimer(machine.CPUFrequency() / 10) 15 16 for { 17 machine.LED.Low() 18 <-timerCh 19 machine.LED.High() 20 <-timerCh 21 } 22 } 23 24 //export SysTick_Handler 25 func timer_isr() { 26 select { 27 case timerCh <- struct{}{}: 28 default: 29 // The consumer is running behind. 30 } 31 }