GLAST / LAT > DAQ and FSW > FSW > Doxygen Index> LSE / V2-1-0 > lsew / linux-gcc
#include <time.h>
#include <LSE/LSE_time.h>
#include <LSE_time.ih>
Classes | |
struct | _LSE_timeContext |
Holds the time context information. More... | |
Defines | |
#define | SA_OFFSET 0x3a4fc880 |
Offset between the UNIX and Spectrum-Astro time epochs. | |
Typedefs | |
typedef struct _LSE_timeContext | LSE_timeContext |
Typedef for struct _LSE_timeContext. | |
Functions | |
static void | lse_construct (LSE_timeFlagSpec *tfs) |
Sets the time specification sequence. | |
static void | lse_set (unsigned int seconds, unsigned int flags, unsigned int frequency) |
Sets the initial time, flags word and frequency. | |
static void | lse_elapsedSet (unsigned int elapsed_reg, unsigned int pps_reg) |
Uses the elapsed clock tick and 1-PPS GEM registers to calculate the elapsed time since the last 1-PPS strobe. | |
static unsigned long long int | lse_timestampGet (void) |
Returns the time since the Spectrum-Astro epoch. | |
static unsigned int | lse_timetoneGet (unsigned int pps, unsigned int *secs, unsigned int *flags) |
Fills in the seconds and flag values of a simulated timetone message corresponding to the specified 1-PPS strobe value. | |
static unsigned int | lse_timetonesGet (unsigned int cur_pps, unsigned int *cur_secs, unsigned int *cur_flags, unsigned int *prv_secs, unsigned int *prv_flags, unsigned int *prv_pps) |
Fills in the timetone message corresponding to cur_pps and the most recent timetone message occuring prior to cur_pps. | |
void | LSE_timeConstruct (const LSE_timeServices *services, void *prm) |
Constructs/initializes the LSE time emulation services. | |
void | LSE_timeSet (unsigned int seconds, unsigned int flags, unsigned int frequency) |
Sets the initial time and frequency. | |
unsigned int | LSE_timeSecsGet (void) |
Get the current number of elapsed seconds since the Spectrum-Astro Epoch. | |
unsigned long long int | LSE_timeTimestampGet (void) |
Get the current timestamp, i.e. the number of elapsed seconds and micro-seconds since the Spectrum-Astro Epoch. | |
unsigned int | LSE_timeOffset (void) |
Gets the offset from standard UNIX time to Spectrum Astro time. | |
static __inline unsigned int | complete_flags (unsigned int new_flags, unsigned int prv_flags) |
If the new flag value is not error-free (IS_SOURCE_GPS) modifies it to update the error count. | |
Variables | |
LSE_timeServices | LseTimeServices |
The list of time services needed when filling in such information in the datagrams. | |
static LSE_timeContext | LseTimeContext = { 0, 0, 0, 0, 0, 0, 0, -1, 0, 0} |
Captures the static context needed by the default implementation. |
CVS $Id: LSE_time.c,v 1.9 2011/03/26 17:35:24 russell Exp $
unsigned int complete_flags | ( | unsigned int | new_flags, | |
unsigned int | prv_flags | |||
) | [static] |
If the new flag value is not error-free (IS_SOURCE_GPS) modifies it to update the error count.
new_flags | The new flag value | |
prv_flags | The previous flag value |
References LSE_CTXTIMFLAGS_M_CNT_GPS_NO_LOCK, LSE_CTXTIMFLAGS_M_IS_SOURCE_GPS, and LSE_CTXTIMFLAGS_V_CNT_GPS_NO_LOCK.
Referenced by lse_elapsedSet().
static void lse_construct | ( | LSE_timeFlagSpec * | tfs | ) | [static] |
Sets the time specification sequence.
tfs | Pointer to the time flag specification sequence. Maybe NULL, in which case, the flag word is always 0. |
References _LSE_timeFlagSpec::cnt, _LSE_timeContext::cur_flags, _LSE_timeFlagSpec::flags, _LSE_timeContext::tfs, and _LSE_timeContext::tfs_cnt.
static void lse_elapsedSet | ( | unsigned int | elapsed_reg, | |
unsigned int | pps_reg | |||
) | [static] |
Uses the elapsed clock tick and 1-PPS GEM registers to calculate the elapsed time since the last 1-PPS strobe.
elapsed_reg | The GEM's elapsed tick register | |
pps_reg | The GEM's 1-PPS strobe register |
References _LSE_ppsReg::bf, _LSE_timeFlagSpec::cnt, complete_flags(), _LSE_timeContext::cur_flags, _LSE_timeFlagSpec::flags, _LSE_timeContext::frequency, _LSE_ppsReg_bf::idx, _LSE_timeFlagSpec::nxt, _LSE_timeContext::prv_flags, _LSE_timeContext::prv_idx, _LSE_timeContext::prv_ticks, _LSE_timeContext::tfs, _LSE_timeContext::tfs_cnt, _LSE_timeContext::ticks, _LSE_ppsReg::ui, and _LSE_ppsReg_bf::val.
static void lse_set | ( | unsigned int | seconds, | |
unsigned int | flags, | |||
unsigned int | frequency | |||
) | [static] |
Sets the initial time, flags word and frequency.
seconds | The initial time, specified in the number of seconds since the Spectrum-Astro epoch. If specified as 0, then the time is not adjusted. If specified as -1, then the default (current time) is used. | |
flags | The initial value of the flags word. There is no default. A reasonable value is 0, i.e. no errors. | |
frequency | The frequency, in Hertz. If specified as 0, then the frequency will not be changed. If specified as -1, then the default (20MHz) is used. |
References _LSE_timeContext::cur_flags, _LSE_timeFlagSpec::flags, _LSE_timeContext::frequency, _LSE_timeContext::init, _LSE_timeContext::prv_flags, SA_OFFSET, _LSE_timeContext::seconds, and _LSE_timeContext::tfs.
void LSE_timeConstruct | ( | const LSE_timeServices * | services, | |
void * | prm | |||
) |
Constructs/initializes the LSE time emulation services.
services | A pointer to the virtual functions. If NULL, the standard services are used. | |
prm | Arbitrary user parameter passed to the constructor |
References _LSE_timeServices::construct.
unsigned int LSE_timeOffset | ( | void | ) |
Gets the offset from standard UNIX time to Spectrum Astro time.
References SA_OFFSET.
unsigned int LSE_timeSecsGet | ( | void | ) |
Get the current number of elapsed seconds since the Spectrum-Astro Epoch.
References _LSE_timeServices::timestampGet.
void LSE_timeSet | ( | unsigned int | seconds, | |
unsigned int | flags, | |||
unsigned int | frequency | |||
) |
Sets the initial time and frequency.
seconds | The initial time, specified in the number of seconds since the Spectrum-Astro epoch. If specified as 0, then the time is not adjusted | |
flags | The initial value of the timetone message's flag word. There is no default value, but bit 16 (source = GPS) would be a good choice as a default (no errors). | |
frequency | The frequency, in Hertz. If specified as 0, then the frequency will not be changed |
References _LSE_timeServices::set.
static unsigned long long int lse_timestampGet | ( | void | ) | [static] |
Returns the time since the Spectrum-Astro epoch.
References _LSE_time::f, _LSE_timeContext::frequency, _LSE_timeContext::seconds, _LSE_timeContext::ticks, and _LSE_time::ull.
unsigned long long int LSE_timeTimestampGet | ( | void | ) |
Get the current timestamp, i.e. the number of elapsed seconds and micro-seconds since the Spectrum-Astro Epoch.
References _LSE_timeServices::timestampGet.
static unsigned int lse_timetoneGet | ( | unsigned int | pps, | |
unsigned int * | secs, | |||
unsigned int * | flags | |||
) | [static] |
Fills in the seconds and flag values of a simulated timetone message corresponding to the specified 1-PPS strobe value.
pps | The value of 1-PPS strobe register to use as a key | |
secs | Filled in with the elapsed time, in seconds from the Spectrum-Astro epoch corresponding to the pps | |
flags | The flag word, currently set to 0, i.e. no errors |
References _LSE_ppsReg::bf, _LSE_timeContext::cur_flags, _LSE_ppsReg_bf::idx, _LSE_timeContext::init, LSE_CTXTIMFLAGS_M_IS_SOURCE_GPS, _LSE_timeContext::prv_flags, _LSE_timeContext::prv_idx, _LSE_timeContext::prv_ticks, _LSE_timeContext::seconds, _LSE_ppsReg::ui, and _LSE_ppsReg_bf::val.
Referenced by lse_timetonesGet().
static unsigned int lse_timetonesGet | ( | unsigned int | cur_pps, | |
unsigned int * | cur_secs, | |||
unsigned int * | cur_flags, | |||
unsigned int * | prv_secs, | |||
unsigned int * | prv_flags, | |||
unsigned int * | prv_pps | |||
) | [static] |
Fills in the timetone message corresponding to cur_pps and the most recent timetone message occuring prior to cur_pps.
cur_pps | The value of the GEM's 1-PPS register to use as a key in locating the timetone messages | |
cur_secs | Filled in with the time since the Spectrum-Astro epoch corresponding the current timetone message | |
cur_flags | Filled in with status flags/values (see THS) corresponding the current timetone message | |
prv_secs | Filled in with the time since the Spectrum-Astro epoch corresponding the previous timetone message | |
prv_flags | Filled in with status flags/values (see THS) corresponding the previous timetone message | |
prv_pps | Filled in with the value of GEM's 1-PPS register corresponding the previous timetone message |
References _LSE_ppsReg::bf, _LSE_timeContext::frequency, _LSE_ppsReg_bf::idx, lse_timetoneGet(), _LSE_timeContext::prv_flags, _LSE_ppsReg::ui, and _LSE_ppsReg_bf::val.
Initial value:
{ (LSE_timeServicesConstruct)lse_construct, lse_set, lse_elapsedSet, lse_timestampGet, lse_timetoneGet, lse_timetonesGet }