ChibiOS 21.11.4
Time Measurement

Detailed Description

Time Measurement APIs and services.

Collaboration diagram for Time Measurement:

Data Structures

struct  tm_calibration_t
 Type of a time measurement calibration data. More...
struct  time_measurement_t
 Type of a Time Measurement object. More...

Macros

#define TM_CALIBRATION_LOOP   4U
 Number of iterations in the calibration loop.

Functions

static void tm_stop (time_measurement_t *tmp, rtcnt_t now, rtcnt_t offset)
void chTMObjectInit (time_measurement_t *tmp)
 Initializes a TimeMeasurement object.
NOINLINE void chTMStartMeasurementX (time_measurement_t *tmp)
 Starts a measurement.
NOINLINE void chTMStopMeasurementX (time_measurement_t *tmp)
 Stops a measurement.
NOINLINE void chTMChainMeasurementToX (time_measurement_t *tmp1, time_measurement_t *tmp2)
 Stops a measurement and chains to the next one using the same time stamp.
static void __tm_calibration_object_init (tm_calibration_t *tcp)
 Time measurement initialization.

Macro Definition Documentation

◆ TM_CALIBRATION_LOOP

#define TM_CALIBRATION_LOOP   4U

Number of iterations in the calibration loop.

Note
This is required in order to assess the best result in architectures with instruction cache.

Definition at line 42 of file chtm.h.

Referenced by __tm_calibration_object_init().

Function Documentation

◆ tm_stop()

◆ chTMObjectInit()

void chTMObjectInit ( time_measurement_t * tmp)

Initializes a TimeMeasurement object.

Parameters
[out]tmppointer to a TimeMeasurement structure
Function Class:
Object or module nitializer function.

Definition at line 79 of file chtm.c.

References time_measurement_t::best, time_measurement_t::cumulative, time_measurement_t::last, time_measurement_t::n, and time_measurement_t::worst.

Referenced by __stats_object_init(), __thd_object_init(), and __tm_calibration_object_init().

◆ chTMStartMeasurementX()

NOINLINE void chTMStartMeasurementX ( time_measurement_t * tmp)

Starts a measurement.

Precondition
The time_measurement_t structure must be initialized.
Parameters
[in,out]tmppointer to a TimeMeasurement structure
Function Class:
This is an X-Class API, this function can be invoked from any context.

Definition at line 96 of file chtm.c.

References chSysGetRealtimeCounterX, time_measurement_t::last, and NOINLINE.

Referenced by __stats_object_init(), __stats_start_measure_crit_isr(), __stats_start_measure_crit_thd(), __tm_calibration_object_init(), and chInstanceObjectInit().

◆ chTMStopMeasurementX()

NOINLINE void chTMStopMeasurementX ( time_measurement_t * tmp)

Stops a measurement.

Precondition
The time_measurement_t structure must be initialized.
Parameters
[in,out]tmppointer to a time_measurement_t structure
Function Class:
This is an X-Class API, this function can be invoked from any context.

Definition at line 109 of file chtm.c.

References chSysGetRealtimeCounterX, NOINLINE, tm_calibration_t::offset, tm_stop(), and ch_system::tmc.

Referenced by __stats_stop_measure_crit_isr(), __stats_stop_measure_crit_thd(), and __tm_calibration_object_init().

Here is the call graph for this function:

◆ chTMChainMeasurementToX()

NOINLINE void chTMChainMeasurementToX ( time_measurement_t * tmp1,
time_measurement_t * tmp2 )

Stops a measurement and chains to the next one using the same time stamp.

Parameters
[in,out]tmp1pointer to the time_measurement_t structure to be stopped
[in,out]tmp2pointer to the time_measurement_t structure to be started
Function Class:
This is an X-Class API, this function can be invoked from any context.

Definition at line 126 of file chtm.c.

References chSysGetRealtimeCounterX, time_measurement_t::last, NOINLINE, and tm_stop().

Referenced by __stats_ctxswc().

Here is the call graph for this function:

◆ __tm_calibration_object_init()

void __tm_calibration_object_init ( tm_calibration_t * tcp)
inlinestatic

Time measurement initialization.

Note
Internal use only.
Parameters
[out]tcppointer to the tm_calibration_t structure
Function Class:
Not an API, this function is for internal use only.

Definition at line 119 of file chtm.h.

References time_measurement_t::best, chTMObjectInit(), chTMStartMeasurementX(), chTMStopMeasurementX(), tm_calibration_t::offset, and TM_CALIBRATION_LOOP.

Referenced by chSysInit().

Here is the call graph for this function: