C Microkernel Realtime eXecutive
Realtime Operating System for Cortex-M based microcontrollers
 
Loading...
Searching...
No Matches
RISC-V Pico SDK Machine-Timer-Based Timing Provider

Ready-to-use implementation of Timing provider API for RP2350 RISC-V cores. More...

Functions

void timing_provider_setup (int interval_ms)
 
void timing_provider_schedule (long delay_us)
 Schedule next timer callback to kernel.
 
void timing_provider_delay (long delay_us)
 Perform tight busy-wait delay.
 
void cmrx_machine_timer_handler (void)
 Machine timer tick handler.
 

Detailed Description

Ready-to-use implementation of Timing provider API for RP2350 RISC-V cores.

The kernel tick is generated by the RISC-V machine timer (mtime/mtimecmp), accessed through Pico SDK's hardware/riscv_platform_timer.h.

Call timing_provider_setup() once, before os_start(), with the tick period in milliseconds. It only stores the period; the timer is armed when the kernel first calls timing_provider_schedule(). The tick period is fixed, so the kernel's tickless feature is not used.

The library also defines cmrx_machine_timer_handler(), which the quirks/pico-sdk-riscv machine-timer interrupt handler calls on every tick.

Function Documentation

◆ cmrx_machine_timer_handler()

void cmrx_machine_timer_handler ( void  )

Machine timer tick handler.

Re-arms the timer and notifies the kernel. Called by the quirks/pico-sdk-riscv machine timer ISR; not meant to be called by applications.

◆ timing_provider_delay()

void timing_provider_delay ( long  delay_us)

Perform tight busy-wait delay.

Kernel calls this function whenever tight delay is required. If delays are in orders of microseconds, then it usually makes no sense to yield or try to do anything else because the overhead of thread switching will consume all the time. Timing timing provider shall perform busy-wait delay, waiting for given amount of microseconds.

Parameters
[in]delay_usamount of microseconds to wait before resuming execution
Note
This function is guarranteed to be called from kernel context.

◆ timing_provider_schedule()

void timing_provider_schedule ( long  delay_us)

Schedule next timer callback to kernel.

Re-configure timing provider so that next timed kernel call will happen after given delay. This is the only function, whose implementation is mandatory and whose prototype nor behavior cannot be changed. If kernel calls this function, then timing provider must reconfigure itself so that it will be able to call back to the kernel as close as possible to time delay_us microseconds in the future. This must happen even if kernel previously signalized that there is no expected timed event and timers were turned off entirely.

Parameters
[in]delay_usdelay time, in microseconds after which kernel shall be called by the timing provider. The value of 0 means that timing provider should not trigger the kernel timer callback until further notice.
Note
This function is guarranteed to be called from kernel context.

◆ timing_provider_setup()

void timing_provider_setup ( int  interval_ms)