GLAST / LAT > DAQ and FSW > FSW > Doxygen Index> THS / dev > ths / rhel5-64


Interface   Data Structures   File List   Data Fields   Globals  

THS.c File Reference

Time Hack Services for CPU. More...

#include <PBS/PBS.h>
#include <PBS/WCT.h>
#include <PBS/TASK.h>
#include <PBS/TMR.h>
#include <PBS/LSU.h>
#include <PBS/MBA.h>
#include <PBS/FPA.h>
#include <PBS/BSWP.ih>
#include <LCBD/LCBD.h>
#include <MSG/MSG_pubdefs.h>
#include <THS/THS_msgs.h>
#include <THS_prvdefs.h>
#include <stdio.h>

Functions

unsigned int THS_init (int mask)
 Inits the TimeHackService module.
unsigned int THS_simulatedPPS ()
 Return the state of the pulse-per-second simulation.
unsigned int THS_simulatedTT ()
 Return the state of the timetone simulation.
unsigned int THS_wait ()
 Wait for TimeHackService module to be fully operational.
unsigned int THS_timetone (unsigned int absTimeSec, unsigned short saFlags)
 Provide absTime for next entry in table (on next PPS).
unsigned int THS_getLastPpsAbsTimeSec ()
 Get the absolute time value at last PPS.
void THS_stats ()
 Print some THS statistics.
void THS_setPpsWarnEvery (unsigned int warnPpsEvery)
 Set how often get warning when no PPS.
void THS_setTimetoneWarnEvery (unsigned int warnTimetoneEvery)
 Set how often get warning when no timetone.
void THS_setGemUpdateMsgs (int maxMsgs)
 set size of memory pool for gemUpdate msgs, must be called before THS_init
void THS_setSlaveSend (THS_SendSlaveRtn rtn, void *arg, int lsmID)
 stash away routine (from LCM) to send msg to EPU
void THS_sendSlaveGemSetTableMsg (unsigned int absTime, THS_GemTableFlags flags, unsigned int gemStrobe, LSU_factors Kgem)
 send gmHack from SIU to EPU (this runs on SIU)
unsigned int THS_slaveProcessMsg (int func, void *payload, unsigned int len)
 routine called from ITC dispatch in LSM to process each message it receives (this routine is run on EPU when it receives message)


Detailed Description

Time Hack Services for CPU.

Author:
Ed Bacho -- ebacho@slac.stanford.edu This is the controlling module for the Time Hack Services. It does the following:
  • Setup Pid and TImers on Rad750 to interrupt on PPS
  • Call THS_gemXXX routines to control time hack for 20 MHz clock on gem/gasu
  • Call THS_cpuXxx routines to control time hack for Cpu CLock
This module handles calculation of absolute time using the "time hack". 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.

This module only truely works on the Rad750 which has the PPS input thru the PID registers. The mv2304 version can be sort-of simulated by setting up a task to provide PPS (see THS_test.c)

Inputs:

Output:


Function Documentation

unsigned int THS_getLastPpsAbsTimeSec (  ) 

Get the absolute time value at last PPS.

Returns:
absolute time value

unsigned int THS_init ( int  mask  ) 

Inits the TimeHackService module.

Parameters:
mask time hack options, 1=CPU time hack, 2=Gem Time Hack, 4=CpuIsSiu
Returns:
status This routine does basic init for THS and requires a few modules to be init (PBS,MSG, ??). It setup the Pid TImers for the PPS interrupt and prepares to handle timeones. Howver, it takes several seconds for time hack to be operational and THS_start() can be used to determine if it is operational.

References THS_CPU_HACK, THS_cpuInit(), THS_GEM_HACK, THS_gemInit(), and THS_SIU_HACK.

void THS_sendSlaveGemSetTableMsg ( unsigned int  absTime,
THS_GemTableFlags  flags,
unsigned int  gemStrobe,
LSU_factors  Kgem 
)

