CTS-SAT-1-OBC-Firmware
Loading...
Searching...
No Matches
timekeeping.h
Go to the documentation of this file.
1#ifndef INCLUDE_GUARD__TIMEKEEPING_H_
2#define INCLUDE_GUARD__TIMEKEEPING_H_
3
4#include <stdint.h>
5#include <stdlib.h>
6
7#define TIME_EPOCH_DECIMAL_STRING_LEN 13
8
16
18void TIME_set_current_unix_epoch_time_ms(uint64_t current_unix_epoch_time_ms, TIME_sync_source_enum_t source);
20uint64_t TIME_convert_uptime_to_unix_epoch_time_ms(uint32_t uptime_ms);
21
23 char dest_str[], size_t dest_str_size,
24 uint32_t uptime_ms, TIME_sync_source_enum_t sync_source
25);
26void TIME_get_current_timestamp_str(char *dest_str, size_t dest_str_size);
27
29 char *dest_str, size_t dest_str_size,
30 uint64_t timestamp_ms, TIME_sync_source_enum_t sync_source
31);
32void TIME_get_current_utc_datetime_str(char *dest_str, size_t dest_str_size);
33
35
39
40#endif // INCLUDE_GUARD__TIMEKEEPING_H_
char TIME_sync_source_enum_to_letter_char(TIME_sync_source_enum_t source)
Definition timekeeping.c:216
TIME_sync_source_enum_t TIME_last_synchronization_source
Definition timekeeping.c:17
void TIME_format_timestamp_str(char dest_str[], size_t dest_str_size, uint32_t uptime_ms, TIME_sync_source_enum_t sync_source)
Definition timekeeping.c:105
uint32_t TIME_get_current_system_uptime_ms(void)
Definition timekeeping.c:19
void TIME_format_utc_datetime_str(char *dest_str, size_t dest_str_size, uint64_t timestamp_ms, TIME_sync_source_enum_t sync_source)
Definition timekeeping.c:164
uint64_t TIME_get_current_unix_epoch_time_ms()
Returns the current unix timestamp, in milliseconds.
Definition timekeeping.c:91
void TIME_set_current_unix_epoch_time_ms(uint64_t current_unix_epoch_time_ms, TIME_sync_source_enum_t source)
Use this function in a telecommand, or upon receiving a time update from the GNSS.
Definition timekeeping.c:24
TIME_sync_source_enum_t
Definition timekeeping.h:9
@ TIME_SYNC_SOURCE_NONE
Definition timekeeping.h:10
@ TIME_SYNC_SOURCE_TELECOMMAND_CORRECTION
Definition timekeeping.h:13
@ TIME_SYNC_SOURCE_EPS_RTC
Definition timekeeping.h:14
@ TIME_SYNC_SOURCE_TELECOMMAND_ABSOLUTE
Definition timekeeping.h:12
@ TIME_SYNC_SOURCE_GNSS
Definition timekeeping.h:11
void TIME_get_current_timestamp_str(char *dest_str, size_t dest_str_size)
Returns a computer-friendly timestamp string.
Definition timekeeping.c:136
uint64_t TIME_convert_uptime_to_unix_epoch_time_ms(uint32_t uptime_ms)
Convert the system uptime to a unix epoch time in ms.
Definition timekeeping.c:86
uint64_t TIME_unix_epoch_time_at_last_time_resync_ms
Definition timekeeping.c:12
uint32_t TIME_system_uptime_at_last_time_resync_ms
Definition timekeeping.c:16
void TIME_get_current_utc_datetime_str(char *dest_str, size_t dest_str_size)
Definition timekeeping.c:208