/*============================================================================= Name: devAiCnstPad.c Abs: Device support for LCLS Beam Charge 4 channel ADC module (Arcturus Coldfire 5282 processor with LTC2208 ADC) constant analog in records. Derived from $EPICS/base/src/rec/aiRecord.c Updated: 02-mar-2010, Shantha Condamoor (scondam): Initial version for Klystron Test Station 01 Interlocking with PAD. Auth: 16-nov-2005, Dayle Kotturi (dayle): Initial version for LLRF PAD -----------------------------------------------------------------------------*/ #include "copyright_SLAC.h" /* SLAC copyright comments */ /*----------------------------------------------------------------------------- Mod: (newest to oldest) xx-xxx-2007, Dayle Kotturi: xxxxxxxxxxxxxxxxxxx =============================================================================*/ #include #include #include #include "alarm.h" #include "cvtTable.h" #include "dbDefs.h" #include "devLib.h" #include "dbAccess.h" #include "recSup.h" #include "callback.h" #include "devSup.h" #include "dbScan.h" /* for SCAN_IO_EVENT */ #include "link.h" #include "aiRecord.h" /* for aiRecord structure */ #include "epicsExport.h"/* for epicsExportAddress */ #include /* for DEBUGPRINT */ #include "drvPadLan9118.h" /* for pad* */ typedef struct aiCnstPad_s { int index; } aiCnstPad_t; LOCAL long init_ai_cnst(); LOCAL long read_ai_cnst(); typedef struct { long number; DEVSUPFUN report; DEVSUPFUN init; DEVSUPFUN init_record; DEVSUPFUN get_ioint_info; DEVSUPFUN read_ai; DEVSUPFUN special_linconv; } AICNSTDSET; AICNSTDSET devAiCnstPad = { 6, NULL, NULL, init_ai_cnst, NULL, read_ai_cnst, NULL }; epicsExportAddress(dset, devAiCnstPad); #ifdef DEBUG_PRINT int devAiCnstPadFlag = 4; #endif int numReads=0; int numToggles=0; LOCAL long init_ai_cnst(struct aiRecord *pai) { aiCnstPad_t *paip; /* Allocate the memory for this records private data structure */ paip = (aiCnstPad_t *) malloc(sizeof(aiCnstPad_t)); if (paip == NULL) { DEBUGPRINT(DP_ERROR, devAiCnstPadFlag, ("init_ai: %s: no memory for dpvt\n", pai->name)); return S_dev_noMemory; } /* Tell the record about its private data structure */ pai->dpvt = paip; /* hack. used to measure return trip travel time of a single AVG_Q send */ if (strcmp("PAD:LE20:1:IRQ5",pai->name) == 0) { paip->index = 0; #ifdef DEBUG_PRINT DEBUGPRINT(DP_INFO, devAiCnstPadFlag, ("init_ai: %s: init routine with index: %d\n", pai->name, paip->index)); #endif } else { DEBUGPRINT(DP_ERROR, devAiCnstPadFlag, ("init_ai: %s: no init routine\n", pai->name)); return -1; } return 0; } LOCAL long read_ai_cnst(struct aiRecord *pai) { aiCnstPad_t *paip; numReads++; /* Set this to facilitate easy access to index field */ paip = (aiCnstPad_t *)pai->dpvt; switch(paip->index) { case 0: numToggles++; pai->val = padToggleIRQ5(); break; default: pai->udf = 1; return ERROR; } #ifdef DEBUG_PRINT DEBUGPRINT(DP_INFO, devAiCnstPadFlag, ("read_ai: %s: val is: %d", pai->name, (int) pai->val)); #endif return OK; }