/************************************************************************************* ** ir.h - IR Array function support clocking of IR ARRAYS. ************************************************************************************** */ #ifndef IR_H #define IR_H /* return code used by uboot - libstargrasp/cmd.h */ #ifndef PASS #define PASS 0 #define FAIL -1 #endif /* general defines for main.c & other.c */ #ifndef TRUE #define FALSE (0) #define TRUE (1) #define BOOLEAN int #endif #ifndef INRANGE #define INRANGE(a,x,b) ((a) <= (x) && (x) <= (b)) #endif #ifndef MAX #define MAX( a, b ) ((a) < (b) ? (b) : (a)) #define MIN( a, b ) ((a) < (b) ? (a) : (b)) #endif #if !LINUX #define FILE int /* uboot has no FILE type, redefined here for uboot (and don't use it) */ #endif /*----------------------------------------------------------------------------------- ** ir_ or ir_seq related .. **----------------------------------------------------------------------------------- */ /* Device */ #define IRDEVICE_H2 0 /* H2RG Array, 2048x2048, ouputs=32,4 */ #define IRDEVICE_AL 1 /* Aladdin InSB 512x512, output=8 */ #define NUM_IRDEVICE 2 /* Clock-Buffer Mode */ #define CBMODE_FS 0 /* Fowler Single samples */ #define CBMODE_FD 1 /* Fowler Double sample */ #define CBMODE_RAMP 2 /* UP the Ramp Sampling, using Fowler Single */ #define NUM_CBMODE 3 /* Acquisition Mode */ #define ACQMODE_BASIC 0 /* Single FIT image. */ #define ACQMODE_MOVIE 1 /* Series of images */ #define NUM_ACQMODE 2 /*---- SEQ_* commands in a sequence table, a GO sequence is built on these operations ----*/ #define IR_SEQ_GPS_HIGH 0 /* set gps signal high */ #define IR_SEQ_GPS_LOW 1 /* set gps signal low */ #define IR_SEQ_RESET_ARRAY 2 /* reset the device */ #define IR_SEQ_SAMPLE_ARRAY 3 /* sample the device */ #define IR_SEQ_WAIT_USEC 4 /* wait between readouts */ #define NUM_IR_SEQ 5 struct ir_array_t /* provides array dimension */ { int x; int y; int wid; int hgt; }; struct ir_seq_in_t /* input parameter for producing ir_seq data */ { int cbmode; /* Clock/buffer mode, ie: FS, FD, RAMP */ int itime_msec; /* (requested) requested exposure in milliseconds */ int coadd; /* co addition of readout */ int ndr; /* (requested) non-dest reads per sample */ int rsample; /* (requested) number of up-the-ramp samples */ int frame_usec; /* time to readout a frame (sample, pedestal) */ int reset_usec; /* actual time for a reset (global or array reset). */ int glr_enable; /* T=global reset; F=clocking reset */ }; struct ir_seq_t { int cbmode; /* Clock/buffer mode, ie: FS, FD, RAMP - copied from in. */ int itime_usec; /* itime in usec ( could be adjusted) */ int coadd; /* co addition of readout - copied from in. */ int ndr; /* actual ndr (this could be adjusted) */ int rsample; /* actual rsample (could be adjusted) */ int frame_usec; /* time to readout a frame (sample, pedestal) - copied from in. */ int reset_usec; /* actual time for a reset */ int glr_enable; /* T=global reset; F=clocking reset. copied from in. */ int wait_usec; /* delay need to achive the desired integration time */ int total_msec; /* total time the sequence will take, in milliseconds */ int n; /* number of seq[] commands */ char *seq; /* buffer of SEQ command to create an image */ }; /*----------------------------------------------------------------------------------- ** ir_ce sequence related .. **----------------------------------------------------------------------------------- */ struct ir_ce_buf_t /* a buffer to hold CE commands */ { int n; /* number of cmd[] entries */ int64_t nsec; /* total time in ns to execute table */ unsigned int *cmd; /* CE commands buffer */ }; /*---------------- define that help with CE execute times -------------------*/ #define IR_CE_CMD_UPDWR_NS 50 /* UPDWR commands takes 50 ns */ #define IR_CE_PARAM_UPDWR_LO_NS 30 /* CE_PARAM_UPDWR_LO_NS 30 ns */ #define IR_CE_PARAM_UPDWR_HI_NS 30 /* CE_PARAM_UPDWR_HI_NS 30 ns */ #define IR_CE_PARAM_PARSEQ_NS 30 /* CE_PARAM_PARSEQ_X takes 30 ns */ #define IR_CE_PARAM_VIDSEQ_NS 30 /* CE_PARAM_VIDSEQ_X takes 30 ns */ #define IR_CE_CMD_SHUTTER_NS 30 /* SHUTTER OPEN/CLOS takes 30 ns */ #define IR_CE_UPD_OUTPUT_EN 0x8000 /* UPD enable bit - not defined by uboot code */ /*---------------- Help with parseq (Parallel Sequencer or PPG4 ) -------------------*/ #define IR_CE_PSEQ_N 9 /* PSEQ has 9 timeslices */ #define IR_CE_PSEQ_SCALE_10 0 /* PSEQ has scale field so duration can be 10, 20, 40 or 80 ns */ #define IR_CE_PSEQ_SCALE_20 1 /* This library uses the 10ns value */ #define IR_CE_PSEQ_SCALE_40 2 #define IR_CE_PSEQ_SCALE_80 3 /* parallel sequence bits */ #define IR_CE_PSEQ_BIT0 0x01 #define IR_CE_PSEQ_BIT1 0x02 #define IR_CE_PSEQ_BIT2 0x04 #define IR_CE_PSEQ_BIT3 0x08 struct ir_ce_pseq_t /* PARSEQ data structure */ { short scale; unsigned short dur[IR_CE_PSEQ_N]; /* duration is 10 bits, range is 0 to 1023 */ unsigned char bits[IR_CE_PSEQ_N]; /* PSEQ has 4 control lines */ int nsec; /* Time for 1 CE_CMD_PARSEQ iter */ }; /*---------------- Help with vidseq (Video Sequencer or PG3/PG4 ) -------------------*/ #define IR_CE_VSEQ_N 9 /* PSEQ has 9 timeslices */ /* video pattern generator 3 */ #define IR_CE_VPG3_BIT0 0x01 #define IR_CE_VPG3_BIT1 0x02 #define IR_CE_VPG3_BIT2 0x04 /* video pattern generator 4 */ #define IR_CE_VPG4_BIT0 0x01 #define IR_CE_VPG4_BIT1 0x02 #define IR_CE_VPG4_BIT2 0x04 /* hardwired to VCLAMP_IN - do not use */ #define IR_CE_VPG4_ADCTRIG 0x08 /* hardwired to ADCTRIG */ struct ir_ce_vseq_t /* VIDSEQ data structure */ { short reps; /* 1 to 64. Reps for pg3_ only (not pg4) */ unsigned short pg3_dur[IR_CE_VSEQ_N]; /* duration is 10 bits, range is 0 to 1023 */ unsigned char pg3_bits[IR_CE_VSEQ_N]; /* pg3 has 3 control lines */ int pg3_nsec; /* time for 1 ITER */ unsigned short pg4_dur[IR_CE_VSEQ_N]; /* duration is 10 bits, range is 0 to 1023 */ unsigned char pg4_bits[IR_CE_VSEQ_N]; /* pg4 has 4 control lines */ int pg4_nsec; /* time for 1 ITER */ }; struct ir_ce_adc_t /* ADC samples options */ { unsigned short numsample; /* number of SAMPCLK per ADCTRIG edge. 0 to 63 */ unsigned short numchannels; /* color channels to be sample on AD: 0, or 1=R, 2=RG, 3=RGB */ unsigned short multisample_gap; /* additional 10 ns wait between SAMPLECLK pulses: 0-255 */ }; /*---------------------- ** function prototypes **---------------------- */ /*----------------------------- ** ir_seq functions */ void ir_seq_open ( struct ir_seq_t * s, int n, int clear_opt ); void ir_seq_close ( struct ir_seq_t * s); int ir_seq_generate_ce_data ( struct ir_seq_t * s, struct ir_seq_in_t * in, FILE * fp); int ir_seq_cal_wait_usec( int * wait_usec_out, int * itime_usec_out, int * ndr_out, int * rsample_out, int cbmode, int itime_usec, int ndr, int rsample, int frame_usec, int glr_enable ); /*----------------------------- ** ir_ce functions */ /* setup */ void ir_ce_open( struct ir_ce_buf_t * ceb, int n, int clear_opt ); void ir_ce_close( struct ir_ce_buf_t * ceb ); void ir_ce_clear( struct ir_ce_buf_t * ceb ); /* ir_ce_ - parseq & vidseq */ void ir_ce_parseq_param( struct ir_ce_pseq_t *pseq, struct ir_ce_buf_t * ceb, FILE * fp ); void ir_ce_parseq_exe( int iter, struct ir_ce_pseq_t *pseq, struct ir_ce_buf_t * ceb, FILE * fp ); void ir_ce_vidseq_param( struct ir_ce_vseq_t *vseq, struct ir_ce_buf_t * ceb, FILE * fp ); void ir_ce_vidseq_exe( int iter, struct ir_ce_vseq_t *vseq, struct ir_ce_buf_t * ceb, FILE * fp ); void ir_ce_adc_param( struct ir_ce_adc_t *adc, struct ir_ce_buf_t * ceb, FILE * fp ); /* ir_ce - dig out */ void ir_ce_digout_lo( unsigned short *bits, unsigned short clrbits, unsigned short setbits, struct ir_ce_buf_t * ceb, FILE * fp ); void ir_ce_digout_hi( unsigned short *bits, unsigned short clrbits, unsigned short setbits, struct ir_ce_buf_t * ceb, FILE * fp ); /* ir_ce - misc */ void ir_ce_gps( int value, struct ir_ce_buf_t * ceb, FILE * fp ); void ir_ce_cmd_delay_usec( struct ir_ce_buf_t * ceb, int64_t delay_usec, FILE * fp ); void ir_ce_cmd_delay( struct ir_ce_buf_t * ceb, int64_t delay_ns, FILE * fp ); void ir_ce_put( unsigned int ce, int nsec, struct ir_ce_buf_t * ceb, FILE * fp); int ir_ce_slowcnt_to_ns ( int slowcnt ); int ir_ce_slowcnt_to_pseqdur ( int slowcnt ); int ir_ce_slowcnt_to_vseqdur ( int slowcnt ); int ir_adc_to_ns ( int sam, int ch, int mgap ); /* ir_- other */ char * ir_btosl ( char * s, unsigned long l ); void ir_printf( FILE * fp, char * fmt, ...); /* ir_cep_ - commands to write directly to the CE filo */ void ir_cep_delay_usec( ce_t* ce, int64_t delay_usec ); void ir_cep_delay_ns( ce_t* ce, int64_t delay_usec ); /**********************************************************************************/ /* COPIED STUFF FROM SGIR CE.H */ /**********************************************************************************/ #endif /* IR_H */