|
Infuse-IoT SDK API 0.0.1
A Scalable Open Source RTOS
|
epoch_time API More...
Data Structures | |
| struct | epoch_time_cb |
| epoch time event callback structure. More... | |
Macros | |
| #define | SECONDS_PER_MINUTE (60) |
| #define | SECONDS_PER_HOUR (60 * SECONDS_PER_MINUTE) |
| #define | SECONDS_PER_DAY (24 * SECONDS_PER_HOUR) |
| #define | SECONDS_PER_WEEK (7 * SECONDS_PER_DAY) |
| #define | INFUSE_EPOCH_TIME_GPS_UNIX_OFFSET_SECONDS_LEAP 18 |
| Current offset between GPS and UNIX timestamps. | |
| #define | INFUSE_EPOCH_TIME_GPS_UNIX_OFFSET_SECONDS_BASE 315964800 |
| Unix time at the instant of the GPS epoch. | |
| #define | INFUSE_EPOCH_TIME_TICKS_PER_SEC (UINT16_MAX + 1) |
| Base tick rate of Infuse-IoT epoch time. | |
Enumerations | |
| enum | epoch_time_source { TIME_SOURCE_NONE = 0 , TIME_SOURCE_GNSS , TIME_SOURCE_NTP , TIME_SOURCE_RPC , TIME_SOURCE_INVALID , TIME_SOURCE_RECOVERED = 0x80 } |
Functions | |
| void | epoch_time_register_callback (struct epoch_time_cb *cb) |
| Register to be notified of epoch time events. | |
| static bool | epoch_time_trusted_source (enum epoch_time_source source, bool recovered_ok) |
| Determine whether a given time source should be trusted. | |
| static uint64_t | epoch_time_seconds (uint64_t epoch_time) |
| Extracts epoch seconds from a complete epoch time. | |
| static uint16_t | epoch_time_subseconds (uint64_t epoch_time) |
| Extracts epoch subseconds from a complete epoch time. | |
| static uint16_t | epoch_time_milliseconds (uint64_t epoch_time) |
| Extracts epoch milliseconds from a complete epoch time. | |
| static uint64_t | epoch_time_from (uint64_t seconds, uint16_t subseconds) |
| Convert seconds and subseconds to complete epoch time. | |
| static uint64_t | epoch_time_from_gps (uint16_t week, uint32_t week_seconds, uint16_t subseconds) |
| Convert GPS time format to complete epoch time. | |
| static uint32_t | unix_time_from_epoch (uint64_t epoch_time) |
| Convert epoch time to current unix time. | |
| static uint64_t | epoch_time_from_unix (uint32_t unix_time, uint16_t subseconds) |
| Convert unix time to current epoch time. | |
| uint64_t | ticks_from_epoch_time (uint64_t epoch_time) |
| Get a tick count associated with a epoch time. | |
| uint64_t | epoch_time_from_ticks (uint64_t ticks) |
| Get the epoch time associated with a local uptime. | |
| uint32_t | epoch_period_from_array_ticks (uint64_t array_ticks, uint16_t array_num) |
| Get the epoch time period associated with an array. | |
| static uint64_t | epoch_time_now (void) |
| Get the current epoch time. | |
| void | epoch_time_unix_calendar (uint64_t epoch_time, struct tm *calendar) |
| Convert a epoch time to a unix time calendar. | |
| enum epoch_time_source | epoch_time_get_source (void) |
| Get the current source of epoch time knowledge. | |
| int | epoch_time_set_reference (enum epoch_time_source source, struct timeutil_sync_instant *reference) |
| Set the local to epoch time reference instant. | |
| uint32_t | epoch_time_reference_age (void) |
| Query how many seconds ago the reference instant was set. | |
| int | epoch_time_reference_shift (const struct timeutil_sync_instant *ref_a, const struct timeutil_sync_instant *ref_b, int64_t *epoch_shift) |
| Determine the epoch time shift due to moving from ref_a to ref_b. | |
epoch_time API
| #define INFUSE_EPOCH_TIME_GPS_UNIX_OFFSET_SECONDS_BASE 315964800 |
#include <infuse/time/epoch.h>
Unix time at the instant of the GPS epoch.
| #define INFUSE_EPOCH_TIME_GPS_UNIX_OFFSET_SECONDS_LEAP 18 |
#include <infuse/time/epoch.h>
Current offset between GPS and UNIX timestamps.
| #define INFUSE_EPOCH_TIME_TICKS_PER_SEC (UINT16_MAX + 1) |
#include <infuse/time/epoch.h>
Base tick rate of Infuse-IoT epoch time.
| #define SECONDS_PER_DAY (24 * SECONDS_PER_HOUR) |
#include <infuse/time/epoch.h>
| #define SECONDS_PER_HOUR (60 * SECONDS_PER_MINUTE) |
#include <infuse/time/epoch.h>
| #define SECONDS_PER_MINUTE (60) |
#include <infuse/time/epoch.h>
| #define SECONDS_PER_WEEK (7 * SECONDS_PER_DAY) |
#include <infuse/time/epoch.h>
| enum epoch_time_source |
#include <infuse/time/epoch.h>
| Enumerator | |
|---|---|
| TIME_SOURCE_NONE | |
| TIME_SOURCE_GNSS | |
| TIME_SOURCE_NTP | |
| TIME_SOURCE_RPC | |
| TIME_SOURCE_INVALID | |
| TIME_SOURCE_RECOVERED | |
| uint32_t epoch_period_from_array_ticks | ( | uint64_t | array_ticks, |
| uint16_t | array_num ) |
#include <infuse/time/epoch.h>
Get the epoch time period associated with an array.
| array_ticks | Ticks between first and last sample in array |
| array_num | Number of samples in array |
|
inlinestatic |
#include <infuse/time/epoch.h>
Convert seconds and subseconds to complete epoch time.
| seconds | Number of seconds since GPS epoch |
| subseconds | Fractional component of time since GPS epoch |
| epoch_time | Complete epoch time |
|
inlinestatic |
#include <infuse/time/epoch.h>
Convert GPS time format to complete epoch time.
| week | GPS week counter |
| week_seconds | GPS seconds of week |
| subseconds | Fractional component of time since GPS epoch |
| epoch_time | Complete epoch time |
| uint64_t epoch_time_from_ticks | ( | uint64_t | ticks | ) |
#include <infuse/time/epoch.h>
Get the epoch time associated with a local uptime.
| ticks | Kernel tick count |
|
inlinestatic |
#include <infuse/time/epoch.h>
Convert unix time to current epoch time.
| unix_time | Current unix time |
| subseconds | Fractional component of unix time |
| epoch_time | Complete epoch time |
| enum epoch_time_source epoch_time_get_source | ( | void | ) |
#include <infuse/time/epoch.h>
Get the current source of epoch time knowledge.
|
inlinestatic |
#include <infuse/time/epoch.h>
Extracts epoch milliseconds from a complete epoch time.
| epoch_time | Complete epoch time |
| milliseconds | Fractional component of time since GPS epoch |
|
inlinestatic |
#include <infuse/time/epoch.h>
Get the current epoch time.
| epoch_time | Complete epoch time |
| uint32_t epoch_time_reference_age | ( | void | ) |
#include <infuse/time/epoch.h>
Query how many seconds ago the reference instant was set.
| UINT32_MAX | if not yet set |
| seconds | since reference instant was set |
| int epoch_time_reference_shift | ( | const struct timeutil_sync_instant * | ref_a, |
| const struct timeutil_sync_instant * | ref_b, | ||
| int64_t * | epoch_shift ) |
#include <infuse/time/epoch.h>
Determine the epoch time shift due to moving from ref_a to ref_b.
| ref_a | Original reference point |
| ref_b | Updated reference point |
| epoch_shift | Time shift from updating reference points |
| 0 | On success |
| -EINVAL | If either sync instant is invalid |
| void epoch_time_register_callback | ( | struct epoch_time_cb * | cb | ) |
#include <infuse/time/epoch.h>
Register to be notified of epoch time events.
| cb | Callback struct to register |
|
inlinestatic |
#include <infuse/time/epoch.h>
Extracts epoch seconds from a complete epoch time.
| epoch_time | Complete epoch time |
| seconds | Number of seconds since GPS epoch |
| int epoch_time_set_reference | ( | enum epoch_time_source | source, |
| struct timeutil_sync_instant * | reference ) |
#include <infuse/time/epoch.h>
Set the local to epoch time reference instant.
| source | Source of the reference instant |
| reference | Same instant in local and epoch time bases |
| 0 | on success |
| -EINVAL | if reference instant is invalid |
|
inlinestatic |
#include <infuse/time/epoch.h>
Extracts epoch subseconds from a complete epoch time.
| epoch_time | Complete epoch time |
| subseconds | Fractional component of time since GPS epoch |
|
inlinestatic |
#include <infuse/time/epoch.h>
Determine whether a given time source should be trusted.
| source | Time source |
| recovered_ok | Should a time source recovered across a reboot be trusted |
| void epoch_time_unix_calendar | ( | uint64_t | epoch_time, |
| struct tm * | calendar ) |
#include <infuse/time/epoch.h>
Convert a epoch time to a unix time calendar.
| epoch_time | Complete epoch time |
| calendar | Output calendar |
| uint64_t ticks_from_epoch_time | ( | uint64_t | epoch_time | ) |
#include <infuse/time/epoch.h>
Get a tick count associated with a epoch time.
| epoch_time | epoch time |
|
inlinestatic |
#include <infuse/time/epoch.h>
Convert epoch time to current unix time.
| epoch_time | Complete epoch time |
| unix_time | Current unix time |