littlekernel / lk

LK embedded kernel

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

How to use timer

Inchul-Lee opened this issue · comments

I am merging IAR source cdoe to LK. In the IAR it is possible to use SysTick_Handler(void). But I have conformed that _systick(void) is used by LK kernel. I need to use systick or timer for system. I fount out that LK has the timer function like as platform_set_oneshot_timer() or platform_set_periodic_timer. How can I use it? Please give me the example or information.

https://github.com/librerpi/lk-overlay/blob/master/platform/bcm28xx/temp/temp.c#L98-L116

static enum handler_return poller_entry(struct timer *t, lk_time_t now, void *arg) {
...
  return INT_NO_RESCHEDULE;
}

static void temp_init(const struct app_descriptor *app) {
  timer_initialize(&poller);
  timer_set_periodic(&poller, 1000, poller_entry, NULL);
}

APP_START(temp)
  .init = temp_init,
APP_END

this code creates a timer that will run the set function every second