Clk_TS_ToTS_NTP
Convert Clock timestamp to NTP timestamp.
Files
clk.h/clk.c
Prototype
CPU_BOOLEAN Clk_TS_ToTS_NTP (CLK_TS_SEC ts_sec, CLK_TS_SEC *p_ts_ntp_sec);
Arguments
ts_sec
Timestamp to convert (in seconds, UTC+00).
p_ts_ntp_sec
Pointer to variable that will receive the NTP timestamp:
In seconds UTC+00, if no errors;CLK_TS_SEC_NONE
, otherwise.
Returned Values
DEF_OK
, if timestamp successfully converted.
DEF_FAIL
, otherwise.
Required Configuration
Available only if CLK_CFG_NTP_EN
is DEF_ENABLED
in clk_cfg.h
(see Module Configuration).
Notes / Warnings
Returned timestamp does not include any time zone offset. Thus any local time zone offset should be applied before or after calling Clk_TS_ToTS_NTP()
.
Only years supported by Clock and NTP can be converted, thus the timestamp date must be greater than or equal to CLK_EPOCH_YR_START
and less than CLK_NTP_EPOCH_YR_END
.
Example Usage
Listing - Clk_TS_ToTS_NTP() Example Usage
CLK_TS_SEC ts_sec; CLK_TS_SEC ts_ntp_sec; CPU_BOOLEAN valid; ts_sec = 0; valid = Clk_TS_ToTS_NTP(ts_sec, &ts_ntp_sec); if (valid == DEF_OK) { printf("Timestamp = %u", ts_ntp_sec); } else { printf("Convert timestamp error\n\r"); }