Contents
KnGetMSecSinceStart()
This function is declared in the coresrv/time/time_api.h
file.
rtl_size_t KnGetMSecSinceStart(void);
Returns the number of milliseconds that have elapsed since the start of the system.
Page topKnGetRtcTime()
This function is declared in the coresrv/time/time_api.h
file.
Retcode KnGetRtcTime(RtlRtcTime *rt);
This function writes the POSIX system time (in RTC format) to the rt
parameter.
If successful, returns rcOk, or returns rcFail if an error occurs.
The RTC time format is defined by the RtlRtcTime
structure (declared in the rtl/rtc.h
file.):
typedef struct {
rtl_uint32_t msec; /**< milliseconds */
rtl_uint32_t sec; /**< second (0..59) */
rtl_uint32_t min; /**< minute (0..59) */
rtl_uint32_t hour; /**< hour (0..23) */
rtl_uint32_t mday; /**< day (1..31) */
rtl_uint32_t month; /**< month (0..11) */
rtl_int32_t year; /**< year - 1900 */
rtl_uint32_t wday; /**< week day (0..6) */
} RtlRtcTime;
KnGetSystemTime()
This function is declared in the coresrv/time/time_api.h
file.
Retcode KnGetSystemTime(RtlTimeSpec *time);
This function lets you get the system time.
Output parameter time
contains the POSIX system time in RtlTimeSpec
format.
KnSetSystemTime()
This function is declared in the coresrv/time/time_api.h
file.
Retcode KnSetSystemTime(RtlTimeSpec *time);
This function lets you set the system time.
The time
parameter must contain the POSIX time in RtlTimeSpec
format.
It is not recommended to call the KnSetSystemTime()
function in the interrupt handler thread.
KnGetSystemTimeRes()
This function is declared in the coresrv/time/time_api.h
file.
Retcode KnGetSystemTimeRes(RtlTimeSpec *res);
This function lets you get the resolution of the system time source.
Output parameter res
contains the resolution in RtlTimeSpec
format.
KnGetUpTime()
This function is declared in the coresrv/time/time_api.h
file.
Retcode KnGetUpTime(RtlTimeSpec *time);
This function lets you get the time that has elapsed since the start of the system.
Output parameter time
contains the time in RtlTimeSpec
format.
KnGetUpTimeRes()
This function is declared in the coresrv/time/time_api.h
file.
Retcode KnGetUpTimeRes(RtlTimeSpec *res);
This function receives the resolution of the source of time whose value can be obtained via KnGetUpTime()
.
Output parameter res
contains the resolution in RtlTimeSpec
format.
RtlTimeSpec
The timespec time format is defined by the RtlTimeSpec
structure (declared in the rtl/rtc.h
file).
typedef struct {
rtl_time_t sec; /**< integer number of seconds that have elapsed since the start of the Unix epoch
* or another defined point in time */
rtl_nsecs_t nsec; /**< adjustment in nanoseconds (number of nanoseconds
* that have elapsed since the point in time defined by the number of seconds*/
} RtlTimeSpec;