//  These routines keep track of time for the logger.  This allows us to
//	correct for the TT8's inability to set the ticks variable (fractions
//	of a second) to zero.
//
//	set_logger_time ():
//		Sets the logger time immediately.  Tracks the fractions of a
//		second so that this routine effectively sets the fraction to 0.
//
//	get_logger_time ():
//		Returns the current time using the standard TT8 time structure
//		(which includes fractions of a second)
//
//	char* get_logger_time_string (time_tt t)
//		Returns a pointer to a char array with the ASCII string for the
//		time passed
//
//	sync_set_logger_time ():
//		Sets the logger time on the falling edge of a pulse which is
//		applied to TPU15.  Tracks fractions as set_logger_time did.
//
//	sync_get_logger_time ():
//		Gets the logger time on the falling edge of a pulse which is
//		applied to TPU15.  Tracks fractions as set_logger_time did.
//
//  even if this file is included multiple times, we want it compiled only once
#ifndef			LTIME_DEFINED
#define			LTIME_DEFINED	0x7F07

#include		<tt8lib.h>
#include        <time.h>

//  These variables provide a convenient way to set the time to
//  either the earliest of the latest times which can possibly
//  be represented
static time_tt LATEST_LOGGER_TIME = {0xFFFFFFFF, 0};
static time_tt EARLIEST_LOGGER_TIME = {0x0, 0x0};

void logger_time_power_on_init (void);
time_tt logger_time_get_time (void);
void logger_time_set_time (struct tm* tp);
void logger_time_sync_set_time (struct tm* tp);
time_tt logger_time_sync_get_time (void);

char* logger_time_get_string (time_tt* t);
int logger_time_query_time (struct tm* tp);
int logger_time_verify_set (void);

long logger_time_get_tick_offset (void);
void logger_time_set_tick_offset (long);

#endif
