/************************************************************************* $Archive: /pacs/OnBoard/Dec.h $ $Revision: 1.12 $ $Date: 2010/09/29 12:36:11 $ $Author: amazy $ $Log: Dec.h,v $ Revision 1.12 2010/09/29 12:36:11 amazy v6.030 * * 5 16/09/10 14:36 Amazy * - Introduced EDAC test code * - Introduced code to reset the DEC FPGA in SET_PARAM_BOTH * * 4 27/11/06 9:26 Amazy * Additionnal cleaning due to the change of master reset philosophy. A * semaphore was still signaled while no tasks were listening to it. It * has been removed. (Everything related to * SignalWhenReceivingSecondToLastReadout has been removed) * * 47 3/14/06 4:31p Pacs Egse * Version 6.001 * Cleaned and commented *************************************************************************/ #define DEC_H #ifndef CSL_TYPE_H #include "csl_type.h" #endif //**************************************************************** // CONSTANTS //**************************************************************** #define SIZE_OF_SPECTRO_PACKET_IN_WORDS 288 #define SIZE_OF_SPECTRO_SCIENCE_DATA_IN_WORDS 234 #define SIZE_OF_PHOTO_PACKET_IN_WORDS 257 #define SIZE_OF_PHOTO_HEADER_IN_WORDS 1 #define SIZE_OF_PHOTO_SCIENCE_DATA_IN_WORDS 256 #define VALID 0xFF #define INVALID 0x00 //**************************************************************** // GLOBAL VARIABLES DECLARATION //**************************************************************** extern void SendCommandToBlueDEC(int address, int value); extern void SendCommandToRedDEC(int address, int value); //**************************************************************** // STRUCTURES //**************************************************************** /* STRUCT : DecParams ****************** AUTHOR : Amazy USE : This structure contain the set of parameters related to each of the DEC. The first 8 words are accessible through a write command. They function are described in the SUM. The CreCtrlReg can be modified by a write command but it is also modified by some trigger commands (SWITCH_ON_DETECTOR_ARRAY). So, the write command will use the CreCtrlRegCommand and, when the parameters are sent to the DEC, we will combinate it with the actual value of CreCtrlReg to keep the status of some bits such as the power on bit. */ typedef struct { // the parameters accessible through the write command int ClocksPerReadout; int ReadoutsPerRamp; int CreCtrlRegCommand; int BiasRCommand; int BiasDCommand; int SimulReg; int HeaterCurrent; int FlasherCurrent; int CreCtrlReg; //This is an image of the register in the DEC BOOL ReadoutValidity; } DecParams; /* STRUCT : DecGroupHk ******************* AUTHOR : Amazy USE: This structure is used to store the analog hk received by each DEC group. Housekeeping is stored at various places in the DEC science packet. Every time a packet is received, this structure is updated with the values found in the packet. */ typedef struct { // Dec Base Hk int ZeroVolt; int HeaterCurrent; int HeaterVoltage; int Sensor1Voltage; int SensorsGeneratorPos; int Sensor2Voltage; int SensorsGeneratorNeg; int SensorsCurrentRange50; int SensorsCurrentRange2; int Thermistor; int Measure10; int Measure11; int Measure12; int Measure13; int VoltagePlus5VAnalog; int VoltagePlus5VRef; // Dec Supply Hk int VzeroVolt; int Vwell; int Vddd; int Vdda; int Vcascp; int Vcascn2; int Vcascn1; int Vddr; int Vss; int GndVoltage; int VzeroBias; int VbiasR; int VdddCurrent; int VddaCurrent; int VssCurrent; int GndCurrent; int Sensor1MeasureInProgress; int Sensor2MeasureInProgress; int Sensor1VoltagePos; int Sensor1VoltageNeg; int Sensor1VoltageDif; int Sensor2VoltagePos; int Sensor2VoltageNeg; int Sensor2VoltageDif; int Sensor1CurrentRange50Pos; int Sensor1CurrentRange50Neg; int Sensor1CurrentRange50Dif; int Sensor1CurrentRange2Pos; int Sensor1CurrentRange2Neg; int Sensor1CurrentRange2Dif; int Sensor2CurrentRange50Pos; int Sensor2CurrentRange50Neg; int Sensor2CurrentRange50Dif; int Sensor2CurrentRange2Pos; int Sensor2CurrentRange2Neg; int Sensor2CurrentRange2Dif; int Sensor1ResistorValue; int Sensor2ResistorValue; int HkHighOrLowGain; } DecGroupHk; /* STRUCT : DecHkReadback ********************** AUTHOR : Amazy USE: This structure is used to store the hk received by DEC. Housekeeping is stored at various places in the DEC science packet. Every time a packet is received, this structure is updated with the values found in the packet. NOTE: The last two values are a combination of two other values to ease the interpretation of hk. */ typedef struct { //DIGITAL HK int ClocksPerReadoutFirst; int ClocksPerReadoutSecond; int ReadoutsPerRampFirst; int ReadoutsPerRampSecond; int CreStatusRegFirst; int CreStatusRegSecond; int BiasRCommandFirst; int BiasRCommandSecond; int BiasDCommandFirst; int BiasDCommandSecond; int SimulRegFirst; int SimulRegSecond; int Spare1RegFirst; int Spare1RegSecond; int Spare2RegFirst; int Spare2RegSecond; int ReadoutCounterFirst; int ReadoutCounterSecond; int RampCounterLowFirst; int RampCounterLowSecond; int RampCounterHighFirst; int RampCounterHighSecond; int Spare1; int Spare2; int Spare3; int Spare4; int Spare5; int Spare6; int Spare7; int Spare8; int Spare9; int Spare10; int Spare11; int Spare12; //analog HK DecGroupHk Group1; DecGroupHk Group2; // additional entries (intermediate values for HK) int RampCounterFirst; int RampCounterSecond; } DecHkReadback; /* STRUCT : DecRecParams ********************** AUTHOR : Amazy USE : This structure is used to monitor the DecReceiver Tasks. */ typedef struct { int TaskStatus; int Options; //software counter counting the packet //received since the start of the task (can not be reset) int PacketCounter; //software counter that can be reset by command (SetTime, //SetOBSID, SetBBID), it is mainly used for timing purpose in HkDiagPacket int ReadoutCounter; int BufferToFill; DecHkReadback DecHk; DecHkReadback SimDecHk; } DecRecParams; /* STRUCT : DecControllerParams ***************************** AUTHOR : Amazy USE : This structure is used to monitor the DecController Tasks. */ typedef struct { int TaskStatus; int PacketCounter; DecParams DetectorParams; DecParams TemporaryDetectorParams; } DecControllerParams; //**************************************************************** // ENUMERATIONS AND DEFINES //**************************************************************** // defines the status of the DecController #define K_BMASK_TASK_STATUS_DEC_CTRL_POWERED_ON 0x00100000 //these mask are used in the bits field CreControlReg #define K_BMASK_DEC_COMMAND_DETECTOR_POWER 0x00000001 #define K_BMASK_DEC_COMMAND_DETECTOR_POWER_OFF 0x00000000 #define K_BMASK_DEC_COMMAND_DETECTOR_POWER_ON 0x00000001 #define K_BMASK_DEC_COMMAND_HEATER_POWER 0x00000800 #define K_BMASK_DEC_COMMAND_HEATER_POWER_OFF 0x00000000 #define K_BMASK_DEC_COMMAND_HEATER_POWER_ON 0x00000800 #define K_BMASK_DEC_COMMAND_FLASHER_POWER 0x00000400 #define K_BMASK_DEC_COMMAND_FLASHER_POWER_OFF 0x00000000 #define K_BMASK_DEC_COMMAND_FLASHER_POWER_ON 0x00000400 #define K_BMASK_DEC_COMMAND_WRITABLE_BITS 0x000003FE //defines the bit that can be written by the WRITE commands (other bits are modified internally by the OBS) // these masks are used in the bits field CreStatusReg #define K_BMASK_HK_VALID 0x00008000 #define K_BMASK_HK_SUPPLY_MUX 0x00000F00 #define K_BMASK_HK_BASE_MUX 0x000000F0 #define K_BMASK_HK_UPPER_SENSOR_VOLTAGE_VALID 0x00000008 #define K_BMASK_HK_LOWER_SENSOR_VOLTAGE_VALID 0x00000004 #define K_BMASK_HK_SENSOR_CURRENT_50_VALID 0x00000002 #define K_BMASK_HK_SENSOR_CURRENT_2_VALID 0x00000001 #define K_BPOS_HK_BASE_MUX 4 #define K_BPOS_HK_SUPPLY_MUX 8 // defines the position of some housekeeping #define DEC_HK_UPPER_SENSOR_VOLTAGE 3 #define DEC_HK_LOWER_SENSOR_VOLTAGE 5 #define DEC_HK_SENSOR_CURRENT_50 7 #define DEC_HK_SENSOR_CURRENT_2 8 /* ENUM : DecParamsAddress *********************** AUTHOR : Amazy USE : This enumeration define the address of command that can be sent to DEC FPGA */ enum DecParamsAddress { DEC_COMMAND = 0x01, DEC_CLOCKS_PER_READOUT = 0x08, DEC_READOUTS_PER_RAMP = 0x09, DEC_CRE_CTRL_REG = 0x0A, DEC_BIAS_R_COMMAND = 0x0B, DEC_ZERO_BIAS_COMMAND = 0x0C, DEC_SIMUL_REG = 0x0D, DEC_HEATER_COMMAND = 0x0E, DEC_FLASHER_COMMAND = 0x0F, FIRST_DEC_CLOCKS_PER_READOUT = 0x08, FIRST_DEC_READOUTS_PER_RAMP = 0x09, FIRST_DEC_CRE_CTRL_REG = 0x0A, FIRST_DEC_BIAS_R_COMMAND = 0x0B, FIRST_DEC_ZERO_BIAS_COMMAND = 0x0C, FIRST_DEC_SIMUL_REG = 0x0D, FIRST_DEC_SPARE_1_REG = 0x0E, FIRST_DEC_SPARE_2_REG = 0x0F, SECOND_DEC_CLOCKS_PER_READOUT = 0x10, SECOND_DEC_READOUTS_PER_RAMP = 0x11, SECOND_DEC_CRE_CTRL_REG = 0x12, SECOND_DEC_BIAS_R_COMMAND = 0x13, SECOND_DEC_ZERO_BIAS_COMMAND = 0x14, SECOND_DEC_SIMUL_REG = 0x15, SECOND_DEC_SPARE_1_REG = 0x16, SECOND_DEC_SPARE_2_REG = 0x17, BOTH_DEC_CLOCKS_PER_READOUT = 0x18, BOTH_DEC_READOUTS_PER_RAMP = 0x19, BOTH_DEC_CRE_CTRL_REG = 0x1A, BOTH_DEC_BIAS_R_COMMAND = 0x1B, BOTH_DEC_ZERO_BIAS_COMMAND = 0x1C, BOTH_DEC_SIMUL_REG = 0x1D, BOTH_DEC_SPARE_1_REG = 0x1E, BOTH_DEC_SPARE_2_REG = 0x1F, }; /* ENUM : DecControllerFifoMessageType *********************************** AUTHOR : Amazy USE : this enumeration is used in the DecController FIFO's */ typedef enum { MSG_DEC_CTRL_LOAD_PARAMETERS, MSG_DEC_CTRL_LOAD_BOTH_PARAMETERS, MSG_DEC_CTRL_SWITCH_DEC_ON, MSG_DEC_CTRL_SWITCH_DETECTOR_ON, MSG_DEC_CTRL_SWITCH_DETECTOR_OFF, MSG_DEC_CTRL_SET_HEATER_CURRENT, MSG_DEC_CTRL_SET_FLASHER_CURRENT, MSG_DEC_CTRL_SWITCH_HEATER_ON, MSG_DEC_CTRL_SWITCH_HEATER_OFF, MSG_DEC_CTRL_SWITCH_FLASHER_ON, MSG_DEC_CTRL_SWITCH_FLASHER_OFF, } DecControllerFifoMessageType; /* ENUM : DecControllerFifoMessage ******************************** AUTHOR : Amazy USE : structure used to transmit messages to DEC Controller FIFO */ typedef struct { DecControllerFifoMessageType Type; int Param; } DecControllerFifoMessage; //**************************************************************** // FUNCTION DECLARATIONS //**************************************************************** extern void SetDecParamsDefaultValues(DecParams* p_params);