As with every peripheral, you need to init the subsystem before using it. Do that with timer_init().

If you need to just wait some time, call

timer_delay(time)

with the number of milliseconds you want to wait. This call will automatically yield the CPU to other processes if you're using the kernel.

In addition, BeRTOS supports timers with callbacks. Define a Timer structure and call timer_setSoftint() to provide a callback that will be called when the timer expires.

Timer t;

void callback(void *data)
{
  (void) data;
  kputs("timer expired\n");
  timer_add(&t);
}

int main()
{
  timer_init();

  // set the callback
  timer_setSoftint(&t, callback, NULL);
  // expire time: 1s
  timer_setDelay(&t, ms_to_ticks(1000));
  // start the timer
  timer_add(&t);
}

By default, BeRTOS timers are not recurrent, so you need to add them again when they expire (check callback() code).

You may be wondering what's the last parameter to the setSoftint() function. Well, sometimes you may want to pass some data to your callback or you want to use the same callback for different events, so you need different data to operate on depending on the event that triggered the callback. The only way to pass the data is to use a void *, so in your code just cast the pointer to the correct type and you can use it freely.

See also timer.h documentation.