#include "kyu.h" #include "thread.h" static int led = 0; static void blink ( int xx ) { gpio_led_set ( led ); led = (led+1) % 2; } static void blinker ( int xx ) { gpio_led_init (); thr_repeat_c ( 500, blink, 0 ); } void user_init ( int xx ) { thr_new ( "blinker", blinker, 0, 10, 0 ); }We launch a thread, which runs the C function "blinker", which contains only initialization and setup code. It then specifies another function, namely "blink" that should be launched every 500 timer ticks. The blink function runs and then returns, i.e. "falls off the end". As long as it doesn't run for longer than the repeat interval, all is well.
This is a nice clean and simple way to blink an LED.
Kyu / tom@mmto.org