/*============================================================================= Name: devBoMps.c Abs: Device support for MPS Link node (Arcturus Coldfire 5282 processor) binary out records. Derived from $EPICS/base/src/rec/boRecord.c Auth: 21-jan-2000, Dayle Kotturi (dayle): Initial version for MPS Link Node -----------------------------------------------------------------------------*/ #include "copyright_SLAC.h" /* SLAC copyright comments */ /*----------------------------------------------------------------------------- Mod: (newest to oldest) xx-xxx-2007, Dayle Kotturi: xxxxxxxxxxxxxxxxxxx =============================================================================*/ #include #include #include #include #include #include #include #include #include #include #include #include #include #include "mpsLinkNodeMacros.h" #include "drvMpsLinkNode.h" typedef struct boMps_s { int routine; /* O=intr en/dis, 1=sw trig */ } boMps_t; typedef struct { long number; DEVSUPFUN report; DEVSUPFUN init; DEVSUPFUN init_record; DEVSUPFUN get_ioint_info; DEVSUPFUN write; } BODSET; #ifdef DEBUG_PRINT int devBoMpsFlag = 2; #endif LOCAL long init_bo(); LOCAL long write_bo(); BODSET devBoMpsLinkNode = { 5, NULL, NULL, init_bo, NULL, write_bo }; epicsExportAddress(dset,devBoMpsLinkNode); static long init_bo(boRecord *pbo) { boMps_t *pbop; long rc =0; /* Allocate the memory for this records private data structure */ pbop = (boMps_t *) malloc(sizeof(boMps_t)); if (pbop == NULL) { #ifdef DEBUG_PRINT DEBUGPRINT(DP_ERROR, devBoMpsFlag, ("init_longout: %s: out of memory\n", pbo->name)); #endif return S_dev_noMemory; } #ifdef DEBUG_PRINT DEBUGPRINT(DP_INFO, devBoMpsFlag, ("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, devBoMpsFlag, ("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, devBoMpsFlag, ("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; boMps_t *pbop; /* Set this to facilitate easy access to index field */ if (pbo->dpvt == NULL) { DEBUGPRINT(DP_ERROR, devBoMpsFlag, ("write_bo: %s: dpvt is NULL\n", pbo->name)); return ERROR; } pbop = (boMps_t *)pbo->dpvt; switch (pbop->routine) { case 0: rc = mpsSetCSR1Reset(); #ifdef DEBUG_PRINT DEBUGPRINT(DP_INFO, devBoMpsFlag, ("write_bo: %s: resetting CSR1\n", pbo->name)); #endif break; case 1: rc = mpsSetCSR1DiagnosticModeEnable(); #ifdef DEBUG_PRINT DEBUGPRINT(DP_INFO, devBoMpsFlag, ("write_bo: %s: enabling diagnostic mode in CSR1\n", pbo->name)); #endif break; case 2: rc = mpsSetCSR1Arm(); #ifdef DEBUG_PRINT DEBUGPRINT(DP_INFO, devBoMpsFlag, ("write_bo: %s: arming CSR1\n", pbo->name)); #endif break; case 3: rc = mpsSetCSR1Enable(); #ifdef DEBUG_PRINT DEBUGPRINT(DP_INFO, devBoMpsFlag, ("write_bo: %s: enabling CSR1\n", pbo->name)); #endif break; case 4: rc = mpsSetCSR1TriggerEdgeSelect(pbo->val); #ifdef DEBUG_PRINT DEBUGPRINT(DP_INFO, devBoMpsFlag, ("write_bo: %s: setting trigger edge to %d (0=falling, 1=rising)\n", pbo->name, pbo->val)); #endif break; case 5: rc = mpsSetCSR1MissedTriggerStatus(pbo->val); break; case 6: rc = mpsSetCSR1SoftwareTrigger(pbo->val); break; case 7: rc = mpsSetCSR1DataReady(pbo->val); break; case 8: rc = mpsSetCSR1GateGeneratorSelect(pbo->val); break; case 9: rc = mpsSetCSR1GateTriggerSelect(pbo->val); break; case 10: rc = mpsSetCSR1GatePolarity(pbo->val); break; case 11: rc = mpsSetCSR1GateEnable(pbo->val); break; case 12: rc = mpsSetCSR2TestPulseEnable(pbo->val); break; case 13: rc = mpsSetCSR2TestPulsePolarity(pbo->val); break; case 14: rc = mpsSetCSR2TestPulseTriggerSelect(pbo->val); break; case 15: rc = mpsSetCSR3SyncOutputEnable(pbo->val); break; case 16: rc = mpsSetCSR3SyncPulsePolarity(pbo->val); break; case 17: rc = mpsSetCSR3SyncOutputMode(pbo->val); break; case 18: rc = mpsSetCSR3ADCRangeControl(pbo->val); break; case 19: rc = mpsSetCSR3FBC(pbo->val); break; case 20: rc = mpsClrTriggerErrorCounter(); break; case 21: /* INVASIVE */ rc = mpsQADCReadout(); break; default: rc = ERROR; #ifdef DEBUG_PRINT DEBUGPRINT(DP_ERROR, devBoMpsFlag, ("write_bo: %s: unrecognized routine in bo record: %d\n", pbo->name, (int) pbop->routine)); #endif } return rc; }