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


Interface   Data Structures   File List   Data Fields   Globals  

THS_cpu.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/PTS.h>
#include <LCBD/LCBD.h>
#include <MSG/MSG_pubdefs.h>
#include <THS/THS_msgs.h>
#include <THS_prvdefs.h>

Functions

unsigned int THS_cpuInit ()
 Inits the TimeHackService module.
unsigned int THS_cpuWait ()
 Start the TimeHackService module.
unsigned int THS_getLastPpsClock ()
 Get the CPU clk value at last PPS.
void THS_setLastPpsClock (unsigned int snapshot)
 Set the CPU clk value at last PPS.
void THS_cpuIsr (unsigned int absTimeSec, int realPps, unsigned int snapshot)
 interrupt routine for CPU specfic time hack
unsigned int THS_cpuSetWarning (unsigned int expectedClkHz, unsigned int expectedDeltaClkHz)
 Set range for cpu clock warning messages.


Detailed Description

Time Hack Services for CPU.

Author:
Ed Bacho -- ebacho@slac.stanford.edu This module works from within THS.c to control the CPU time hack. THS_init() can be called so that the CPU time hack is not enabled.
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 file has routines for adjusting the time on the CPU clock by using the WCT_set/get routines, therefore one can only get the current time thru WCT_get(). THese are based on a sub-multiple of the CPU's 33 MHz PCI clock.

The determination of the absolute time from event and LCB times is handled in other time hack files.

This module only truely works on the Rad750 which has the PPS input thru the PID registers. The mv2304 version starts up a task to simulate the PPS but it should therefore show no drift (since its locked with the clock)

Inputs:

Output:


Function Documentation

unsigned int THS_cpuInit (  ) 

Inits the TimeHackService module.

Returns:
status This routine does basic init for THS cpu time hack and requires a few modules to be init (PBS,MSG, ??). Howver, actually operation will not happen till THS_cpuStart() is run.

Referenced by THS_init().

void THS_cpuIsr ( unsigned int  absTimeSec,
int  realPps,
unsigned int  snapshot 
)

interrupt routine for CPU specfic time hack

Parameters:
absTimeSec absolute time at PPS
realPps 1=indicates snapshot is real, 0=indicates snapshot is estimated
snapshot snapshot clk value at PPS
Returns:
nothing CPU Hack interrupt routine called from the ThsIsr() which is connected to the 1PPS interrutp. This adjusts the WCT clock with WCT_set().
CAUTION: THis routine adjusts the WUT timer module and it is very easy to kill the OS when modifying calls to WUT.

unsigned int THS_cpuSetWarning ( unsigned int  expectedClkHz,
unsigned int  expectedDeltaClkHz 
)

Set range for cpu clock warning messages.

Parameters:
expectedClkHz - expected clock in Hz, <=0 uses default, (16.6MHz on mv2304, 8.3MHz on Rad750)
expectedDeltaClkHz - expected delta clk in Hz, <0 uses default of 2% of clock
Returns:
status

unsigned int THS_cpuWait (  ) 

Start the TimeHackService module.

Returns:
status Wait for the CPU TimeHackServices to start up. 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 module is called within THS.c.

The sequence is: THS_cpuInit();

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_cpuWait() (this routine waits till received first THS_cpuTimeTone() followed by PPS interrupt)

Referenced by THS_wait().

unsigned int THS_getLastPpsClock (  ) 

Get the CPU clk value at last PPS.

Returns:
clock value

void THS_setLastPpsClock ( unsigned int  snapshot  ) 

Set the CPU clk value at last PPS.

Parameters:
snapshot snapshow value from Rad750 HW


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