GLAST/LAT >
DAQ and FSW >
FSW >
Doxygen Index >
THS / V1-0-5
Constituent: ths     Tag: sun-gcc
Interface Data Structures File List Data Fields Globals
THS_gem.c File Reference
Time Hack Services.
More...
#include "PBS/PBS.h"
#include "PBS/TASK.h"
#include "PBS/TMR.h"
#include "PBI/Endianness.h"
#include "LCBD/LCBD.h"
#include "LCBD/LCBD_pci.h"
#include "LEM/defs.h"
#include "LEM/decode.h"
#include "LEM/encode.h"
#include "LEM/encode_structs.h"
#include "LEM/cli.h"
#include "MSG/MSG_pubdefs.h"
#include "THS/THS_msgs.h"
#include "THS_prvdefs.h"
#include <stdio.h>
Include dependency graph for THS_gem.c:
|
Functions |
WCT_time | THS_gemAbsTimeEvent (int gemStrobeIn, int gemClk) |
| Calculate absolute time for event from strobe and clk provided with event (20MHz clk).
|
unsigned int | THS_gemInit (int siu) |
| Inits the TimeHackService module.
|
unsigned int | THS_gemWait () |
| Start the TimeHackService module.
|
unsigned int | THS_gemGetTableInfo (int count, unsigned int *gemStrobe, LSU_factors *Kgem) |
| get info from hack table
|
unsigned int | THS_gemCalcClkDiff (unsigned int clk, unsigned int prevClk) |
| calculate diff between clks assuming 25 bit clock
|
void | THS_gemIsr (unsigned int absTimeSec, int newTimetone) |
| interrupt routine for gem specfic time hack
|
unsigned int | THS_gemSetWarning (unsigned int expectedClkHz, unsigned int expectedDeltaClkHz) |
| Set range for gem clock warning messages.
|
void | THS_gemSetTable (WCT_time absTimeSec, unsigned int gemStrobeIn, LSU_factors Kgem) |
| Set a single entry in the gem hack table.
|
Detailed Description
Time Hack Services.
- Author:
- Ed Bacho -- ebacho@slac.stanford.edu
This module works from within THS.c to control the GEM time hack.
This module handles calculation of absolute time using the "time hack" for the clk in the GEM (GASU).
The absolute (or true) time is provided once a second through a combination of a 1PPS (1 pulse per sec) hardware pulse and a time tone message ("at the tone the time will be") that preceeds it. The time provided in the time tone message from the scapecraft is in microSec since 1/1/2001. Hence the clock value is adjusted each second to account for clock counter drift from GEM clock.
The basic functions provided to application programs are:
- convert a 20 MHz bases clkCOunter (from GEM) value into absoluteTime
Inputs:
- time tone message every sec (500-800 mSec before pulse) giving next absTime
- HW 1PPS pulse every sec from GASU (although originates from spacecraft)
Outputs:
- convert time from event into absTIme using THS_gemAbsTimeEvent
Function Documentation
WCT_time THS_gemAbsTimeEvent |
( |
int |
gemStrobeIn, |
|
|
int |
gemClk |
|
) |
|
|
|
Calculate absolute time for event from strobe and clk provided with event (20MHz clk).
- Parameters:
-
gemStrobeIn | stobe counter from GEM from event data |
gemClk | clk counter from GEM from event data |
- Returns:
- 64b value of number of nanoSec since 1/1/2001
This routine takes the stobe and clk values from the GEM (part of event data) and converts it to an absolute time. Since this value is calulated through a table saved for the last N secs, it is only valid for the last N secs else will error and retun 0. |
Here is the call graph for this function:
unsigned int THS_gemCalcClkDiff |
( |
unsigned int |
clk, |
|
|
unsigned int |
prevClk |
|
) |
|
|
|
calculate diff between clks assuming 25 bit clock
- Parameters:
-
clk | latest gem clk value |
prevClk | previous gem clock value |
- Returns:
- difference between clk values
|
unsigned int THS_gemGetTableInfo |
( |
int |
count, |
|
|
unsigned int * |
gemStrobe, |
|
|
LSU_factors * |
Kgem |
|
) |
|
|
|
get info from hack table
- Parameters:
-
count | count value from gemStrobe, this is a 7 bit index into table |
gemStrobe | gemStrobe register value for this |
Kgem | ptr to extrapolation constants struct to fill |
- Returns:
- absolute time value at PPS in sec
|
unsigned int THS_gemInit |
( |
int |
siu |
) |
|
|
|
Inits the TimeHackService module.
- Parameters:
-
siu | 1=SIU(=commander on cmd/response), 0=EPU |
- Returns:
- status
This routine does basic init for gem specific THS and requires only a few modules to be init (PBS,MSG, ??). It is called from THS.c. Howver, it will not be fully operation till is has received timetone and PPS interrupt. THS_gemWait() can be used to wait for this state. |
void THS_gemIsr |
( |
unsigned int |
absTimeSec, |
|
|
int |
newTimetone |
|
) |
|
|
|
interrupt routine for gem specfic time hack
- Parameters:
-
absTimeSec | absolute time at PPS |
newTimetone | 1=indicates absTimeSec is real, 0=indicates absTimeSec is estimated |
- Returns:
- nothing
Interrupt routine connected to 1PPS input. This should be called from ThsIsr(). This is first half of processing to put a new entry into the time table. Other half is callback form LCB routine to read gem register. |
void THS_gemSetTable |
( |
WCT_time |
absTimeSec, |
|
|
unsigned int |
gemStrobeIn, |
|
|
LSU_factors |
Kgem |
|
) |
|
|
|
Set a single entry in the gem hack table.
- Parameters:
-
absTimeSec | |
gemStrobeIn | |
Kgem | |
- Returns:
- none
On SIU, this will be called within callback from the GEM read started by the PPS interrupt. The callback will also send this info on to the EPu's
On EPUs, this will be called as the results of a message from the SIU with this information. |
unsigned int THS_gemSetWarning |
( |
unsigned int |
expectedClkHz, |
|
|
unsigned int |
expectedDeltaClkHz |
|
) |
|
|
|
Set range for gem clock warning messages.
- Parameters:
-
expectedClkHz | - expected clock in Hz, <=0 uses default of 20MHz |
expectedDeltaClkHz | - expected delta clk in Hz, <0 uses default of 1% of clock |
- Returns:
- status
|
unsigned int THS_gemWait |
( |
|
) |
|
|
|
Start the TimeHackService module.
- Returns:
- status
Wait for THS to become full operational after THS_init(). This routines requires that most of the software is operational. This includes LCB driver, 1553 driver, and time tone messages from the scapecraft enabled. Since this module requires a timeTOne message from the spacecraft it can take up to 2 sec to return.
The sequence is: THS_gemInit();
start up bunch of things including LCB driver Sw to call THS_timeTone() every second as result of message from spacecraft Hw to cause PPS interrupt every second
THS_gemWait() (this routine waits till received first THS_gemTimeTone() followed by PPS interrupt) |
Generated on Thu Jun 23 21:59:28 2005 by
1.3.3