Zephyr API Documentation  2.7.0-rc2
A Scalable Open Source RTOS
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
49
61time_t timeutil_timegm(const struct tm *tm);
62
91
104};
105
120
126};
127
141
144
150
166 float skew;
167};
168
187 const struct timeutil_sync_instant *inst);
188
214 const struct timeutil_sync_instant *base);
215
230
254 uint64_t local, uint64_t *refp);
255
278 uint64_t ref, int64_t *localp);
279
299
300#ifdef __cplusplus
301}
302#endif
303
308#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:60
__INT32_TYPE__ int32_t
Definition: stdint.h:44
__UINT64_TYPE__ uint64_t
Definition: stdint.h:61
__INT64_TYPE__ int64_t
Definition: stdint.h:45
Immutable state for synchronizing two clocks.
Definition: timeutil.h:82
uint32_t ref_Hz
Definition: timeutil.h:90
uint32_t local_Hz
Definition: timeutil.h:103
Representation of an instant in two time scales.
Definition: timeutil.h:113
uint64_t ref
Definition: timeutil.h:119
uint64_t local
Definition: timeutil.h:125
State required to convert instants between time scales.
Definition: timeutil.h:138
const struct timeutil_sync_config * cfg
Definition: timeutil.h:140
float skew
Definition: timeutil.h:166
struct timeutil_sync_instant latest
Definition: timeutil.h:149
struct timeutil_sync_instant base
Definition: timeutil.h:143
Definition: time.h:24