send gmHack from SIU to EPU (this runs on SIU)

Parameters:
absTime - time in sec since 1/1/2001 from tt message
flags - flags from tt message
gemStrobe - contents of gemStrobe reg with clk on last PPS and clk counter
Kgem - multiplcation constants for calcs
Returns:
none

void THS_setGemUpdateMsgs ( int  maxMsgs  ) 

set size of memory pool for gemUpdate msgs, must be called before THS_init

Parameters:
maxMsgs number of gem table update messages in memory pool
Returns:
none

void THS_setPpsWarnEvery ( unsigned int  warnPpsEvery  ) 

Set how often get warning when no PPS.

Parameters:
warnPpsEvery 0=warn once when no pps detect, n=warn every N sec
Returns:
none

void THS_setSlaveSend ( THS_SendSlaveRtn  rtn,
void *  arg,
int  lsmID 
)

stash away routine (from LCM) to send msg to EPU

Parameters:
rtn - pointer to function to use to send off message to EPU
arg - 1st arg passed into rtn
lsmID - 2nd arg passed into rtn
Returns:
none Given routine should be called as: (rtn)(arg, lsmId, int nid, void *payload, int payloadLen, void* payloadFreeRtn, void *payloadFreeRtnArg);

void THS_setTimetoneWarnEvery ( unsigned int  warnTimetoneEvery  ) 

Set how often get warning when no timetone.

Parameters:
warnTimetoneEvery 0=warn once when no tt detect, n=warn every N sec
Returns:
none

unsigned int THS_simulatedPPS ( void   ) 

Return the state of the pulse-per-second simulation.

Return values:
0 Pulse-per-second is not being simulated
1 Pulse-per-second is being simulated

unsigned int THS_simulatedTT ( void   ) 

Return the state of the timetone simulation.

Return values:
0 Timetone is not being simulated
1 Timetone is being simulated

unsigned int THS_slaveProcessMsg ( int  func,
void *  payload,
unsigned int  len 
)

routine called from ITC dispatch in LSM to process each message it receives (this routine is run on EPU when it receives message)

Parameters:
func func code for message
payload - buffer with received message
len - length of given buffer
Returns:
none

References THS_FSW_FLAG_CPU_PPS_SIM, THS_FSW_FLAG_TT_SIM, THS_gemSetTable(), and THS_timetone().

void THS_stats (  ) 

Print some THS statistics.

Returns:
none

References THS_CPU_HACK, THS_GEM_HACK, THS_gemCalcClkDiff(), THS_gemGetTableInfo(), and THS_prevTimtoneFromEvent().

unsigned int THS_timetone ( unsigned int  absTimeSec,
unsigned short  saFlags 
)

Provide absTime for next entry in table (on next PPS).

Parameters:
absTimeSec - absolute time for next PPS pulse in secs since 1/1/2001
saFlags - flags from Spectrum Astro (i.e. in Magic 7 telecommand)
Returns:
status This routine provides the absolute time for next PPS. This should come from the spacecrasft once a sec approx 500-800 milliSec before PPS.

Referenced by THS_slaveProcessMsg().

unsigned int THS_wait (  ) 

Wait for TimeHackService module to be fully operational.

Returns:
status Since time hack requires a number of subsystems to be operating. These includes LCB driver, 1553 driver, and time tone messages from the scapecraft. Since this module requires two timeTone message from the spacecraft it might take 2 seconds before it is operational. THe routine does a slow poll waiting for the THS to be operational.
The sequence is: THS_init();

start up bunch of things including Sw to call THS_timeTone() every second as result of message from spacecraft Hw to cause PPS interrupt every second

THS_wait() (this routine waits till receives two THS_timeTone() followed by PPS interrupt)

References THS_CPU_HACK, THS_cpuWait(), THS_GEM_HACK, and THS_gemWait().


Generated on Thu Mar 31 12:53:03 2011 by  doxygen 1.5.8