RTEMS 6.1-rc2
|
Free-running counter and busy wait delay functions. More...
Files | |
file | counter.h |
This header file defines the Free-Running Counter and Busy Wait Delay API. | |
file | delaynano.c |
This source file contains the implementation of rtems_counter_delay_nanoseconds(). | |
file | delayticks.c |
This source file contains the implementation of rtems_counter_delay_ticks(). | |
Typedefs | |
typedef CPU_Counter_ticks | rtems_counter_ticks |
Unsigned integer type for counter values. | |
Functions | |
uint64_t | rtems_counter_ticks_to_nanoseconds (rtems_counter_ticks ticks) |
Converts counter ticks into nanoseconds. | |
rtems_counter_ticks | rtems_counter_nanoseconds_to_ticks (uint32_t nanoseconds) |
Converts nanoseconds into counter ticks. | |
int64_t | rtems_counter_ticks_to_sbintime (rtems_counter_ticks ticks) |
Converts counter ticks into signed binary time (sbintime_t). | |
rtems_counter_ticks | rtems_counter_sbintime_to_ticks (int64_t sbt) |
Converts signed binary time (sbintime_t) into counter ticks. | |
void | rtems_counter_initialize_converter (uint32_t frequency) |
Initializes the counter ticks to/from nanoseconds converter functions. | |
void | rtems_counter_delay_ticks (rtems_counter_ticks ticks) |
Busy wait for some counter ticks. | |
void | rtems_counter_delay_nanoseconds (uint32_t nanoseconds) |
Busy wait for some nanoseconds. | |
Free-running counter and busy wait delay functions.
The RTEMS counter is some free-running counter. It ticks usually with a frequency close to the CPU or system bus clock.
The counter can be used in case the overhead of the rtems_clock_get_uptime_nanoseconds() is too high. The step from counter ticks to/from nanoseconds is explicit in this API unlike to rtems_clock_get_uptime_nanoseconds() which performs the conversion on each invocation.
This counter works without a clock driver and during system initialization.
The counter can be used to profile low-level operations like SMP locks or interrupt disabled critical sections. The counter can act also as an entropy source for a random number generator.
The period of the counter depends on the actual hardware.
void rtems_counter_delay_nanoseconds | ( | uint32_t | nanoseconds | ) |
Busy wait for some nanoseconds.
This function does not disable interrupts. Thus task switches and interrupts can interfere with this busy wait may prolong the delay. This function busy waits at least the specified time. Due to some overhead the actual delay may be longer.
[in] | nanoseconds | The minimum busy wait time in nanoseconds. |
void rtems_counter_delay_ticks | ( | rtems_counter_ticks | ticks | ) |
Busy wait for some counter ticks.
This function does not disable interrupts. Thus task switches and interrupts can interfere with this busy wait may prolong the delay. This function busy waits at least the specified time. Due to some overhead the actual delay may be longer.
[in] | ticks | The minimum busy wait time in counter ticks. |
void rtems_counter_initialize_converter | ( | uint32_t | frequency | ) |
Initializes the counter ticks to/from nanoseconds converter functions.
This function must be used to initialize the rtems_counter_ticks_to_nanoseconds() and rtems_counter_nanoseconds_to_ticks() functions. It should be called during system initialization by the board support package.
[in] | frequency | The current counter frequency in Hz. |
rtems_counter_ticks rtems_counter_nanoseconds_to_ticks | ( | uint32_t | nanoseconds | ) |
Converts nanoseconds into counter ticks.
[in] | nanoseconds | The nanoseconds value to convert. |
rtems_counter_ticks rtems_counter_sbintime_to_ticks | ( | int64_t | sbt | ) |
Converts signed binary time (sbintime_t) into counter ticks.
[in] | sbt | The signed binary time value to convert. |
uint64_t rtems_counter_ticks_to_nanoseconds | ( | rtems_counter_ticks | ticks | ) |
Converts counter ticks into nanoseconds.
[in] | ticks | The counter ticks value to convert. |
int64_t rtems_counter_ticks_to_sbintime | ( | rtems_counter_ticks | ticks | ) |
Converts counter ticks into signed binary time (sbintime_t).
[in] | ticks | The counter ticks value to convert. |