Skip to main content

get_sim_nanos

Returns the current simulator (virtual) time in nanoseconds.
You can get the current time in microseconds by calling get_sim_nanos() / 1000, or in milliseconds by calling get_sim_nanos() / 1000000.

timer_init

Initializes a new timer. Returns the identifier of the timer. Call timer_start() to start the timer, and define the chip_timer_event() callback to response to timer events. The timer_config_t struct contains the following fields: The signature for the callback function is as follows:
Note: timer_init() can only be called from chip_init(). Do not call it at a later time.

timer_start

Schedules the timer given by timer_id. The micros argument determines how many microseconds will pass until the timer will call chip_timer_event(). If repeat is false, the timer event will be called once (one-shot timer). If repeat is true, the timer event will keep getting called every micros microseconds, until you call timer_stop() or reconfigure the timer with timer_start.

timer_start_ns

Similar to timer_start, but specifies the duration of the timer in nanoseconds instead of microseconds. Prefer timer_start() when possible, in order to improve performance.

timer_stop

Stops the given timer. If the timer hasn’t fired yet, it won’t fire until you call timer_start() again.