Timing

Currently, the SDK only supports simple sleep/delay and timestamping functionality.

riotee_sleepX(..) functions put the system into a low power sleep mode for the specified number of ticks or milliseconds. If the power supply fails while sleeping, the functions may return earlier than requested with a RIOTEE_ERR_RESET return code.

riotee_delayX(..) functions spin the CPU until the specified number of milli/microseconds has passed. If the runtime suspends execution or the power supply fails while waiting, the remaining cycles are waited after execution resumes.

API reference

void riotee_timing_init(void)

Initializes the LF clock. Must be called once after reset before any sleep/delay calls.

riotee_rc_t riotee_sleep_ticks(unsigned int ticks_32k)

Waits in a low power mode for the specified number of ticks on a 32kHz clock.

Starts a timer and blocks on a notification. The idle task will keep the system in a low power mode. Function may return earlier than requested if the power runs out and a reset occurs.

Parameters:

ticks_32k – Number of ticks on a 32kHz clock to sleep for.

Return values:
  • RIOTEE_SUCCESS – Successfully passed specified time sleeping.

  • RIOTEE_ERR_RESET – Reset occured while sleeping.

riotee_rc_t riotee_sleep_ms(unsigned int ms)

Waits in a low power mode for the specified time.

Starts a timer and blocks on a notification. The idle task will keep the system in a low power mode. Function may return earlier than requested if the power runs out and a reset occurs.

Parameters:

ms – Number of milliseconds to sleep for.

Return values:
  • RIOTEE_SUCCESS – Successfully passed specified time sleeping.

  • RIOTEE_ERR_RESET – Reset occured while sleeping.

void riotee_delay_us(unsigned int us)

Busy waits for specified number of microseconds.

Keeps the CPU busy for the specified time. Consumes significant energy while waiting. Note that the time passed in the function can be much longer than specified when execution is suspended due to low energy.

Parameters:

us – Number of microseconds to wait.

void riotee_delay_ms(unsigned int ms)

Busy waits for specified number of milliseconds.

Keeps the CPU busy for the specified time. Consumes significant energy while waiting. Note that the time passed in the function can be much longer than specified when execution is suspended due to low energy.

Parameters:

ms – Number of milliseconds to wait.

riotee_rc_t riotee_timing_now(uint64_t *dst)

Reads the current value of the internal RTC-driven timer.

Reads a 56-bit wide counter driven by a 32kHz clock. Return code indicates whether a reset has occured since the last call to the function.

Parameters:

dst – Pointer to destination buffer.

Return values:
  • RIOTEE_SUCCESS – No reset since the last call to the function.

  • RIOTEE_ERR_RESET – Reset since the last call to the function.