/**********************************************************************/ /* strips.h, ucsc.h */ /**********************************************************************/ /* this part is only included if: #define I_AM_DSP */ /* us_LL_ports.h initialization of LL ports */ /* us_var_point.h static variables, */ /* constant pointer definitions */ /**********************************************************************/ /* this part is always included */ /* us_mess.h structure definitions of user messages */ /* us_action_id.h definitions of action_id */ /* us_error_codes.h definitions of error codes */ /* us_response_codes.h definitions of response codes */ /* us_defaults.h default values */ /**********************************************************************/ /* this part is only included if: #define I_AM_DSP */ /* us_sys.h prototype definitions */ /* us.h prototype definitions */ /**********************************************************************/ #ifdef I_AM_DSP #define CODE_VER_UH 0x100 /**********************************************************************/ /* SLL PORTS */ /**********************************************************************/ #define SLL_IN_INFLAG (LL_BASE + 0x0) #define SLL_IN_OUTFLAG (LL_BASE + 0x80) #define SLL_IN_FIFO0 (LL_BASE + 0x200) #define SLL_IN_FIFO1 (LL_BASE + 0x280) #define SLL_IN_FIFO2 (LL_BASE + 0x300) #define SLL_IN_FIFO3 (LL_BASE + 0x380) #define SLL_OUT_DACMISC (LL_BASE + 0x0) #define SLL_OUT_COUNT (LL_BASE + 0x80) #define SLL_OUT_DELAY (LL_BASE + 0x100) #define SLL_OUT_FIFO (LL_BASE + 0x180) #define SLL_OUT_NEXT0 (LL_BASE + 0x200) #define SLL_OUT_NEXT1 (LL_BASE + 0x280) #define SLL_OUT_NEXT2 (LL_BASE + 0x300) #define SLL_OUT_NEXT3 (LL_BASE + 0x380) /*******************************************************************/ /* BIT DEFINITIONS FOR SLL PORTS: */ /*******************************************************************/ #define SLL_OUTFLAG0 0 /* output fifo flags */ #define SLL_OUTFLAG1 1 #define SLL_OFIFO_RESET 0 #define SLL_OFIFO_GO 1 /**********************************************************************/ /* DEFINITION OF PORTS */ /**********************************************************************/ #define SLL_INFLAG 0 #define SLL_OUTFLAG 1 #define SLL_DATIN0 2 #define SLL_DATIN1 3 #define SLL_DATIN2 4 #define SLL_DATIN3 5 #define SLL_DACMISC 6 #define SLL_COUNTER 7 #define SLL_DELAY 8 #define SLL_DATOUT 9 #define SLL_NEXT0 10 #define SLL_NEXT1 11 #define SLL_NEXT2 12 #define SLL_NEXT3 13 #define A_SLL_INFLAG (int *) SLL_IN_INFLAG #define A_SLL_OUTFLAG (int *) SLL_IN_OUTFLAG #define A_SLL_DATIN0 (int *) SLL_IN_FIFO0 #define A_SLL_DATIN1 (int *) SLL_IN_FIFO1 #define A_SLL_DATIN2 (int *) SLL_IN_FIFO2 #define A_SLL_DATIN3 (int *) SLL_IN_FIFO3 #define A_SLL_DACMISC (int *) SLL_OUT_DACMISC #define A_SLL_COUNTER (int *) SLL_OUT_COUNT #define A_SLL_DELAY (int *) SLL_OUT_DELAY #define A_SLL_DATOUT (int *) SLL_OUT_FIFO #define A_SLL_NEXT0 (int *) SLL_OUT_NEXT0 #define A_SLL_NEXT1 (int *) SLL_OUT_NEXT1 #define A_SLL_NEXT2 (int *) SLL_OUT_NEXT2 #define A_SLL_NEXT3 (int *) SLL_OUT_NEXT3 /**********************************************************************/ /* INPUT PORT MASKS */ /**********************************************************************/ #define M_SLL 0xff /**********************************************************************/ /* INITIALIZATION OF PORTS */ /**********************************************************************/ struct LL_ports LL_port[LL_MAXPORTS] = { {A_SLL_INFLAG, 0}, {A_SLL_OUTFLAG, 0}, {A_SLL_DATIN0, 0}, {A_SLL_DATIN1, 0}, {A_SLL_DATIN2, 0}, {A_SLL_DATIN3, 0}, {A_SLL_DACMISC, 0xc3}, {A_SLL_COUNTER, 0}, {A_SLL_DELAY, 0}, {A_SLL_DATOUT, 0}, {A_SLL_NEXT0, 0x1}, {A_SLL_NEXT1, 0x1}, {A_SLL_NEXT2, 0x1}, {A_SLL_NEXT3, 0x1}}; /**********************************************************************/ /**********************************************************************/ /* POINTER DEFINITIONS */ /**********************************************************************/ /* p_indata[NUMLINKS]: points to input data block from links */ /* p_ctrout_block[4]: points to output control blocks */ /* (to be loaded into output fifo) */ /* inflag_mask[NUMLINKS]: masks input fifo flag bits for link i */ /**********************************************************************/ #define INDATA_BASE (DATA_BASE + HEADLEN + 1) #define NUMLINKS 4 /* number of links connected to DSP */ #define CTROUT_BLOCKSIZE (2048 +1) /* size of control block buffer in RAM */ #define INDATA_BLOCKSIZE (DATA_BLOCKSIZE/NUMLINKS \ - (HEADLEN + 1) \ - 4*CTROUT_BLOCKSIZE) const int *p_indata[NUMLINKS] = { (int *) INDATA_BASE, (int *) (INDATA_BASE + HEADLEN + 1 + INDATA_BLOCKSIZE), (int *) (INDATA_BASE + 2*(HEADLEN + 1) + 2*INDATA_BLOCKSIZE), (int *) (INDATA_BASE + 3*(HEADLEN + 1) + 3*INDATA_BLOCKSIZE)}; #define CTROUT_BASE \ (INDATA_BASE + 4*(HEADLEN + 1 + INDATA_BLOCKSIZE) + 0x0) const int *p_ctrout_block[4] = { (int *) CTROUT_BASE, (int *) (CTROUT_BASE + CTROUT_BLOCKSIZE), (int *) (CTROUT_BASE + 2*CTROUT_BLOCKSIZE), (int *) (CTROUT_BASE + 3*CTROUT_BLOCKSIZE)}; const int inflag_mask[NUMLINKS] = {0x3,0xc,0x30,0xc0}; #endif /**********************************************************************/ /* MESSAGES: */ /**********************************************************************/ /**********************************************************************/ /* LOAD_CONTROL_BLOCK */ /* parameters: 1+ 2048 MAX */ /**********************************************************************/ struct m_load_control { HEADER int32 blocknum; /* block will be loaded into RAM buffer blocknum */ int32 blockdata[2048]; /* control block to load */ }; typedef struct m_load_control m_load_control; /**********************************************************************/ /* EXECUTE_CONTROL_BLOCK */ /* parameters: 2 */ /**********************************************************************/ struct m_exe_control { HEADER int32 blocknum; /* RAM buffer block to execute */ int32 numexe; /* number of times to execute control block blocknum */ }; typedef struct m_exe_control m_exe_control; /**********************************************************************/ /* LOAD_EXE_CTR_BLK */ /**********************************************************************/ struct m_load_exe_ctr_blk { HEADER int32 take_data; int32 data_format; int32 numpackets; int32 blockdata[2048]; }; typedef struct m_load_exe_ctr_blk m_load_exe_ctr_blk; /**********************************************************************/ /* GET_DET_STATUS */ /* parameters: 2048 max */ /**********************************************************************/ struct m_get_det_status { HEADER int32 blockdata[2048]; /* control block to execute */ }; typedef struct m_get_det_status m_get_det_status; /**********************************************************************/ /* DET_STATUS Response message from DSP to GET_DET_STATUS */ /* parameters: 2048 max */ /**********************************************************************/ struct m_det_status { HEADER int32 data[2048]; /* status block from detector */ }; typedef struct m_det_status m_det_status; /**********************************************************************/ /* LL_STATUS */ /* parameters: 6 */ /**********************************************************************/ struct m_LL_status { HEADER int32 LL_dac_setting[4]; int32 LL_strobe_setting; int32 LL_counter_setting; }; typedef struct m_LL_status m_LL_status; /**********************************************************************/ /* SET_LL_DAC */ /* # of parameters: 2 */ /**********************************************************************/ struct m_set_LL_dac { HEADER int32 dac; /* DAC: (LL card: 0-3) */ int32 voltage; /* voltage: (0-4095) */ }; typedef struct m_set_LL_dac m_set_LL_dac; /**********************************************************************/ /* SET_STROBE_DELAY */ /* parameters: 1 */ /**********************************************************************/ struct m_set_strobe_delay { HEADER int32 strobe_delay; /* strobe delay value */ }; typedef struct m_set_strobe_delay m_set_strobe; /**********************************************************************/ /* SET_COUNTER_VAL */ /* parameters: 1 */ /**********************************************************************/ struct m_set_counter_val { HEADER int32 count_val; /* input control counter value */ }; typedef struct m_set_counter_val m_set_counter; /**********************************************************************/ /* SET_TIMEOUT */ /* parameters: 2 */ /**********************************************************************/ struct m_set_timeout { HEADER int32 det_rd_timeout; int32 gen_timeout; }; typedef struct m_set_timeout m_set_timeout; /**********************************************************************/ /* ACTION_ID: */ /**********************************************************************/ /**********************************************************************/ /* us_action_id.h */ /* USER MESSAGES: DEFINITIONS OF action_id */ /* strips: action_id 200-299 */ /* pixels: action_id 100-199 */ /**********************************************************************/ #define LOAD_CONTROL_BLOCK 200 #define EXECUTE_CONTROL_BLOCK 201 #define GET_DET_STATUS 202 #define DET_STATUS 203 #define SET_STROBE_DELAY 204 #define SET_COUNTER_VAL 205 #define SET_LL_DAC 206 #define GET_LL_STATUS 207 #define LL_STATUS 208 #define LOAD_EXE_CTR_BLK 209 #define SET_TIMEOUT 210 #define RESET_FIFOS 211 /**********************************************************************/ /* strips_error_codes.h */ /* ERROR CODE DEFINITIONS */ /**********************************************************************/ /* fatal errors: reported by message fatal_error */ /* other errors: reported by message error_report */ #define BLOCK_TOO_LONG 200 /* control block too long */ #define INVALID_BLOCK_NUMBER 201 /* valid blocks: 0-3 */ #define INVALID_COUNTER_VALUE 210 #define INVALID_DELAY_VALUE 211 #define TIMEOUT 212 /* read_packets exceeded time */ /* limit given by */ /* det_read_timeout */ /**********************************************************************/ /* us_defaults.h */ /* DEFAULTS */ /**********************************************************************/ #define RUN_MODE EOB_TRANSFER /* run-mode */ #define TRIG_PULSES 1 /* trigger accepts/external trigger */ #define TRIG_DELAY1 80 /* delay for trigger alignment fifo 1*/ #define TRIG_DELAY2 80 /* delay for trigger alignment fifo 2*/ #define VOLTAGE 0 /* DSP-DAC voltage */ /**********************************************************************/ /* add other default values to be set in set_defaults() */ /**********************************************************************/ #define STROBE_DELAY 0 /* strobe delay */ #define COUNTER_VAL 100 /* input fifo control counter value */ #define LL_VOLTAGE 0 /* LL-DAC voltage */ #define DET_READ_TIMEOUT 1000 /* timeout for reading packets */ #ifdef I_AM_DSP /**********************************************************************/ /* us_sys.h */ /* PROTOTYPE DEFINITIONS */ /**********************************************************************/ /* functions invoked by system functions: coding mandatory */ /* also defined in sys.h */ /**********************************************************************/ int get_user_code_ver(void); int load_data_block(int, int *); int dispatch_specific(int); int report_data(int); int get_data_summary(int, int *, int *); int set_defaults(void); int det_init(void); int burst_det_init(void); int init_user_var(void); int read_det(void); int data_ready(void); int calib_init(int); int exec_calib(void); /**********************************************************************/ /* us.h */ /* PROTOTYPE DEFINITIONS */ /**********************************************************************/ /* user functions */ /* only definded in user.h */ /**********************************************************************/ /* functions invoked by user messages: */ /* action_id defined */ /**********************************************************************/ int load_control_block(void); int execute_control_block(void); int load_exe_ctr_blk(void); int read_packets(int); int get_det_status(void); int get_LL_status(void); int set_strobe_delay(void); int set_strobe(int); int set_counter_val(void); int set_counter(int); int set_LL_dac(void); int set_LL_voltage(int,int); int set_timeout(void); /*******************************************************************/ int exe_control(int,int); int exe_control_packed(int,int); int load_ctr_block(int *,int, int *); int read_byte(int, int *); int reset_io_fifo(void); int clear_indata_buf(void); int validate_data(int, int *); #endif