Free-running counter and busy wait delay functions.
More...
|
file | counter.h |
| Free-Running Counter and Busy Wait Delay API.
|
|
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.
◆ rtems_counter_delay_nanoseconds()
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.
- Parameters
-
[in] | nanoseconds | The minimum busy wait time in nanoseconds. |
◆ rtems_counter_delay_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.
- Parameters
-
[in] | ticks | The minimum busy wait time in counter ticks. |
◆ rtems_counter_difference()
Returns the difference between the second and first CPU counter value.
This operation may be carried out as a modulo operation depending on the range of the CPU counter device.
- Parameters
-
[in] | second | The second CPU counter value. |
[in] | first | The first CPU counter value. |
- Returns
- Returns second minus first modulo counter period.
Definition at line 96 of file counter.h.
◆ rtems_counter_frequency()
static uint32_t rtems_counter_frequency |
( |
void |
| ) |
|
|
inlinestatic |
Returns the current counter frequency in Hz.
- Returns
- The current counter frequency in Hz.
Definition at line 69 of file counter.h.
◆ rtems_counter_initialize_converter()
void rtems_counter_initialize_converter |
( |
uint32_t |
frequency | ) |
|
◆ rtems_counter_nanoseconds_to_ticks()
Converts nanoseconds into counter ticks.
- Parameters
-
[in] | nanoseconds | The nanoseconds value to convert. |
- Returns
- The counter ticks value corresponding to the nanoseconds value. The value is rounded up.
◆ rtems_counter_read()
Reads the current counter value.
- Returns
- The current counter value.
Definition at line 79 of file counter.h.
◆ rtems_counter_sbintime_to_ticks()
Converts signed binary time (sbintime_t) into counter ticks.
- Parameters
-
[in] | sbt | The signed binary time value to convert. |
- Returns
- The counter ticks value corresponding to the nanoseconds value. The value is rounded up.
◆ rtems_counter_ticks_to_nanoseconds()
Converts counter ticks into nanoseconds.
- Parameters
-
[in] | ticks | The counter ticks value to convert. |
- Returns
- The nanoseconds value corresponding to the counter ticks. The value is rounded up.
◆ rtems_counter_ticks_to_sbintime()
Converts counter ticks into signed binary time (sbintime_t).
- Parameters
-
[in] | ticks | The counter ticks value to convert. |
- Returns
- The signed binary time value corresponding to the counter ticks value. The value is rounded up.