GLAST / LAT > DAQ and FSW > FSW > Doxygen Index> PBS / dev > pbs / rad750
#include <intLib.h>
#include <excLib.h>
#include <semLib.h>
#include <PBS/L.ih>
#include <PBS/MTX.ih>
#include <PBS/TAU.h>
#include <PBS/TAU.ih>
#include <PBI/Alias.h>
Classes | |
struct | _TAU_tauCtx |
The original interrupt context before the initialization of the TAU facility. This context is restored when TAU_shutdown is called. More... | |
struct | _TAU_chkCtx |
The context when the TAU facility is running in the check limits mode. More... | |
struct | _TAU_rdCtx |
The context when the TAU facility is running in the read temperature mode. More... | |
struct | _TAU_ctx |
The grand context of TAU facility. More... | |
Defines | |
#define | LOG_MSG(fmt, p0, p1, p2, p3, p4, p5) |
#define | TAU_A_EXCEPTION_VECTOR 0x1700 |
#define | TAU_K_SITV (1024) |
#define | INTERRUPT_IF_GREATER 0 |
#define | INTERRUPT_IF_LESS 1 |
#define | TAU_K_INITIAL_GUESS 63 |
The intial guess at the processor temperature. | |
Typedefs | |
typedef struct _TAU_tauCtx | TAU_tauCtx |
Typedef for struct _TAU_tauCtx. | |
typedef struct _TAU_chkCtx | TAU_chkCtx |
Typedef for struct _TAU_chkCtx. | |
typedef struct _TAU_rdCtx | TAU_rdCtx |
Typedef for struct _TAU_rdCtx. | |
typedef struct _TAU_ctx | TAU_ctx |
Typedef for struct _TAU_ctx. | |
Functions | |
static void | disable (void) |
Disables the TAU interrupt. | |
static void | enable (int sitv) |
Enables the TAU interrupt with the specified sampling timer interval. | |
static void | save (TAU_tauCtx *tau) |
Saves the current context of the TAU facility. | |
static int | restore (const TAU_tauCtx *tau) |
Restores a previous context of the TAU facility. | |
static int | calcNewLimits (int count) |
Calculates a new set of threshold limits based on the current set and the iteration count. | |
static int | adone (TAU_request *request, int temperature, int count, int sequence) |
Stub routine to act as the completion routine for TAU_aread. | |
static void | limitsSet (int threshold, int direction) |
Sets THRM1 and THRM2 to the specified threshold, but with opposite comparison directions. | |
static void | service (void) |
The interrupt handler for the read temperature facility. | |
static int | acquire (TAU_ctx *ctx) |
Begins an acquisition cycle. | |
int | TAU_initialize (int sitv) |
Initializes the TAU facility. | |
int | TAU_shutdown (void) |
Restores the original VxWorks routine. | |
TAU_isr * | TAU_connect (TAU_isr *isr) |
Connects the specified routine as the TAU interrupt handler. | |
int | TAU_restore (TAU_isr *prvIsr) |
Restores the specified interrupt service routine as the current thermal exception handler. | |
int | TAU_qread (TAU_request *request) |
Ques a read of the temperature. | |
int | TAU_aread (TAU_request *request) |
Perform an asynchronous read. This call should be matched with a TAU_await (). | |
int | TAU_await (TAU_request *request) |
Waits for the completion of the read request. | |
int | TAU_read (void) |
Issues a synchronous read request. | |
int | TAU_pread (TAU_request *request) |
Issues a synchronous polled read request. | |
ALIAS_FNC (int, TAU_pread, TAU_sread) | |
Variables | |
static TAU_ctx | TauCtx |
Static variable holding the TAU context. |
CVS $Id: TAU.c.vx-ppc750-gcc,v 1.4 2011/03/24 23:05:47 apw Exp $
The tactic taken in this design is a variation of this. Rather than having a service task, one sets up a que that requests can be queued to. A request that causes the que to go from empty to non-empty initialiates the sequence. Instead of polling each digization sequence for completion, the TAU is configured to deliver an interrupt. The interrupt service routine then examines the result of the comparision operation and either declares that the temperature has been found or seeds the TAU with a new threshold, repeating this process until the temperature is found.
Having lost the ability to do a trinary search, one may be tempted to try a binary search. Here one would set THRM1 and THRM2 with the same values, but opposition comparision directions (this guarantees an interrupt will always be generated) and keeps cutting the range in half. The problem with this approach is that the junction temperature, while very stable, is not completely fixed. If it wanders over a boundary, the binary search can fail. For example, imagine that one starts the search with a threshold of 63 and the temperature is 63.1 at the beginning. The first search tells you to go higher. So now the range is 63-127 and the algorithm selects 85 as its next break point. However in between the two readings the junction temperature moves down to 62.9 and continues to drift down. The result of the search will lead on to believe the answer is in the range 63-85. Eventually the search will settle on 63, even though the temperature may have continued to drift down.
The astute reader will notice that since the comparison to THRM1 occurs first, if possible, one should bias the algorithm such that THRM1 will generate the interrupt.
T2 T1 T2 T1 Iter Time Lo Hi Lo Hi <55 >55 invalid TRUE 1 20usecs 0 127 55 127 <56 >56 TRUE invalid 2 40usecs 55 127 55 56
Now suppose the temperature has changed to 54.5 The sequence should be
T2 T1 T2 T1 Iter Time Lo Hi Lo Hi <55 >55 TRUE invalid 1 40usecs 0 127 0 55 >54 <54 TRUE invalid 2 40usecs 0 55 54 55
T = 53.5 -------- T2 T1 T2 T1 Iter Time Lo Hi Lo Hi <55 >55 TRUE invalid 1 40usecs 0 127 0 55 >54 <54 invalid TRUE 2 20usecs 0 55 0 54 >53 <53 TRUE invalid 3 40usecs 0 54 53 54
T = 56.5 -------- T2 T1 T2 T1 Iter Time Lo Hi Lo Hi <55 >55 invalid TRUE 1 20usecs 0 127 55 127 <56 >56 invalid TRUE 1 20usecs 55 127 56 127 <57 >57 TRUE invalid 1 40usecs 56 127 56 57
#define TAU_K_INITIAL_GUESS 63 |
The intial guess at the processor temperature.
This is used to seed the first search. Subsequent searches are seeded with the last temperature reading
Referenced by TAU_initialize().
int acquire | ( | TAU_ctx * | ctx | ) | [inline, static] |
Begins an acquisition cycle.
References _TAU_rdCtx::count, disable(), enable(), _TAU_rdCtx::last, limitsSet(), _TAU_ctx::rd, _TAU_rdCtx::save, save(), _TAU_rdCtx::sequence, service(), _TAU_rdCtx::sitv, and TAU_connect().
Referenced by TAU_qread().
void adone | ( | TAU_request * | request, | |
int | temperature, | |||
int | count, | |||
int | sequence | |||
) | [static] |
Stub routine to act as the completion routine for TAU_aread.
request | The request descriptor | |
temperature | The temperature | |
count | The number of iterations to converge | |
sequence | The sequence number of this reading |
References _TAU_request::count, _TAU_request::prm, _TAU_request::sequence, and _TAU_request::temperature.
Referenced by TAU_aread().
int calcNewLimits | ( | int | count | ) | [static] |
Calculates a new set of threshold limits based on the current set and the iteration count.
count | The iteration count |
References _TAU_reg::bf, TAU__get1(), TAU__get2(), TAU__set1(), TAU__set2(), _TAU_reg_bf::threshold, _TAU_reg_bf::tid, _TAU_reg_bf::tin, and _TAU_reg::val.
Referenced by service(), and TAU_pread().
void enable | ( | int | sitv | ) | [inline, static] |
Enables the TAU interrupt with the specified sampling timer interval.
sitv | The sampling timer interval |
References _TAU_ctl::bf, _TAU_ctl_bf::e, _TAU_ctl_bf::rsvd, _TAU_ctl_bf::sitv, TAU__set3(), and _TAU_ctl::val.
Referenced by acquire(), service(), and TAU_pread().
void limitsSet | ( | int | threshold, | |
int | direction | |||
) | [inline, static] |
Sets THRM1 and THRM2 to the specified threshold, but with opposite comparison directions.
threshold | The threshold value | |
direction | The comparison direction for THRM1. THRM2 will be set in the opposite direction. This ensures that any temperature will generate and interrupt. |
References _TAU_reg::bf, TAU__set1(), TAU__set2(), _TAU_reg_bf::threshold, _TAU_reg_bf::tid, _TAU_reg_bf::tie, _TAU_reg_bf::v, and _TAU_reg::val.
Referenced by acquire().
restore | ( | const TAU_tauCtx * | tau | ) | [static] |
Restores a previous context of the TAU facility.
tau | The TAU context to restore |
References disable(), _TAU_tauCtx::handler, TAU__set1(), TAU__set2(), TAU__set3(), TAU_restore(), _TAU_tauCtx::thrm1, _TAU_tauCtx::thrm2, and _TAU_tauCtx::thrm3.
Referenced by service(), TAU_pread(), and TAU_shutdown().
save | ( | TAU_tauCtx * | tau | ) | [static] |
Saves the current context of the TAU facility.
tau | Structure to receive the saved context |
References _TAU_tauCtx::handler, TAU__get1(), TAU__get2(), TAU__get3(), _TAU_tauCtx::thrm1, _TAU_tauCtx::thrm2, and _TAU_tauCtx::thrm3.
Referenced by acquire(), TAU_initialize(), and TAU_pread().
int TAU_aread | ( | TAU_request * | request | ) |
Perform an asynchronous read. This call should be matched with a TAU_await ().
request | An un-initialized request structure |
References adone(), _TAU_request::completion, _TAU_request::prm, _TAU_ctx::rd, _TAU_rdCtx::synch, and TAU_qread().
int TAU_await | ( | TAU_request * | request | ) |
Waits for the completion of the read request.
request | The request being waited on |
References _TAU_request::prm.
Connects the specified routine as the TAU interrupt handler.
isr | The interrupt service routine to connect |
Referenced by acquire().
int TAU_initialize | ( | int | sitv | ) |
Initializes the TAU facility.
This is a one-time only initialization call. When finished with the facility, call TAU_shutdown ().
References _TAU_rdCtx::count, L__init(), _TAU_rdCtx::last, _TAU_rdCtx::mtx, MTX__create(), _TAU_ctx::org, _TAU_ctx::rd, _TAU_rdCtx::requests, save(), _TAU_rdCtx::sequence, _TAU_rdCtx::sitv, _TAU_rdCtx::synch, and TAU_K_INITIAL_GUESS.
Referenced by PBS_initialize2().
status TAU_pread | ( | TAU_request * | request | ) |
Issues a synchronous polled read request.
request | The read request block |
References _TAU_reg::bf, calcNewLimits(), _TAU_request::count, disable(), enable(), _TAU_rdCtx::last, _TAU_rdCtx::mtx, MTX__lock(), MTX__unlock(), _TAU_ctx::rd, restore(), _TAU_rdCtx::save, save(), _TAU_request::sequence, _TAU_rdCtx::sequence, _TAU_rdCtx::sitv, TAU__get1(), TAU__set1(), TAU__set2(), _TAU_request::temperature, _TAU_reg_bf::threshold, _TAU_reg_bf::tid, _TAU_reg_bf::tie, _TAU_reg_bf::tiv, _TAU_reg_bf::v, and _TAU_reg::val.
int TAU_qread | ( | TAU_request * | request | ) |
Ques a read of the temperature.
request | A previously initialized read request. One should use the macro TAU_REQUEST_INIT to initialize this structure. |
References acquire(), L__insert(), _TAU_request::node, _TAU_ctx::rd, and _TAU_rdCtx::requests.
Referenced by TAU_aread().
int TAU_read | ( | void | ) |
Issues a synchronous read request.
References TAU_sread(), and _TAU_request::temperature.
int TAU_restore | ( | TAU_isr * | prvIsr | ) |
Restores the specified interrupt service routine as the current thermal exception handler.
Referenced by restore().
int TAU_shutdown | ( | void | ) |
Restores the original VxWorks routine.
This routine restores the original interrupt service handler
References L__destroy(), _TAU_rdCtx::mtx, MTX__destroy(), _TAU_ctx::org, _TAU_ctx::rd, _TAU_rdCtx::requests, restore(), and _TAU_rdCtx::synch.
Referenced by PBS_shutdown().