Zephyr API Documentation  3.6.99
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
50
62time_t timeutil_timegm(const struct tm *tm);
63
92
105};
106
121
127};
128
142
145
151
167 float skew;
168};
169
188 const struct timeutil_sync_instant *inst);
189
215 const struct timeutil_sync_instant *base);
216
231
255 uint64_t local, uint64_t *refp);
256
279 uint64_t ref, int64_t *localp);
280
300
301#ifdef __cplusplus
302}
303#endif
304
309#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:83
uint32_t ref_Hz
The nominal instance counter rate in Hz.
Definition: timeutil.h:91
uint32_t local_Hz
The nominal local counter rate in Hz.
Definition: timeutil.h:104
Representation of an instant in two time scales.
Definition: timeutil.h:114
uint64_t ref
An instant in the reference time scale.
Definition: timeutil.h:120
uint64_t local
The corresponding instance in the local time scale.
Definition: timeutil.h:126
State required to convert instants between time scales.
Definition: timeutil.h:139
const struct timeutil_sync_config * cfg
Pointer to reference and local rate information.
Definition: timeutil.h:141
float skew
The scale factor used to correct for clock skew.
Definition: timeutil.h:167
struct timeutil_sync_instant latest
The most recent instant in both time scales.
Definition: timeutil.h:150
struct timeutil_sync_instant base
The base instant in both time scales.
Definition: timeutil.h:144
Definition: time.h:24