Zephyr API Documentation 4.0.0-rc3
A Scalable Open Source RTOS
Loading...
Searching...
No Matches
timeutil.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2019 Peter Bigot Consulting, LLC
3 *
4 * SPDX-License-Identifier: Apache-2.0
5 */
6
21#ifndef ZEPHYR_INCLUDE_SYS_TIMEUTIL_H_
22#define ZEPHYR_INCLUDE_SYS_TIMEUTIL_H_
23
24#include <time.h>
25
26#include <zephyr/types.h>
27
28#ifdef __cplusplus
29extern "C" {
30#endif
31
40/* Base Year value use in calculations in "timeutil_timegm64" API */
41#define TIME_UTILS_BASE_YEAR 1900
42
53
65time_t timeutil_timegm(const struct tm *tm);
66
109
131
172
191 const struct timeutil_sync_instant *inst);
192
218 const struct timeutil_sync_instant *base);
219
234
258 uint64_t local, uint64_t *refp);
259
282 uint64_t ref, int64_t *localp);
283
303
304#ifdef __cplusplus
305}
306#endif
307
312#endif /* ZEPHYR_INCLUDE_SYS_TIMEUTIL_H_ */
_TIME_T_ time_t
Definition _timespec.h:14
time_t timeutil_timegm(const struct tm *tm)
Convert broken-down time to a POSIX epoch offset in seconds.
int64_t timeutil_timegm64(const struct tm *tm)
Convert broken-down time to a POSIX epoch offset in seconds.
int timeutil_sync_state_set_skew(struct timeutil_sync_state *tsp, float skew, const struct timeutil_sync_instant *base)
Update the state with a new skew and possibly base value.
int timeutil_sync_ref_from_local(const struct timeutil_sync_state *tsp, uint64_t local, uint64_t *refp)
Interpolate a reference timescale instant from a local instant.
int timeutil_sync_state_update(struct timeutil_sync_state *tsp, const struct timeutil_sync_instant *inst)
Record a new instant in the time synchronization state.
int32_t timeutil_sync_skew_to_ppb(float skew)
Convert from a skew to an error in parts-per-billion.
float timeutil_sync_estimate_skew(const struct timeutil_sync_state *tsp)
Estimate the skew based on current state.
int timeutil_sync_local_from_ref(const struct timeutil_sync_state *tsp, uint64_t ref, int64_t *localp)
Interpolate a local timescale instant from a reference instant.
__UINT32_TYPE__ uint32_t
Definition stdint.h:90
__INT32_TYPE__ int32_t
Definition stdint.h:74
__UINT64_TYPE__ uint64_t
Definition stdint.h:91
__INT64_TYPE__ int64_t
Definition stdint.h:75
Immutable state for synchronizing two clocks.
Definition timeutil.h:86
uint32_t ref_Hz
The nominal instance counter rate in Hz.
Definition timeutil.h:94
uint32_t local_Hz
The nominal local counter rate in Hz.
Definition timeutil.h:107
Representation of an instant in two time scales.
Definition timeutil.h:117
uint64_t ref
An instant in the reference time scale.
Definition timeutil.h:123
uint64_t local
The corresponding instance in the local time scale.
Definition timeutil.h:129
State required to convert instants between time scales.
Definition timeutil.h:142
const struct timeutil_sync_config * cfg
Pointer to reference and local rate information.
Definition timeutil.h:144
float skew
The scale factor used to correct for clock skew.
Definition timeutil.h:170
struct timeutil_sync_instant latest
The most recent instant in both time scales.
Definition timeutil.h:153
struct timeutil_sync_instant base
The base instant in both time scales.
Definition timeutil.h:147
Definition time.h:24