/*============================================================================= Name: devMbboPll.c Abs: Device support for LCLS Phase locked loop module (Arcturus Coldfire 5282 processor with LTC2208 ADC) mbbo records. Derived from $EPICS/base/src/rec/mbboRecord.c Auth: 28-jan-2008, Robert Steele: Adaptation for mbbo -----------------------------------------------------------------------------*/ #include "copyright_SLAC.h" /* SLAC copyright comments */ /*----------------------------------------------------------------------------- Mod: (newest to oldest) xx-xxx-2007, Robert Steele 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 "mbboRecord.h" #include "epicsExport.h"/* for epicsExportAddress */ #include /* for DEBUGPRINT */ #include "drvPll.h" #include "pllChannel.hxx" #ifdef DEBUG_PRINT int devMbboFlag = DP_ERROR; #endif typedef struct mbboPll_s { int routine; } mbboPll_t; typedef struct { long number; DEVSUPFUN report; DEVSUPFUN init; DEVSUPFUN init_record; DEVSUPFUN get_ioint_info; DEVSUPFUN write_write; } MBBODSET; LOCAL long init_mbbo(); LOCAL long mbbo_ioinfo(); LOCAL long write_mbbo(); MBBODSET devMbboPll = {5, NULL, NULL, init_mbbo, mbbo_ioinfo, write_mbbo}; epicsExportAddress(dset, devMbboPll); LOCAL long init_mbbo(struct mbboRecord *pmbbo) { mbboPll_t *pmbbop; /* Allocate the memory for this records private data structure */ pmbbop = (mbboPll_t *) malloc(sizeof(mbboPll_t)); if (pmbbop == NULL) { DEBUGPRINT(DP_ERROR, devMbboFlag, ("init_mbbo: %s: out of memory\n", pmbbo->name)); return S_dev_noMemory; } /* Read the DBLINK "out" field to get the routine */ sscanf(pmbbo->out.value.instio.string, "%d", &(pmbbop->routine)); DEBUGPRINT(DP_INFO, devMbboFlag, ("init_mbbo: %s: has parm: %s\n", pmbbo->name, pmbbo->out.value.instio.string)); DEBUGPRINT(DP_INFO, devMbboFlag, ("init_mbbo: %s's dpvt has routine: %d\n", pmbbo->name, pmbbop->routine)); /* Tell the record about its private data structure */ pmbbo->dpvt = pmbbop; return 0; } LOCAL long mbbo_ioinfo( int cmd, struct mbboRecord *pmbbo, IOSCANPVT *ppvt ) { return 0; } LOCAL long write_mbbo(struct mbboRecord *pmbbo) { int rc = 0; mbboPll_t *pmbbop; /* Set this to facilitate easy access to index field */ if (pmbbo->dpvt == NULL) { DEBUGPRINT(DP_ERROR, devMbboFlag, ("write_mbbo: %s: dpvt is NULL\n", pmbbo->name)); return ERROR; } /* point to private data */ pmbbop = (mbboPll_t *) pmbbo->dpvt; DEBUGPRINT(DP_INFO, devMbboFlag, ("write_mbbo: routine: %d\n", pmbbop->routine)); switch (pmbbop->routine) { case 0: rc = pllSetTrackingMode( (int) pmbbo->val ); if (rc == ERROR) { DEBUGPRINT(DP_ERROR, devMbboFlag, ("write_mbbo: %s: unable to set tracking mode to: %d", pmbbo->name, (int) pmbbo->val)); } break; case 1: rc = pllSetFineDacMode( (int) pmbbo->val ); if (rc == ERROR) { DEBUGPRINT(DP_ERROR, devMbboFlag, ("write_mbbo: %s: unable to set fine tracking mode to: %d", pmbbo->name, (int) pmbbo->val)); } break; default: return ERROR; } return rc; }