CTS-SAT-1-OBC-Firmware
Loading...
Searching...
No Matches
timekeeping.h File Reference
#include <stdint.h>
#include <stdlib.h>
Include dependency graph for timekeeping.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define TIME_EPOCH_DECIMAL_STRING_LEN   13
 

Enumerations

enum  TIME_sync_source_enum_t {
  TIME_SYNC_SOURCE_NONE = 0 , TIME_SYNC_SOURCE_GNSS , TIME_SYNC_SOURCE_TELECOMMAND_ABSOLUTE , TIME_SYNC_SOURCE_TELECOMMAND_CORRECTION ,
  TIME_SYNC_SOURCE_EPS_RTC
}
 

Functions

uint32_t TIME_get_current_system_uptime_ms (void)
 
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.
 
uint64_t TIME_get_current_unix_epoch_time_ms ()
 Returns the current unix timestamp, in milliseconds.
 
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.
 
void TIME_format_timestamp_str (char dest_str[], size_t dest_str_size, uint32_t uptime_ms, TIME_sync_source_enum_t sync_source)
 
void TIME_get_current_timestamp_str (char *dest_str, size_t dest_str_size)
 Returns a computer-friendly timestamp string.
 
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)
 
void TIME_get_current_utc_datetime_str (char *dest_str, size_t dest_str_size)
 
char TIME_sync_source_enum_to_letter_char (TIME_sync_source_enum_t source)
 

Variables

uint64_t TIME_unix_epoch_time_at_last_time_resync_ms
 
uint32_t TIME_system_uptime_at_last_time_resync_ms
 
TIME_sync_source_enum_t TIME_last_synchronization_source
 

Macro Definition Documentation

◆ TIME_EPOCH_DECIMAL_STRING_LEN

#define TIME_EPOCH_DECIMAL_STRING_LEN   13

Enumeration Type Documentation

◆ TIME_sync_source_enum_t

Enumerator
TIME_SYNC_SOURCE_NONE 
TIME_SYNC_SOURCE_GNSS 
TIME_SYNC_SOURCE_TELECOMMAND_ABSOLUTE 
TIME_SYNC_SOURCE_TELECOMMAND_CORRECTION 
TIME_SYNC_SOURCE_EPS_RTC 

Function Documentation

◆ TIME_convert_uptime_to_unix_epoch_time_ms()

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.

Parameters
uptime_msSystem uptime in ms, as returned by HAL_GetTick().
Returns
The unix epoch time in ms (ms since 1970-01-01).
Note
This function still works fine even if you store the uptime, resync the system time, and then call this function.
Here is the caller graph for this function:

◆ TIME_format_timestamp_str()

void TIME_format_timestamp_str ( char dest_str[],
size_t dest_str_size,
uint32_t uptime_ms,
TIME_sync_source_enum_t sync_source )
Here is the call graph for this function:
Here is the caller graph for this function:

◆ TIME_format_utc_datetime_str()

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 )
Here is the call graph for this function:
Here is the caller graph for this function:

◆ TIME_get_current_system_uptime_ms()

uint32_t TIME_get_current_system_uptime_ms ( void )
Here is the caller graph for this function:

◆ TIME_get_current_timestamp_str()

void TIME_get_current_timestamp_str ( char * dest_str,
size_t dest_str_size )

Returns a computer-friendly timestamp string.

Parameters
dest_str- Pointer to buffer that stores the log string
dest_str_size- Maximum length of dest_str buffer

The string identifies the timestamp of the last time synchronization, the synchronization source (N - none; G - GNSS/GPS; T - telecommand), and the time passed in ms since the last synchronization. Added together, the two numbers represent the current unix timestamp in ms. Example: "1719169299720+0000042000_N"

Here is the call graph for this function:
Here is the caller graph for this function:

◆ TIME_get_current_unix_epoch_time_ms()

uint64_t TIME_get_current_unix_epoch_time_ms ( )

Returns the current unix timestamp, in milliseconds.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ TIME_get_current_utc_datetime_str()

void TIME_get_current_utc_datetime_str ( char * dest_str,
size_t dest_str_size )
Here is the call graph for this function:
Here is the caller graph for this function:

◆ TIME_set_current_unix_epoch_time_ms()

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.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ TIME_sync_source_enum_to_letter_char()

char TIME_sync_source_enum_to_letter_char ( TIME_sync_source_enum_t source)
Here is the caller graph for this function:

Variable Documentation

◆ TIME_last_synchronization_source

TIME_sync_source_enum_t TIME_last_synchronization_source
extern

◆ TIME_system_uptime_at_last_time_resync_ms

uint32_t TIME_system_uptime_at_last_time_resync_ms
extern

◆ TIME_unix_epoch_time_at_last_time_resync_ms

uint64_t TIME_unix_epoch_time_at_last_time_resync_ms
extern