/*============================================================================= Name: devBoLlrf.c Abs: Device support for LCLS LLRF VME Derived from $EPICS/base/src/rec/boRecord.c Auth: 15-oct-2008, 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 #include #include #include #include #include #include #include #include #include #include "llrfMacros.h" #include "drvLlrf.h" typedef struct boLlrf_s { int routine; int station; } boLlrf_t; typedef struct { long number; DEVSUPFUN report; DEVSUPFUN init; DEVSUPFUN init_record; DEVSUPFUN get_ioint_info; DEVSUPFUN write; } BODSET; /* 11/21/8 Writing errors (level 2) has become too invasive to the processor w.r.t. processing the incoming data streams. Set this to 0 */ #ifdef DEBUG_PRINT int devBoLlrfFlag = 0; #endif LOCAL long init_bo(); LOCAL long write_bo(); BODSET devBoLlrf = { 5, NULL, NULL, init_bo, NULL, write_bo }; epicsExportAddress(dset,devBoLlrf); static long init_bo(boRecord *pbo) { boLlrf_t *pbop; long rc =0; /* Allocate the memory for this records private data structure */ pbop = (boLlrf_t *) malloc(sizeof(boLlrf_t)); if (pbop == NULL) { #ifdef DEBUG_PRINT DEBUGPRINT(DP_ERROR, devBoLlrfFlag, ("init_longout: %s: out of memory\n", pbo->name)); #endif return S_dev_noMemory; } #ifdef DEBUG_PRINT DEBUGPRINT(DP_INFO, devBoLlrfFlag, ("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, devBoLlrfFlag, ("init_bo: %s: has parm: %s\n", pbo->name, pbo->out.value.instio.string)); sscanf(pbo->out.value.instio.string, "%d %d", &(pbop->routine), &(pbop->station)); DEBUGPRINT(DP_INFO, devBoLlrfFlag, ("init_bo: %s's dpvt has routine: %d station: %d\n", pbo->name, pbop->routine, pbop->station)); /* Tell the record about its private data structure */ pbo->dpvt = pbop; /* dont convert */ rc=2; return rc; } static long write_bo(boRecord *pbo) { long rc; boLlrf_t *pbop; /* Set this to facilitate easy access to index field */ if (pbo->dpvt == NULL) { DEBUGPRINT(DP_ERROR, devBoLlrfFlag, ("write_bo: %s: dpvt is NULL\n", pbo->name)); return ERROR; } pbop = (boLlrf_t *)pbo->dpvt; switch (pbop->routine) { case 0: rc = llrfSetPhaseFeedbackControl(pbop->station, pbo->val); #ifdef DEBUG_PRINT DEBUGPRINT(DP_INFO, devBoLlrfFlag, ("write_bo: %s: station %d setting feedback control to %d\n", pbo->name, pbop->station, pbo->val)); #endif break; default: rc = ERROR; #ifdef DEBUG_PRINT DEBUGPRINT(DP_ERROR, devBoLlrfFlag, ("write_bo: %s: unrecognized routine in bo record: %d\n", pbo->name, (int) pbop->routine)); #endif } return rc; }