/*============================================================================= Name: devBoPad.c Abs: Device support for LCLS Beam Charge 4 channel ADC module (Arcturus Coldfire 5282 processor with LTC2208 ADC) binary out records. Derived from $EPICS/base/src/rec/boRecord.c 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 "dbDefs.h" #include "dbAccess.h" #include "recGbl.h" #include "recSup.h" #include "devLib.h" #include "devSup.h" #include "boRecord.h" #include "epicsExport.h" #include #include "padLan9118Macros.h" #include "drvPadLan9118.h" typedef struct boPad_s { int routine; /* O=intr en/dis, 1=sw trig */ } boPad_t; typedef struct { long number; DEVSUPFUN report; DEVSUPFUN init; DEVSUPFUN init_record; DEVSUPFUN get_ioint_info; DEVSUPFUN write; } BODSET; #ifdef DEBUG_PRINT int devBoPadFlag = 2; #endif LOCAL long init_bo(); LOCAL long write_bo(); BODSET devBoPad = { 5, NULL, NULL, init_bo, NULL, write_bo }; epicsExportAddress(dset,devBoPad); static long init_bo(boRecord *pbo) { boPad_t *pbop; long rc =0; /* Allocate the memory for this records private data structure */ pbop = (boPad_t *) malloc(sizeof(boPad_t)); if (pbop == NULL) { #ifdef DEBUG_PRINT DEBUGPRINT(DP_ERROR, devBoPadFlag, ("init_longout: %s: out of memory\n", pbo->name)); #endif return S_dev_noMemory; } #ifdef DEBUG_PRINT DEBUGPRINT(DP_INFO, devBoPadFlag, ("init_bo: %s: has initial value: %d\n", pbo->name, pbo->val)); #endif /* Read the DBLINK "out" field to get the routine */ DEBUGPRINT(DP_INFO, devBoPadFlag, ("init_bo: %s: has parm: %s\n", pbo->name, pbo->out.value.instio.string)); sscanf(pbo->out.value.instio.string, "%d", &(pbop->routine)); DEBUGPRINT(DP_INFO, devBoPadFlag, ("init_bo: %s's dpvt has routine: %d\n", pbo->name, pbop->routine)); /* Tell the record about its private data structure */ pbo->dpvt = pbop; /* dont convert */ rc=2; return rc; } /* end init_record() */ static long write_bo(boRecord *pbo) { long rc; boPad_t *pbop; /* Set this to facilitate easy access to index field */ if (pbo->dpvt == NULL) { DEBUGPRINT(DP_ERROR, devBoPadFlag, ("write_bo: %s: dpvt is NULL\n", pbo->name)); return ERROR; } pbop = (boPad_t *)pbo->dpvt; switch (pbop->routine) { case 0: switch (pbo->val) { case 1: rc = padEnableIntr(); #ifdef DEBUG_PRINT DEBUGPRINT(DP_INFO, devBoPadFlag, ("write_bo: %s: enabling interrupts\n", pbo->name)); #endif #ifdef DEBUG_PRINT if (rc == ERROR) { DEBUGPRINT(DP_ERROR, devBoPadFlag, ("write_bo: %s: unable to enable interrupts\n", pbo->name)); /* pbo->sevr = INVALID; or something */ } #endif break; case 0: rc = padDisableIntr(); #ifdef DEBUG_PRINT DEBUGPRINT(DP_INFO, devBoPadFlag, ("write_bo: %s: disabling interrupts\n", pbo->name)); #endif #ifdef DEBUG_PRINT if (rc == ERROR) { DEBUGPRINT(DP_ERROR, devBoPadFlag, ("write_bo: %s: unable to disable interrupts\n", pbo->name)); } #endif /*pbo->sevr = INVALID; or something */ break; default: rc = ERROR; #ifdef DEBUG_PRINT DEBUGPRINT(DP_ERROR, devBoPadFlag, ("write_bo: %s: unrecognized value in bo record: %d\n", pbo->name, (int) pbo->val)); #endif /* pbo->sevr = INVALID; or something */ } break; case 1: padSoftTrigger(); #ifdef DEBUG_PRINT DEBUGPRINT(DP_INFO, devBoPadFlag, ("write_bo: %s: triggering software interrupt\n", pbo->name)); #endif break; default: rc = ERROR; #ifdef DEBUG_PRINT DEBUGPRINT(DP_ERROR, devBoPadFlag, ("write_bo: %s: unrecognized routine in bo record: %d\n", pbo->name, (int) pbop->routine)); #endif } return rc; }