C Microkernel Realtime eXecutive
Realtime Operating System for Cortex-M based microcontrollers
 
Loading...
Searching...
No Matches
Standard API

API providing standardized access to various aspects required by userland. More...

Detailed Description

API providing standardized access to various aspects required by userland.

Function Documentation

◆ diff_microtime()

uint32_t diff_microtime ( uint32_t  older_timestamp,
uint32_t  newer_timestamp 
)

Calculate a distance of two timestamps Small helper function to calculate the time between two timestamps.

It will calculate the distance of two timestamps taking possible time counter wraparound. It assumes the order of timestamps is older first, newer last.

Note
This function only returns correct results for timestamps that are less than ~4000 seconds apart. For timestamps more than ~4000 seconds apart two (or even more) timestamp wraparounds happen and the distance calculation returns invalid values.
Parameters
[in]older_timestamptimestamp of event that happened first
[in]newer_timestamptimestamp of event that happened last
Returns
distance of timestamps in microseconds

◆ get_cpu_freq()

__SYSCALL long get_cpu_freq ( void  )

Obtain the current CPU frequency.

Give userspace applications access to the current CPU frequency.

Returns
CPU frequency in Hz or 0 if frequency is unknown or unreliable.

◆ getmicrotime()

__SYSCALL uint32_t getmicrotime ( void  )

Obtain the current scheduler time.

Returns current scheduler time. The time is returned with nanosecond resolution and precision depending on the timing provider implemented.

This value wraps around after about 4000 seconds on 32-bit CPUs

Returns
current scheduler time in nanoseconds

◆ shutdown()

__SYSCALL uint32_t shutdown ( void  )

Shutdown CMRX kernel.

This syscall will initiate CMRX kernel shutdown. Kernel shutdown ensures that the timing provider is stopped. Interrupts are also disabled globally. No check on existing threads status is made. It is up to the application developer to ensure that threads are in stable state before kernel is shut down. Any work done and not saved in threads still active will be lost.

It is not possible to call CMRX system calls once kernel has been shut down. While in general, the possibility of restarting kernel after it has been shut down is not ruled out this workflow is considered as unsupported.

After kernel is shut down the execution will continue in function named cmrx_shutdown_handler(). If this function is not defined, then the CPU will be reset.

CPU state when cmrx_shutdown_handler() is called:

  • memory protection disabled
  • privileged mode execution
  • all interrupts disabled