Files
epics-base/src/dev/devMbbiMpv910.c
Marty Kraimer 9c53cfe9e9 make release
1990-11-30 09:58:54 +00:00

91 lines
2.1 KiB
C
Raw Blame History

This file contains invisible Unicode characters
This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
/* devMbbiMpv910.c */
/* share/src/dev $Id$ */
/* devMbbiMpv910.c - Device Support Routines*/
/* Burr Brown MPV 910 Multibit Binary input */
#include <vxWorks.h>
#include <types.h>
#include <stdioLib.h>
#include <alarm.h>
#include <dbAccess.h>
#include <dbDefs.h>
#include <devSup.h>
#include <link.h>
#include <module_types.h>
#include <mbbiRecord.h>
/* Create the dset for devAiMbbiMpv910 */
long init_record();
long read_mbbi();
struct {
long number;
DEVSUPFUN report;
DEVSUPFUN init;
DEVSUPFUN init_record;
DEVSUPFUN get_ioint_info;
DEVSUPFUN read_mbbi;
}devMbbiMpv910={
5,
NULL,
NULL,
init_record,
NULL,
read_mbbi};
static long masks[] = {
0x00000000,
0x00000001, 0x00000003, 0x00000007, 0x0000000f,
0x0000001f, 0x0000003f, 0x0000007f, 0x000000ff,
0x000001ff, 0x000003ff, 0x000007ff, 0x00000fff,
0x00001fff, 0x00003fff, 0x00007fff, 0x0000ffff,
0x0001ffff, 0x0003ffff, 0x0007ffff, 0x000fffff,
0x001fffff, 0x003fffff, 0x007fffff, 0x00ffffff,
0x01ffffff, 0x03ffffff, 0x07ffffff, 0x0fffffff,
0x1fffffff, 0x3fffffff, 0x7fffffff, 0xffffffff
};
static long init_record(pmbbi)
struct mbbiRecord *pmbbi;
{
char message[100];
/* mbbi.inp must be an VME_IO */
switch (pmbbi->inp.type) {
case (VME_IO) :
pmbbi->mask = masks[pmbbi->nobt]<<pmbbi->inp.value.vmeio.signal;
break;
default :
strcpy(message,pmbbi->name);
strcat(message,": devMbbiMpv910 (init_record) Illegal INP field");
errMessage(S_db_badField,message);
return(S_db_badField);
}
return(0);
}
static long read_mbbi(pmbbi)
struct mbbiRecord *pmbbi;
{
struct vmeio *pvmeio;
int status;
unsigned long value;
pvmeio = (struct vmeio *)&(pmbbi->inp.value);
status = bi_driver(pvmeio->card,pmbbi->mask,BB910,&value);
if(status==0) {
pmbbi->rval = value >> pvmeio->signal;
} else {
if(pmbbi->nsev<MAJOR_ALARM ) {
pmbbi->nsta = READ_ALARM;
pmbbi->nsev = MAJOR_ALARM;
}
}
return(status);
}