Zephyr API Documentation 4.4.99
A Scalable Open Source RTOS
Loading...
Searching...
No Matches
timing.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2020 Intel Corporation.
3 *
4 * SPDX-License-Identifier: Apache-2.0
5 */
6
7#ifndef ZEPHYR_INCLUDE_TIMING_TIMING_H_
8#define ZEPHYR_INCLUDE_TIMING_TIMING_H_
9
11#include <zephyr/timing/types.h>
12
13#ifdef __cplusplus
14extern "C" {
15#endif
16
29
40
48void soc_timing_init(void);
49
59
68void soc_timing_stop(void);
69
85
101 volatile timing_t *const end);
102
111
121
132
141
145
156
165
175
185
201
217 volatile timing_t *const end);
218
227
237
248
257
261
266
267#ifdef CONFIG_TIMING_FUNCTIONS
268
274void timing_init(void);
275
282void timing_start(void);
283
290void timing_stop(void);
291
309
315static inline timing_t timing_counter_get(void)
316{
317#if defined(CONFIG_BOARD_HAS_TIMING_FUNCTIONS)
319#elif defined(CONFIG_SOC_HAS_TIMING_FUNCTIONS)
320 return soc_timing_counter_get();
321#else
323#endif
324}
325
336static inline uint64_t timing_cycles_get(volatile timing_t *const start,
337 volatile timing_t *const end)
338{
339#if defined(CONFIG_BOARD_HAS_TIMING_FUNCTIONS)
340 return board_timing_cycles_get(start, end);
341#elif defined(CONFIG_SOC_HAS_TIMING_FUNCTIONS)
342 return soc_timing_cycles_get(start, end);
343#else
344 return arch_timing_cycles_get(start, end);
345#endif
346}
347
353static inline uint64_t timing_freq_get(void)
354{
355#if defined(CONFIG_BOARD_HAS_TIMING_FUNCTIONS)
356 return board_timing_freq_get();
357#elif defined(CONFIG_SOC_HAS_TIMING_FUNCTIONS)
358 return soc_timing_freq_get();
359#else
360 return arch_timing_freq_get();
361#endif
362}
363
371{
372#if defined(CONFIG_BOARD_HAS_TIMING_FUNCTIONS)
373 return board_timing_cycles_to_ns(cycles);
374#elif defined(CONFIG_SOC_HAS_TIMING_FUNCTIONS)
375 return soc_timing_cycles_to_ns(cycles);
376#else
377 return arch_timing_cycles_to_ns(cycles);
378#endif
379}
380
389{
390#if defined(CONFIG_BOARD_HAS_TIMING_FUNCTIONS)
391 return board_timing_cycles_to_ns_avg(cycles, count);
392#elif defined(CONFIG_SOC_HAS_TIMING_FUNCTIONS)
393 return soc_timing_cycles_to_ns_avg(cycles, count);
394#else
395 return arch_timing_cycles_to_ns_avg(cycles, count);
396#endif
397}
398
404static inline uint32_t timing_freq_get_mhz(void)
405{
406#if defined(CONFIG_BOARD_HAS_TIMING_FUNCTIONS)
408#elif defined(CONFIG_SOC_HAS_TIMING_FUNCTIONS)
410#else
412#endif
413}
414
415#endif /* CONFIG_TIMING_FUNCTIONS */
416
420
421#ifdef __cplusplus
422}
423#endif
424
425#endif /* ZEPHYR_INCLUDE_TIMING_TIMING_H_ */
uint64_t arch_timing_freq_get(void)
Get frequency of counter used (in Hz).
uint32_t arch_timing_freq_get_mhz(void)
Get frequency of counter used (in MHz).
uint64_t arch_timing_cycles_get(volatile timing_t *const start, volatile timing_t *const end)
Get number of cycles between start and end.
uint64_t arch_timing_cycles_to_ns(uint64_t cycles)
Convert number of cycles into nanoseconds.
uint64_t arch_timing_cycles_to_ns_avg(uint64_t cycles, uint32_t count)
Convert number of cycles into nanoseconds with averaging.
timing_t arch_timing_counter_get(void)
Return timing counter.
uint64_t board_timing_cycles_to_ns(uint64_t cycles)
Convert number of cycles into nanoseconds.
uint64_t board_timing_cycles_get(volatile timing_t *const start, volatile timing_t *const end)
Get number of cycles between start and end.
void board_timing_stop(void)
Signal the end of the timing information gathering.
uint64_t board_timing_cycles_to_ns_avg(uint64_t cycles, uint32_t count)
Convert number of cycles into nanoseconds with averaging.
void board_timing_init(void)
Initialize the timing subsystem.
uint64_t board_timing_freq_get(void)
Get frequency of counter used (in Hz).
uint32_t board_timing_freq_get_mhz(void)
Get frequency of counter used (in MHz).
void board_timing_start(void)
Signal the start of the timing information gathering.
timing_t board_timing_counter_get(void)
Return timing counter.
void soc_timing_stop(void)
Signal the end of the timing information gathering.
void soc_timing_start(void)
Signal the start of the timing information gathering.
void soc_timing_init(void)
Initialize the timing subsystem on SoC.
uint64_t soc_timing_cycles_to_ns_avg(uint64_t cycles, uint32_t count)
Convert number of cycles into nanoseconds with averaging.
timing_t soc_timing_counter_get(void)
Return timing counter.
uint32_t soc_timing_freq_get_mhz(void)
Get frequency of counter used (in MHz).
uint64_t soc_timing_cycles_get(volatile timing_t *const start, volatile timing_t *const end)
Get number of cycles between start and end.
uint64_t soc_timing_cycles_to_ns(uint64_t cycles)
Convert number of cycles into nanoseconds.
uint64_t soc_timing_freq_get(void)
Get frequency of counter used (in Hz).
static uint64_t timing_cycles_to_ns(uint64_t cycles)
Convert number of cycles into nanoseconds.
Definition timing.h:370
static uint64_t timing_cycles_to_ns_avg(uint64_t cycles, uint32_t count)
Convert number of cycles into nanoseconds with averaging.
Definition timing.h:388
void timing_start(void)
Signal the start of the timing information gathering.
void timing_init(void)
Initialize the timing subsystem.
static uint32_t timing_freq_get_mhz(void)
Get frequency of counter used (in MHz).
Definition timing.h:404
uint64_t timing_ns_get(void)
Return a monotonic timestamp in nanoseconds.
static uint64_t timing_cycles_get(volatile timing_t *const start, volatile timing_t *const end)
Get number of cycles between start and end.
Definition timing.h:336
static timing_t timing_counter_get(void)
Return timing counter.
Definition timing.h:315
static uint64_t timing_freq_get(void)
Get frequency of counter used (in Hz).
Definition timing.h:353
void timing_stop(void)
Signal the end of the timing information gathering.
uint64_t timing_t
Definition types.h:10
__UINT32_TYPE__ uint32_t
Definition stdint.h:90
__UINT64_TYPE__ uint64_t
Definition stdint.h:91