1 /*
2  * Copyright (c) 2024 Cienet
3  *
4  * SPDX-License-Identifier: Apache-2.0
5  */
6 
7 #ifndef ZEPHYR_DRIVERS_SENSOR_CLOCK_H_
8 #define ZEPHYR_DRIVERS_SENSOR_CLOCK_H_
9 
10 #include <stdint.h>
11 
12 #ifdef __cplusplus
13 extern "C" {
14 #endif
15 
16 /**
17  * @brief Retrieve the current sensor clock cycles.
18  *
19  * This function obtains the current cycle count from the selected
20  * sensor clock source. The clock source may be the system clock or
21  * an external clock, depending on the configuration.
22  *
23  * @param[out] cycles Pointer to a 64-bit unsigned integer where the
24  *                    current clock cycle count will be stored.
25  *
26  * @return 0 on success, or an error code on failure.
27  */
28 int sensor_clock_get_cycles(uint64_t *cycles);
29 
30 /**
31  * @brief Convert clock cycles to nanoseconds.
32  *
33  * This function converts clock cycles into nanoseconds based on the
34  * clock frequency.
35  *
36  * @param cycles Clock cycles to convert.
37  * @return Time in nanoseconds.
38  */
39 uint64_t sensor_clock_cycles_to_ns(uint64_t cycles);
40 
41 #ifdef __cplusplus
42 }
43 #endif
44 
45 #endif /* ZEPHYR_DRIVERS_SENSOR_CLOCK_H_ */
46