merged LANL changes

This commit is contained in:
Jeff Hill
1993-02-12 15:25:22 +00:00
parent c73f52bcb7
commit b1b2ae4da5
12 changed files with 846 additions and 548 deletions

View File

@@ -1,8 +1,6 @@
/* drvVxiAt5.c */
/* share/src/drv @(#) $Id$ */
/* share/src/drv @(#) $Id$ */
/*
* at5vxi_driver.c
*
* driver for at5 designed VXI modules
*
@@ -54,7 +52,8 @@
* .15 joh 072992 print more raw values in io report
* .16 joh 081092 merged at5vxi_models.h into this source
* .17 joh 081992 function name change
* .17 mrk 082692 Added support for new I/O event scanning
* .18 joh 082792 converted to ansi C
* .19 joh 111392 removed shifts on analog IO
*
* Notes:
* ------
@@ -102,9 +101,6 @@
*/
#include <vxWorks.h>
#include <dbDefs.h>
#ifdef V5_vxWorks
# include <iv.h>
#else
@@ -114,23 +110,101 @@
#include <module_types.h>
#include <task_params.h>
#include <fast_lock.h>
#include <epvxiLib.h>
#include <drvSup.h>
#include <dbDefs.h>
#ifndef EPICS_V2
#include <dbScan.h>
#endif
#include <drvEpvxi.h>
static char SccsId[] = "$Id$\t$Date$";
typedef long (*DRVSUPFUN) (); /* ptr to driver support function*/
void log_at5vxi_failure();
void at5vxi_int_service();
void at5vxi_init_card();
void at5vxi_stat();
void at5vxi_shutdown();
void at5vxi_shutdown_card();
int at5vxi_report_timing();
long at5vxi_init();
void at5vxi_int_service(
int addr
);
void at5vxi_init_card(
unsigned addr
);
void at5vxi_shutdown(
void
);
void at5vxi_shutdown_card(
unsigned la
);
int at5vxi_report_timing(
unsigned card,
unsigned channel
);
void at5vxi_stat(
unsigned card,
int level
);
/*
* these should be in a header file
*/
long at5vxi_init(
void
);
int at5vxi_one_shot(
int preset, /* TRUE or COMPLEMENT logic */
double edge0_delay, /* sec */
double edge1_delay, /* set */
unsigned card, /* 0 through ... */
unsigned channel, /* 0 through channels on a card */
int int_source, /* (FALSE)External/(TRUE)Internal source */
void *event_rtn, /* subroutine to run on events */
int event_rtn_param /* parameter to pass to above routine */
);
int at5vxi_one_shot_read(
int *preset, /* TRUE or COMPLEMENT logic */
double *edge0_delay, /* sec */
double *edge1_delay, /* sec */
unsigned card, /* 0 through ... */
unsigned channel, /* 0 through channels on a card */
int *int_source /* (FALSE)External/(TRUE)Internal src */
);
int at5vxi_ai_driver(
unsigned short card,
unsigned short chan,
unsigned short *prval
);
int at5vxi_ao_driver(
unsigned short card,
unsigned short chan,
unsigned short *prval,
unsigned short *prbval
);
int at5vxi_ao_read(
unsigned short card,
unsigned short chan,
unsigned short *pval
);
int at5vxi_bi_driver(
unsigned short card,
unsigned long mask,
unsigned long *prval
);
int at5vxi_bo_driver(
unsigned short card,
unsigned long val,
unsigned long mask
);
struct {
long number;
@@ -207,10 +281,17 @@ struct at5vxi_control{
* Insert or extract a bit field using the standard
* masks and shifts defined below
*/
#define INSERT(FIELD,VALUE)\
(((VALUE)&(FD_/* */FIELD/* */_M))<<(FD_/* */FIELD/* */_S))
#define EXTRACT(FIELD,VALUE)\
( ((VALUE)>>(FD_/* */FIELD/* */_S)) &(FD_/* */FIELD/* */_M))
#ifdef __STDC__
# define INSERT(FIELD,VALUE)\
(((VALUE)&(FD_ ## FIELD ## _M))<<(FD_ ## FIELD ## _S))
# define EXTRACT(FIELD,VALUE)\
( ((VALUE)>>(FD_ ## FIELD ## _S)) &(FD_ ## FIELD ## _M))
#else
# define INSERT(FIELD,VALUE)\
(((VALUE)&(FD_/* */FIELD/* */_M))<<(FD_/* */FIELD/* */_S))
# define EXTRACT(FIELD,VALUE)\
( ((VALUE)>>(FD_/* */FIELD/* */_S)) &(FD_/* */FIELD/* */_M))
#endif
/*
* in the constants below _M is a right justified mask
@@ -348,8 +429,9 @@ struct at5vxi_config{
struct vxi_csr *pcsr; /* vxi device hdr ptr */
struct at5vxi_dd *pdd; /* at5 device dep ptr */
#ifndef EPICS_V2
IOSCANPVT ioscanpvt;
IOSCANPVT ioscanpvt;
#endif
};
LOCAL unsigned long at5vxiDriverID;
@@ -409,7 +491,9 @@ struct at5vxi_model at5vxi_models[] = {
*
*/
long
at5vxi_init()
at5vxi_init(
void
)
{
int r0;
@@ -450,8 +534,10 @@ at5vxi_init()
* disable interrupts on at5vxi cards
*
*/
LOCAL void
at5vxi_shutdown()
LOCAL
void at5vxi_shutdown(
void
)
{
epvxiDeviceSearchPattern dsp;
int s;
@@ -472,9 +558,10 @@ at5vxi_shutdown()
* disable interrupts on at5vxi cards
*
*/
LOCAL void
at5vxi_shutdown_card(la)
unsigned la;
LOCAL
void at5vxi_shutdown_card(
unsigned la
)
{
#ifndef CONTINUOUS_OPERATION
struct vxi_csr *pcsr;
@@ -493,9 +580,10 @@ unsigned la;
* initialize single at5vxi card
*
*/
LOCAL void
at5vxi_init_card(addr)
unsigned addr;
LOCAL
void at5vxi_init_card(
unsigned addr
)
{
int r0;
struct at5vxi_config *pc;
@@ -525,9 +613,10 @@ unsigned addr;
FASTLOCKINIT(&pc->lock);
#ifndef EPICS_V2
scanIoInit(&pc->ioscanpvt);
scanIoInit(&pc->ioscanpvt);
#endif
/*
* revert to power up control
* (temporarily disable the busy period)
@@ -675,9 +764,9 @@ unsigned addr;
*
* update card busy writes and notify the IO interrupt scanner
*/
void
at5vxi_int_service(addr)
int addr;
void at5vxi_int_service(
int addr
)
{
register struct at5vxi_config *pconfig;
@@ -695,7 +784,7 @@ int addr;
io_scanner_wakeup(IO_AI, VXI_AT5_AI, addr);
io_scanner_wakeup(IO_BI, VXI_AT5_BI, addr);
#else
scanIoRequest(pconfig->ioscanpvt);
scanIoRequest(pconfig->ioscanpvt);
#endif
}
@@ -759,7 +848,7 @@ int addr;
for(chan=0; chan<NELEMENTS(pconfig->av); chan++){
if(!pconfig->av[chan].mdt)
continue;
pdd->ao[chan] = pconfig->av[chan].val<<4;
pdd->ao[chan] = pconfig->av[chan].val;
pconfig->av[chan].mdt = FALSE;
}
@@ -795,23 +884,16 @@ int addr;
*
* setup AMD 9513 STC for a repeated two edge timing signal
*/
at5vxi_one_shot(
preset,
edge0_delay,
edge1_delay,
card,
channel,
int_source,
event_rtn,
event_rtn_param)
int preset; /* TRUE or COMPLEMENT logic */
double edge0_delay; /* sec */
double edge1_delay; /* set */
unsigned card; /* 0 through ... */
unsigned channel; /* 0 through channels on a card */
int int_source; /* (FALSE)External/(TRUE)Internal source */
void *event_rtn; /* subroutine to run on events */
int event_rtn_param;/* parameter to pass to above routine */
int at5vxi_one_shot(
int preset, /* TRUE or COMPLEMENT logic */
double edge0_delay, /* sec */
double edge1_delay, /* set */
unsigned card, /* 0 through ... */
unsigned channel, /* 0 through channels on a card */
int int_source, /* (FALSE)External/(TRUE)Internal source */
void *event_rtn, /* subroutine to run on events */
int event_rtn_param /* parameter to pass to above routine */
)
{
int status;
register struct vxi_csr *pcsr;
@@ -903,18 +985,14 @@ int event_rtn_param;/* parameter to pass to above routine */
*
* read back two edge timing from an AMD 9513 STC
*/
at5vxi_one_shot_read( preset,
edge0_delay,
edge1_delay,
card,
channel,
int_source)
int *preset; /* TRUE or COMPLEMENT logic */
double *edge0_delay; /* sec */
double *edge1_delay; /* sec */
unsigned card; /* 0 through ... */
unsigned channel; /* 0 through channels on a card */
int *int_source; /* (FALSE)External/(TRUE)Internal src */
int at5vxi_one_shot_read(
int *preset, /* TRUE or COMPLEMENT logic */
double *edge0_delay, /* sec */
double *edge1_delay, /* sec */
unsigned card, /* 0 through ... */
unsigned channel, /* 0 through channels on a card */
int *int_source /* (FALSE)External/(TRUE)Internal src */
)
{
#ifdef CONTINUOUS_OPERATION
unsigned short iedge0;
@@ -1010,10 +1088,10 @@ int *int_source; /* (FALSE)External/(TRUE)Internal src */
*
*
*/
void
at5vxi_stat(card, level)
unsigned card;
int level;
void at5vxi_stat(
unsigned card,
int level
)
{
struct vxi_csr *pcsr;
register struct at5vxi_dd *pdd;
@@ -1115,10 +1193,11 @@ int level;
*
* diagnostic
*/
LOCAL int
at5vxi_report_timing(card,channel)
unsigned card;
unsigned channel;
LOCAL
int at5vxi_report_timing(
unsigned card,
unsigned channel
)
{
int preset;
double edge0_delay;
@@ -1155,10 +1234,11 @@ unsigned channel;
*
* analog input driver
*/
at5vxi_ai_driver(card,chan,prval)
register unsigned short card;
unsigned short chan;
register unsigned short *prval;
int at5vxi_ai_driver(
unsigned short card,
unsigned short chan,
unsigned short *prval
)
{
register struct at5vxi_dd *pdd;
register struct vxi_csr *pcsr;
@@ -1177,7 +1257,7 @@ register unsigned short *prval;
if(chan >= NELEMENTS(pdd->ai))
return ERROR;
*prval = pdd->ai[chan]>>(unsigned)4;
*prval = pdd->ai[chan];
return OK;
}
@@ -1190,11 +1270,12 @@ register unsigned short *prval;
*
* analog output driver
*/
at5vxi_ao_driver(card,chan,prval,prbval)
register unsigned short card;
register unsigned short chan;
unsigned short *prval;
unsigned short *prbval;
int at5vxi_ao_driver(
unsigned short card,
unsigned short chan,
unsigned short *prval,
unsigned short *prbval
)
{
struct at5vxi_dd *pdd;
register struct vxi_csr *pcsr;
@@ -1214,8 +1295,8 @@ unsigned short *prbval;
return ERROR;
#ifdef CONTINUOUS_OPERATION
pdd->ao[chan] = *prval<<4;
*prbval = pdd->ao[chan]>>(unsigned)4;
pdd->ao[chan] = *prval;
*prbval = pdd->ao[chan];
#else
*PCONTROL(pcsr) = INTDISABLE;
pconfig->av[chan].val = *prval;
@@ -1223,7 +1304,7 @@ unsigned short *prbval;
pconfig->mdt = TRUE;
*PCONTROL(pcsr) = CSRINIT;
*prbval = *prval & 0xfff;
*prbval = *prval;
#endif
return OK;
}
@@ -1236,10 +1317,11 @@ unsigned short *prbval;
*
* analog output read back
*/
at5vxi_ao_read(card,chan,pval)
register unsigned short card;
register unsigned short chan;
unsigned short *pval;
int at5vxi_ao_read(
unsigned short card,
unsigned short chan,
unsigned short *pval
)
{
register struct at5vxi_dd *pdd;
register struct vxi_csr *pcsr;
@@ -1258,7 +1340,7 @@ unsigned short *pval;
if(chan >= NELEMENTS(pdd->ao))
return ERROR;
*pval = pdd->ao[chan] >> 4;
*pval = pdd->ao[chan];
return OK;
}
@@ -1271,10 +1353,11 @@ unsigned short *pval;
*
* binary input driver
*/
at5vxi_bi_driver(card, mask, prval)
register unsigned short card;
unsigned long mask;
register unsigned long *prval;
int at5vxi_bi_driver(
unsigned short card,
unsigned long mask,
unsigned long *prval
)
{
register unsigned long work;
register struct at5vxi_dd *pdd;
@@ -1298,19 +1381,7 @@ register unsigned long *prval;
return OK;
}
#ifndef EPICS_V2
at5vxi_getioscanpvt(card,scanpvt)
unsigned short card;
IOSCANPVT *scanpvt;
{
register struct at5vxi_config *pconfig;
pconfig = AT5VXI_PCONFIG(card);
if(pconfig) *scanpvt = pconfig->ioscanpvt;
return(0);
}
#endif
/*
*
@@ -1319,10 +1390,11 @@ IOSCANPVT *scanpvt;
*
* binary output driver
*/
at5vxi_bo_driver(card,val,mask)
register unsigned short card;
register unsigned long val;
unsigned long mask;
int at5vxi_bo_driver(
unsigned short card,
unsigned long val,
unsigned long mask
)
{
#ifdef CONTINUOUS_OPERATION
register unsigned long work;
@@ -1368,3 +1440,23 @@ unsigned long mask;
return OK;
}
#ifndef EPICS_V2
/*
*
* at5vxi_getioscanpvt()
*
*
*/
at5vxi_getioscanpvt(card,scanpvt)
unsigned short card;
IOSCANPVT *scanpvt;
{
register struct at5vxi_config *pconfig;
pconfig = AT5VXI_PCONFIG(card);
if(pconfig) *scanpvt = pconfig->ioscanpvt;
return(0);
}
#endif

View File

@@ -1,5 +1,5 @@
/* comet_driver.c */
/* share/src/drv $Id$ */
/* share/src/drv @(#)drvComet.c 1.11 9/16/92 */
/*
* Author: Leo R. Dalesio
* Date: 5-92
@@ -39,17 +39,22 @@
* to the waveform memory of the second card
* .05 joh 071592 modified A16 & A32 base addr to match AT8
* address standard
*
* .06 bg 071792 moved addresses to module_types.h
* .07 joh 080592 added io report routines
* .08 ms 080692 added comet_mode routine, modified comet_driver
* and cometDoneTask to allow an external routine
* to control hardware scan mode. Added variable
* scan_control to flag operating mode.
* .09 mrk 082692 added DSET
* .09 mrk 082692 added DSET
* .10 joh 082792 fixed uninitialized csr pointer in comet_driver()
* function
* .11 lrd 091692 add signal support
* .12 joh 092992 card number validation now based on module_types.h.
* signal number checking now based on the array element
* count.
*/
static char *sccsID = "$Id$\t$Date$";
static char *sccsID = "@(#)drvComet.c 1.11\t9/16/92";
/*
* Code Portions
@@ -73,38 +78,13 @@ static char *sccsID = "$Id$\t$Date$";
#include <fast_lock.h>
#include <vme.h>
#include <drvSup.h>
static long report();
static long init();
struct {
long number;
DRVSUPFUN report;
DRVSUPFUN init;
} drvComet={
2,
report,
init};
static long report(level)
int level;
{
comet_io_report(level);
return(0);
}
static long init()
{
comet_init();
return(0);
}
#define COMET_NCHAN 4
#define COMET_CHANNEL_MEM_SIZE 0x20000 /* bytes */
#define COMET_DATA_MEM_SIZE (COMET_CHANNEL_MEM_SIZE*COMET_NCHAN)
static char *shortaddr;
static short scan_control; /* scan type/rate (if >0 normal, <=0 external control) */
/* comet conrtol register map */
struct comet_cr{
unsigned char csrh; /* control and status register - high byte */
@@ -172,13 +152,25 @@ struct comet_config{
struct comet_cr *pcomet_csr; /* pointer to the control/status register */
unsigned short *pdata; /* pointer to data area for this COMET card */
void (*psub)(); /* subroutine to call on end of conversion */
void *parg; /* argument to return to the arming routine */
void *parg[4]; /* argument to return to the arming routine */
FAST_LOCK lock; /* mutual exclusion lock */
};
/* task ID for the comet done task */
int cometDoneTaskId;
struct comet_config *pcomet_config;
static long report();
static long init();
struct {
long number;
DRVSUPFUN report;
DRVSUPFUN init;
} drvComet={
2,
report,
init};
/*
* cometDoneTask
@@ -190,45 +182,46 @@ struct comet_config *pcomet_config;
void
cometDoneTask()
{
register unsigned card;
register struct comet_config *pconfig;
register long i;
register unsigned card;
register struct comet_config *pconfig;
register long i;
while(TRUE){
while(TRUE){
if (scan_control <= 0)
taskDelay(2);
else
{
taskDelay(scan_control);
if (scan_control <= 0)
taskDelay(2);
else{
taskDelay(scan_control);
/* check each card for end of conversion */
for(card=0, pconfig = pcomet_config; card < 2;card++, pconfig++)
{
/* is the card present */
if (!pconfig->pcomet_csr) continue;
/* check each card for end of conversion */
for(card=0, pconfig = pcomet_config; card < 2;card++, pconfig++){
/* is the card present */
if (!pconfig->pcomet_csr) continue;
/* is the card armed */
if (!pconfig->psub) continue;
/* is the card armed */
if (!pconfig->psub) continue;
/* is the digitizer finished conversion */
if (*(pconfig->pdata+FLAG_EOC) == 0xffff) continue;
/* is the digitizer finished conversion */
if (*(pconfig->pdata+FLAG_EOC) == 0xffff) continue;
/* reset each of the control registers */
pconfig->pcomet_csr->csrh = pconfig->pcomet_csr->csrl = 0;
pconfig->pcomet_csr->lcrh = pconfig->pcomet_csr->lcrl = 0;
pconfig->pcomet_csr->gdcrh = pconfig->pcomet_csr->gdcrl = 0;
pconfig->pcomet_csr->acr = 0;
/* reset each of the control registers */
pconfig->pcomet_csr->csrh = pconfig->pcomet_csr->csrl = 0;
pconfig->pcomet_csr->lcrh = pconfig->pcomet_csr->lcrl = 0;
pconfig->pcomet_csr->gdcrh = pconfig->pcomet_csr->gdcrl = 0;
pconfig->pcomet_csr->acr = 0;
/* clear the pointer to the subroutine to allow rearming */
/*pconfig->psub = NULL;*/
/* clear the pointer to the subroutine to allow rearming */
pconfig->psub = NULL;
/* post the event */
/* - is there a bus error for long references to this card?? copy into VME mem? */
(*pconfig->psub)(pconfig->parg,0xffff,pconfig->pdata);
}
}
/* post the event */
/* - is there a bus error for long references to this card?? copy into VME mem? */
if(pconfig->parg[0]) (*pconfig->psub)(pconfig->parg[0],0xffff,pconfig->pdata);
if(pconfig->parg[1]) (*pconfig->psub)(pconfig->parg[1],0xffff,pconfig->pdata+COMET_DATA_MEM_SIZE/4);
if(pconfig->parg[2]) (*pconfig->psub)(pconfig->parg[2],0xffff,pconfig->pdata+COMET_DATA_MEM_SIZE/2);
if(pconfig->parg[3]) (*pconfig->psub)(pconfig->parg[3],0xffff,pconfig->pdata+(COMET_DATA_MEM_SIZE/4)*3);
}
}
}
}
@@ -247,17 +240,14 @@ comet_init()
struct comet_cr *pcomet_cr;
unsigned char *extaddr;
void cometDoneTask();
/* free memory and delete tasks from previous initialization */
if (cometDoneTaskId){
if ((status = taskDelete(cometDoneTaskId)) < 0)
logMsg("\nCOMET: Failed to delete cometDoneTask: %d",status);
}else{
/* if (pcomet_config = (struct comet_config *) calloc(wf_num_cards[COMET], sizeof(struct comet_config))
!= (wf_num_cards[COMET]*sizeof(struct comet_config)){
*/
if ( (pcomet_config = (struct comet_config *)calloc(2,sizeof(struct comet_config))) == 0){
pcomet_config =
(struct comet_config *)calloc(wf_num_cards[COMET],sizeof(struct comet_config));
if (pcomet_config == 0){
logMsg("\nCOMET: Couldn't allocate memory for the configuration data");
return;
}
@@ -294,6 +284,8 @@ comet_init()
pconfig->pdata = (unsigned short *) extaddr;
got_one = TRUE;
FASTLOCKINIT(&pcomet_config[card].lock);
/* initialize the card */
pcomet_cr->csrh = ARM_DIGITIZER | AUTO_RESET_LOC_CNT;
pcomet_cr->csrl = COMET_1MHZ;
@@ -315,10 +307,23 @@ comet_init()
/* start the waveform readback task */
scan_control = 2; /* scan rate in vxWorks clock ticks */
cometDoneTaskId = taskSpawn("cometWFTask",WFDONE_PRI,WFDONE_OPT,WFDONE_STACK,cometDoneTask);
cometDoneTaskId = taskSpawn("cometWFTask",WFDONE_PRI,WFDONE_OPT,WFDONE_STACK,(FUNCPTR) cometDoneTask);
}
}
static long report(level)
int level;
{
comet_io_report(level);
return(0);
}
static long init()
{
comet_init();
return(0);
}
/*
@@ -327,33 +332,36 @@ comet_init()
* initiate waveform read
*
*/
comet_driver(card, pcbroutine, parg)
register unsigned short card;
comet_driver(card, signal, pcbroutine, parg)
register unsigned short card,signal;
register unsigned int *pcbroutine;
register unsigned int *parg; /* number of values read */
{
register struct comet_cr *pcomet_csr=0;
register struct comet_cr *pcomet_csr;
register unsigned short *pcomet_data;
/* check for valid card number */
if(card >= 2) return ERROR;
if(card >= wf_num_cards[COMET])
return ERROR;
if(signal >= NELEMENTS(pcomet_config[card].parg))
return ERROR;
/* check for card present */
if(!pcomet_config[card].pcomet_csr) return ERROR;
/* check for card already armed */
if(pcomet_config[card].psub) return ERROR;
/* mutual exclusion area */
FASTLOCK(&pcomet_config[card].lock);
FASTLOCK(&pcomet_config[card].lock);
/* mark the card as armed */
pcomet_config[card].parg = parg;
pcomet_config[card].psub = (void (*)()) pcbroutine;
if (pcomet_config[card].parg[signal] != 0) pcomet_config[card].parg[signal] = parg;
if (pcomet_config[card].psub) return;
pcomet_config[card].psub = (void (*)()) pcbroutine;
/* exit mutual exclusion area */
FASTUNLOCK(&pcomet_config[card].lock);
pcomet_csr = pcomet_config[card].pcomet_csr;
/* reset each of the control registers */
pcomet_csr->csrh = pcomet_csr->csrl = 0;
pcomet_csr->lcrh = pcomet_csr->lcrl = 0;
@@ -361,7 +369,6 @@ register unsigned int *parg; /* number of values read */
pcomet_csr->acr = 0;
/* arm the card */
pcomet_csr = pcomet_config[card].pcomet_csr;
*(pcomet_config[card].pdata+FLAG_EOC) = 0xffff;
if (scan_control > 0)
{
@@ -425,6 +432,9 @@ unsigned n;
unsigned short *pbegin;
unsigned short *pend;
if (card >= wf_num_cards[COMET])
return ERROR;
pdata = pcomet_config[card].pdata;
psave = (unsigned short *) malloc(n * sizeof(*psave));
if(!psave){
@@ -468,7 +478,7 @@ comet_mode(card,mode,arg,val)
unsigned char *cptr;
int i;
if (card >= 2)
if (card >= wf_num_cards[COMET])
return ERROR;
if (!pcomet_config[card].pcomet_csr)
return ERROR;

View File

@@ -1,6 +1,6 @@
/* drvCompuSm.c */
/* share/src/drv $Id$ */
/* share/src/drv @(#)drvCompuSm.c 1.9 8/27/92 */
/*
* subroutines and tasks that are used to interface to the Compumotor 1830
* stepper motor drivers
@@ -49,6 +49,8 @@
* structure
* .11 06-29-92 joh took file ptr arg out of io report
* .12 08-06-92 joh merged compu sm include file
* .13 08-27-92 joh silenced ANSI C function proto warning
* .14 08-27-92 joh fixed no epics init
*/
#include <vxWorks.h>
#include <vme.h>
@@ -56,9 +58,6 @@
#include <semLib.h> /* library for semaphore support */
#include <wdLib.h>
#include <rngLib.h> /* library for ring buffer support */
#if 0
#include <stdioLib.h>
#endif
/* drvCompuSm.c - Driver Support Routines for CompuSm */
@@ -69,9 +68,8 @@
#include <task_params.h>
/* If any of the following does not exist replace it with #define <> NULL */
static long report();
static long init();
long compu_sm_io_report();
long compu_driver_init();
struct {
long number;
@@ -79,21 +77,8 @@ struct {
DRVSUPFUN init;
} drvCompuSm={
2,
report,
init};
static long report(level)
int level;
{
compu_sm_io_report(level);
}
static long init()
{
int status;
return(0);
}
compu_sm_io_report,
compu_driver_init};
/* compumotor vme interface information */
#define MAX_COMPU_MOTORS 8 /********/
@@ -337,7 +322,7 @@ struct compu_motor compu_motor_array[MAX_COMPU_MOTORS];
/* Forward reference. */
VOID compu_sm_reset();
VOID compu_sm_stat();
/* motor status - returned to the database library routines */
struct motor_data compu_motor_data_array[MAX_COMPU_MOTORS];
@@ -415,7 +400,7 @@ compu_resp_task()
/* 2 - the first byte of the response */
/* process requests in the command ring buffer */
while (rngBufGet(smRespQ,resp,RESPBUF_SZ) == RESPBUF_SZ){
while (rngBufGet(smRespQ,(char *)resp,RESPBUF_SZ) == RESPBUF_SZ){
pmotor_data = &compu_motor_data_array[resp[0]];
/* convert argument */
@@ -546,7 +531,7 @@ register int mdnum;
/* when the buffer is full pass it onto the repsonse task */
if (counts[mdnum] == RESPBUF_SZ){
if (rngBufPut(smRespQ,sm_responses[mdnum],RESPBUF_SZ) != RESPBUF_SZ)
if (rngBufPut(smRespQ,(char *)sm_responses[mdnum],RESPBUF_SZ) != RESPBUF_SZ)
logMsg("smRespQ %d - Full\n",mdnum);
else
semGive (&smRespSem);
@@ -569,6 +554,7 @@ register int mdnum;
*
* initialization for the compumotor 1830 card
*/
long
compu_driver_init(){
register short i;
int status;
@@ -578,9 +564,13 @@ compu_driver_init(){
/* intialize each driver which is present */
none_found = TRUE;
rebootHookAdd(compu_sm_reset);
if ((status = sysBusToLocalAdrs(VME_AM_SUP_SHORT_IO,sm_addrs[CM57_83E], &compu_addr)) != OK){
printf("Addressing error in compumotor steppermotor driver\n");
rebootHookAdd((FUNCPTR)compu_sm_reset);
status = sysBusToLocalAdrs(
VME_AM_SUP_SHORT_IO,
(char *)sm_addrs[CM57_83E],
(char **)&compu_addr);
if (status != OK){
printf("%s: failed to map A16 base\n", __FILE__);
return ERROR;
}
@@ -921,7 +911,7 @@ register short count;
* send a message to the compumotor 1830
*/
VOID compu_sm_io_report(level)
long compu_sm_io_report(level)
short int level;
{
register int i;
@@ -934,6 +924,8 @@ VOID compu_sm_io_report(level)
compu_sm_stat(i);
}
}
return OK;
}
VOID compu_sm_stat(compu_num)

View File

@@ -48,7 +48,8 @@
* .10 joh 071092 added scan task wakeup from ISR
* .11 joh 071092 moved ivec allocation to module_types.h
* .12 joh 072792 added soft reboot int disable
* .13 mrk 090192 support epics I/O event scan, and added DRVET
* .13 joh 082792 converted to V5 vxorks
* .14 mrk 090192 support epics I/O event scan, and added DRVET
*/
@@ -506,7 +507,11 @@ fp_dump()
*/
fp_mon()
{
#ifdef V5_vxWorks
for(semTake(fp_semid,WAIT_FOREVER);fp_dump() != 0;semTake(fp_semid,WAIT_FOREVER));
#else
for(semTake(fp_semid);fp_dump() != 0;semTake(fp_semid));
#endif
}
fp_monitor()
{

View File

@@ -1,7 +1,9 @@
/*
*
* HP E1404A VXI bus slot zero translator
* device dependent routines
* HP E1404A VXI bus slot zero translator
* device dependent routines
*
* share/src/drv @(#)drvHp1404a.c 1.4 8/27/92
*
* Author Jeffrey O. Hill
* Date 030692
@@ -31,12 +33,13 @@
* -----------------
* .01 joh 073092 Added msg device support & interrupt shutdown for
* soft reboots
* .02 joh 082792 converted to ANSI C
*
*
*
*/
static char *sccsId = "$Id$\t$Date$";
static char *sccsId = "@(#)drvHp1404a.c 1.4\t8/27/92";
#include <vxWorks.h>
#ifdef V5_vxWorks
@@ -44,17 +47,17 @@ static char *sccsId = "$Id$\t$Date$";
#else
# include <iv68k.h>
#endif
#include <epvxiLib.h>
#include <drvEpvxi.h>
LOCAL unsigned long hpE1404DriverID;
struct hpE1404_config{
void (*pSignalCallback)();
};
#define TLTRIG(N) (1<<(N))
#define ECLTRIG(N) (1<<((N)+8))
#define LOCAL static
#define NULL 0
#define TRUE 1
#define FALSE 0
#define VXI_HP_MODEL_E1404_REG_SLOT0 0x10
#define VXI_HP_MODEL_E1404_REG 0x110
#define VXI_HP_MODEL_E1404_MSG 0x111
@@ -78,17 +81,55 @@ static char *sccsId = "$Id$\t$Date$";
#define hpE1404PConfig(LA) \
epvxiPConfig((LA), hpE1404DriverID, struct hpE1404_config *)
void hpE1404Int();
void hpE1404InitLA();
void hpE1404ShutDown();
void hpE1404ShutDownLA();
int hpE1404IOReport();
void hpE1404InitLA(
unsigned la
);
struct hpE1404_config{
void (*pSignalCallback)();
};
void hpE1404ShutDown(
void
);
void hpE1404ShutDownLA(
unsigned la
);
/*
* these should be in a header file
*/
int hpE1404SignalConnect(
unsigned la,
void (*pSignalCallback)()
);
void hpE1404Int(
unsigned la
);
int hpE1404RouteTriggerECL(
unsigned la, /* slot zero device logical address */
unsigned enable_map, /* bits 0-5 correspond to trig 0-5 */
/* a 1 enables a trigger */
/* a 0 disables a trigger */
unsigned io_map /* bits 0-5 correspond to trig 0-5 */
/* a 1 sources the front panel */
/* a 0 sources the back plane */
);
int hpE1404RouteTriggerTTL(
unsigned la, /* slot zero device logical address */
unsigned enable_map, /* bits 0-5 correspond to trig 0-5 */
/* a 1 enables a trigger */
/* a 0 disables a trigger */
unsigned io_map /* bits 0-5 correspond to trig 0-5 */
/* a 1 sources the front panel */
/* a 0 sources the back plane */
);
void hpE1404IOReport(
unsigned la,
unsigned level
);
LOCAL unsigned long hpE1404DriverID;
/*
@@ -97,7 +138,9 @@ LOCAL unsigned long hpE1404DriverID;
*
*/
int
hpE1404Init()
hpE1404Init(
void
)
{
int status;
@@ -154,7 +197,9 @@ hpE1404Init()
*
*/
LOCAL
void hpE1404ShutDown()
void hpE1404ShutDown(
void
)
{
int status;
epvxiDeviceSearchPattern dsp;
@@ -182,9 +227,10 @@ void hpE1404ShutDown()
*
*
*/
void
hpE1404ShutDownLA(la)
unsigned la;
LOCAL
void hpE1404ShutDownLA(
unsigned la
)
{
struct vxi_csr *pcsr;
@@ -199,8 +245,10 @@ unsigned la;
* hpE1404InitLA()
*
*/
LOCAL void
hpE1404InitLA(la)
LOCAL
void hpE1404InitLA(
unsigned la
)
{
struct hpE1404_config *pc;
struct vxi_csr *pcsr;
@@ -252,10 +300,10 @@ hpE1404InitLA(la)
* hpE1404SignalConnect()
*
*/
int
hpE1404SignalConnect(la, pSignalCallback)
unsigned la;
void (*pSignalCallback)();
int hpE1404SignalConnect(
unsigned la,
void (*pSignalCallback)()
)
{
struct hpE1404_config *pc;
@@ -275,9 +323,10 @@ void (*pSignalCallback)();
* hpE1404Int()
*
*/
LOCAL void
hpE1404Int(la)
unsigned la;
LOCAL
void hpE1404Int(
unsigned la
)
{
struct vxi_csr *pcsr;
unsigned short signal;
@@ -308,14 +357,15 @@ unsigned la;
* hpE1404RouteTriggerECL
*
*/
hpE1404RouteTriggerECL(la, enable_map, io_map)
unsigned la; /* slot zero device logical address */
unsigned enable_map; /* bits 0-5 correspond to trig 0-5 */
int hpE1404RouteTriggerECL(
unsigned la, /* slot zero device logical address */
unsigned enable_map, /* bits 0-5 correspond to trig 0-5 */
/* a 1 enables a trigger */
/* a 0 disables a trigger */
unsigned io_map; /* bits 0-5 correspond to trig 0-5 */
unsigned io_map /* bits 0-5 correspond to trig 0-5 */
/* a 1 sources the front panel */
/* a 0 sources the back plane */
)
{
struct vxi_csr *pcsr;
@@ -335,14 +385,15 @@ unsigned io_map; /* bits 0-5 correspond to trig 0-5 */
*
*
*/
hpE1404RouteTriggerTTL(la, enable_map, io_map)
unsigned la; /* slot zero device logical address */
unsigned enable_map; /* bits 0-5 correspond to trig 0-5 */
int hpE1404RouteTriggerTTL(
unsigned la, /* slot zero device logical address */
unsigned enable_map, /* bits 0-5 correspond to trig 0-5 */
/* a 1 enables a trigger */
/* a 0 disables a trigger */
unsigned io_map; /* bits 0-5 correspond to trig 0-5 */
unsigned io_map /* bits 0-5 correspond to trig 0-5 */
/* a 1 sources the front panel */
/* a 0 sources the back plane */
)
{
struct vxi_csr *pcsr;
@@ -362,9 +413,10 @@ unsigned io_map; /* bits 0-5 correspond to trig 0-5 */
*
*/
LOCAL
int hpE1404IOReport(la, level)
unsigned la;
unsigned level;
void hpE1404IOReport(
unsigned la,
unsigned level
)
{

View File

@@ -4,7 +4,7 @@
/*
* hpe1368a_driver.c
*
* driver for hpe1368a and hpe1369a VXI modules
* driver for hpe1368a and hpe1369a microwave switch VXI modules
*
* Author: Jeff Hill
* Date: 052192
@@ -38,6 +38,7 @@
*
*/
static char *sccsId = "$Id$\t$Date$"
#include <vxWorks.h>
#include <dbDefs.h>
@@ -50,7 +51,7 @@
#include <module_types.h>
#include <task_params.h>
#include <fast_lock.h>
#include <epvxiLib.h>
#include <drvEpvxi.h>
#include <dbDefs.h>
#include <drvSup.h>
#ifndef EPICS_V2

View File

@@ -1,7 +1,7 @@
/* drvJgvtr1.c */
/* share/src/drv $Id$ */
/* share/src/drv @(#)drvJgvtr1.c 1.9 8/27/92 */
/*
* Author: Jeff Hill
* Author: Jeff Hill
* Date: 5-89
*
* Experimental Physics and Industrial Control System (EPICS)
@@ -50,9 +50,10 @@
* 062592 bg Combined drvJgvtr1.c and jgvtr_driver.c
* 062992 joh removed file pointer argument added to io
* report by bg
* 082792 joh added ANSI C function prototypes
*/
static char *sccsID = "$Id$\t$Date$";
static char *sccsID = "@(#)drvJgvtr1.c 1.9\t8/27/92";
/*
* Code Portions
@@ -85,9 +86,40 @@ static char *sccsID = "$Id$\t$Date$";
# endif
/* If any of the following does not exist replace it with #define <> NULL */
static long jgvtr1_io_report();
static long jgvtr1_init();
long jgvtr1_io_report(
unsigned level
);
long jgvtr1_init(
void
);
void jgvtr1_int_service(
void
);
void jgvtr1DoneTask(
void
);
int jgvtr1_dump(
unsigned card,
unsigned n
);
/*
* should be in a header file
*/
int jgvtr1_driver(
unsigned short card,
unsigned int *pcbroutine,
unsigned int *parg /* number of values read */
);
int jgvtr1_stat(
unsigned card,
short int level
);
struct {
long number;
@@ -169,7 +201,9 @@ int jgvtr1_max_card_count;
* intialize the driver for the joerger vtr1
*
*/
long jgvtr1_init()
long jgvtr1_init(
void
)
{
register unsigned card;
register unsigned card_count = 0;
@@ -178,8 +212,6 @@ long jgvtr1_init()
short readback;
int status;
void jgvtr1_int_service();
void jgvtr1DoneTask();
if ((status = sysBusToLocalAdrs(VME_AM_SUP_SHORT_IO,0,&shortaddr)) != OK){
printf("Addressing error for short address in jgvtr1 driver\n");
@@ -250,7 +282,7 @@ long jgvtr1_init()
WFDONE_PRI,
WFDONE_OPT,
WFDONE_STACK,
jgvtr1DoneTask);
(FUNCPTR) jgvtr1DoneTask);
if(status == ERROR)
return ERROR;
@@ -275,10 +307,11 @@ long jgvtr1_init()
* initiate waveform read
*
*/
jgvtr1_driver(card, pcbroutine, parg)
register unsigned short card;
register unsigned int *pcbroutine;
register unsigned int *parg; /* number of values read */
int jgvtr1_driver(
unsigned short card,
unsigned int *pcbroutine,
unsigned int *parg /* number of values read */
)
{
if(card >= jgvtr1_max_card_count)
return ERROR;
@@ -309,8 +342,7 @@ register unsigned int *parg; /* number of values read */
*
*/
#ifdef INTERRUPT_HARDWARE_FIXED
void
jgvtr1_int_service()
void jgvtr1_int_service(void)
{
semGive(jgvtr1_interrupt);
}
@@ -324,8 +356,9 @@ jgvtr1_int_service()
* and call back to the database with the waveform size and address
*
*/
void
jgvtr1DoneTask()
void jgvtr1DoneTask(
void
)
{
register unsigned card;
register struct jgvtr1_config *pconfig;
@@ -336,7 +369,7 @@ jgvtr1DoneTask()
/* dont allow two of this task */
if(started)
exit(1);
exit(0);
started = TRUE;
while(TRUE){
@@ -439,8 +472,9 @@ jgvtr1DoneTask()
*
*
*/
long jgvtr1_io_report(level)
short int level;
long jgvtr1_io_report(
unsigned level
)
{
unsigned card;
unsigned nelements;
@@ -472,9 +506,10 @@ short int level;
*
*
*/
jgvtr1_stat(card,level)
unsigned card;
short int level;
int jgvtr1_stat(
unsigned card,
short int level
)
{
struct jgvtr1_status stat;
int status;
@@ -532,9 +567,10 @@ short int level;
*
*/
LOCAL
int jgvtr1_dump(card, n)
unsigned card;
unsigned n;
int jgvtr1_dump(
unsigned card,
unsigned n
)
{
register unsigned short *pjgdata;
unsigned short *pread;

View File

@@ -34,6 +34,7 @@
* .01 071792 joh Added model name registration
* .02 081992 joh vxiUniqueDriverID -> epvxiUniqueDriverID
* .03 082692 mrk Added support for new I/O event scanning and DRVET
* .03 012893 joh include file name change
*
*/
@@ -49,7 +50,7 @@
#include <module_types.h>
#include <task_params.h>
#include <fast_lock.h>
#include <epvxiLib.h>
#include <drvEpvxi.h>
#include <dbDefs.h>
#include <drvSup.h>
#ifndef EPICS_V2

View File

@@ -1,6 +1,6 @@
/* drvMz8310.c */
/* share/src/drv $Id$ */
/* share/src/drv @(#)drvMz8310.c 1.9 8/27/92 */
/*
* Routines specific to the MZ8310 Low level routines for the AMD STC in
* stc_driver.c
@@ -175,10 +175,11 @@ static struct mz8310_strap_info mz8310_strap[MZ8310CHANCNT] =
/* forward reference. */
void mz8310_reset();
int mz8310_io_report_card(int card, int level);
long mz8310_io_report(level)
short int level;
int level;
{
unsigned card;
@@ -191,7 +192,7 @@ short int level;
LOCAL
int mz8310_io_report_card(card,level)
int mz8310_io_report_card(int card, int level)
{
unsigned int channel, chip;
int status;

View File

@@ -1,3 +1,4 @@
/* drvOms.c */
/* share/src/drv $Id$ */
/*
@@ -57,6 +58,12 @@
* .16 06-26-92 bg Combined drvOms.c with oms_driver.c
* .17 06-29-92 joh took file pointer arg out of io report
* .18 08-11-92 joh io report format cleanup
* .19 08-26-92 mrk changed oms poll rate
* .20 08-27-92 joh silenced gcc warnings
* .21 08-27-92 joh started to fix driver function which returned
* with and without status but left new code #if'd
* out until the proper status can be determined
* .22 08-03-92 joh merged the include oms file
*/
/* data requests are made from the oms_task at
@@ -77,14 +84,13 @@
#include <dbDefs.h>
#include <drvSup.h>
#include <module_types.h>
#include <drvOms.h>
#include <steppermotor.h>
#define OMS_INT_LEV 5
/* If any of the following does not exist replace it with #define <> NULL */
static long report();
static long init();
long oms_io_report(int level);
long oms_driver_init(void);
struct {
long number;
@@ -92,22 +98,47 @@ struct {
DRVSUPFUN init;
} drvOms={
2,
report,
init};
static long report(level)
int level;
{
oms_io_report(level);
}
oms_io_report,
oms_driver_init};
#define MAX_OMS_CARDS 8
#define MAX_OMS_CHANNELS 6
/* motor information */
struct oms_motor{
short active; /* flag to tell the oms_task if the motor is moving */
int callback; /* routine in database library to call with status */
int callback_arg; /* argument to callback routine */
short update_count;
short stop_count;
};
#define MIRQE 0x80
#define TRANSMIT_BUFFER_EMPTY 0x40
#define INPUT_BUFFER_FULL 0x20
#define MDONE 0x10
#define OMS_ENCODER 0x04
#define OMS_CMD_ERROR 0x01
struct vmex_motor{
char unused0;
char data;
char unused1;
char done;
char unused2;
char control;
char unused3;
char status;
char unused4;
char vector;
char unused5[6];
};
/* oms message defines */
#define OMS_MSG_SZ 32 /* response message size */
#define OMS_RESP_Q_SZ (OMS_MSG_SZ*500) /* response ring buffer size */
static long init()
{
int status;
oms_driver_init();
return(0);
}
/*
* a rate of 10Hz when a motor is active
@@ -143,9 +174,10 @@ char read_buffer[MAX_OMS_CARDS][34];
/* forward reference. */
VOID oms_reset();
LOCAL void oms_intr();
oms_intr(card)
LOCAL void oms_intr(card)
register short card;
{
register struct vmex_motor *pmotor;
@@ -158,7 +190,7 @@ register short card;
/* pointer to this motor */
if ((pmotor = oms_motor_present[card]) == 0){
intUnlock(key);
return(0);
return;
}
pinx = &resp_inx[card];
@@ -196,7 +228,6 @@ register short card;
}
}
intUnlock(key);
return(0);
}
/*
@@ -227,7 +258,7 @@ oms_resp_task()
# endif
/* process requests in the command ring buffer */
while (rngBufGet(oms_resp_q,resp,OMS_MSG_SZ) == OMS_MSG_SZ){
while (rngBufGet(oms_resp_q,(char *)resp,OMS_MSG_SZ) == OMS_MSG_SZ){
if (oms_debug)
printf("card: %d msg:%s\n",resp[0],&resp[1]);
/* get the card number and pointers to the state and channel */
@@ -252,14 +283,14 @@ oms_resp_task()
/* convert encoder position */
}else if (*pstate == 1){
sscanf(&resp[1],"%d",&temp);
sscanf((char *)&resp[1],"%d",&temp);
pmotor_data_array->encoder_position = temp;
*pstate = 0;
/* convert motor position */
/* use the motor position for detecting end of motion because */
/* all motors use this, not all motors have encoders */
}else if (*pstate == 2){
sscanf(&resp[1],"%d",&temp);
sscanf((char *)&resp[1],"%d",&temp);
if ((pmotor_data_array->motor_position == temp)
&& (poms_motor_array->active == TRUE)){
poms_motor_array->stop_count++;
@@ -333,7 +364,6 @@ oms_task()
motor_active = TRUE;
while (motor_active){
motor_active = FALSE;
taskDelay(2);
for (channel = 0; channel < MAX_OMS_CHANNELS; channel++){
pmotor = oms_motor_present[0];
for (card = 0; card < MAX_OMS_CARDS; card++,pmotor++){
@@ -350,6 +380,7 @@ oms_task()
oms_send_msg(oms_motor_present[card],oms_msg);
}
}
taskDelay(2);
}
}
}
@@ -360,7 +391,8 @@ oms_task()
*
* initialize all oms drivers present
*/
oms_driver_init(){
long oms_driver_init(void)
{
struct vmex_motor *pmotor;
short i,j,got_one;
int status;
@@ -374,10 +406,13 @@ oms_driver_init(){
/* find all cards present */
got_one = FALSE;
status = sysBusToLocalAdrs(VME_AM_SUP_SHORT_IO,sm_addrs[OMS_6AXIS], &localaddr);
status = sysBusToLocalAdrs(
VME_AM_SUP_SHORT_IO,
(char *)sm_addrs[OMS_6AXIS],
&localaddr);
if (status != OK){
logMsg("Addressing error in oms driver\n");
return(ERROR);
return ERROR;
}
rebootHookAdd(oms_reset);
pmotor = (struct vmex_motor *)localaddr;
@@ -442,7 +477,8 @@ oms_driver_init(){
}
}
}
return(0);
return OK;
}
/*
@@ -524,7 +560,7 @@ int arg2;
if (arg1 == 0){
oms_move_msg[1] = oms_motor_specifier[channel];
}else{
return(0);
return (0);
}
oms_send_msg(oms_motor_present[card],oms_move_msg);
@@ -571,8 +607,10 @@ int arg2;
break;
}
return(0);
return (0);
}
char last_msg[80];
int oms_count,oms_icount,oms_illcmd,oms_sleep,oms_isleep;
@@ -600,8 +638,13 @@ i = 0;
oms_icount++;
if ((oms_icount % 5) == 0){
oms_isleep++;
/* A taskDelay makes a 68040 wait frequently */
/*taskDelay(1);*/
/*
* A taskDelay makes a 68040
* wait frequently
*/
# ifdef 0
taskDelay(1);
# endif
}
}
pmotor->data = 0x19; /* reset */
@@ -610,8 +653,13 @@ i = 0;
oms_count++;
if ((oms_count % 5) == 0){
oms_sleep++;
/* A taskDelay makes a 68040 wait frequently */
/*taskDelay(1);*/
/*
* A taskDelay makes a 68040
* wait frequently
*/
# ifdef 0
taskDelay(1);
# endif
}
}
pmotor->data = *pmsg;
@@ -622,8 +670,7 @@ i = 0;
semGive(&oms_send_sem);
}
oms_io_report(level)
short int level;
long oms_io_report(int level)
{
register short int i,j;
@@ -637,6 +684,8 @@ short int level;
}
}
return OK;
}
VOID oms_sm_stat(card,channel)

View File

@@ -36,14 +36,27 @@
* should have been used
* .04 08-11-92 joh now allows for runtime reconfiguration of
* the addr map
* .05 08-25-92 mrk added DSET; made masks a macro
* .06 08-26-92 mrk support epics I/O event scan
* .05 08-25-92 mrk added DSET; made masks a macro
* .06 08-26-92 mrk support epics I/O event scan
* .07 08-26-92 joh task params from task params header
* .08 08-26-92 joh removed STDIO task option
* .09 08-26-92 joh increased stack size for V5
* .10 08-26-92 joh increased stack size for V5
* .11 08-27-92 joh fixed no status return from bo driver
* .12 09-03-92 joh fixed wrong index used when testing for card
* present
* .13 09-03-92 joh fixed structural problems in the io
* report routines which caused messages to
* be printed even when no xy240's are present
* .14 09-17-92 joh io report now tabs over detailed info
* .15 09-18-92 joh documentation
*/
#include "vxWorks.h"
#include "taskLib.h"
#include "vme.h"
#include "module_types.h"
#include "task_params.h"
#include <drvSup.h>
#ifndef EPICS_V2
#include <dbDefs.h>
@@ -54,38 +67,12 @@ s complete */
#define interruptAccept wakeup_init
#endif
static long report();
static long init();
struct {
long number;
DRVSUPFUN report;
DRVSUPFUN init;
} drvXy240={
2,
report,
init};
static long report(level)
int level;
{
xy240_io_report(level);
return(0);
}
static long init()
{
xy240_init();
return(0);
}
#define XY240_ADDR0 (bi_addrs[XY240_BI])
#define XY240_MAX_CARDS (bi_num_cards[XY240_BI])
#define XY240_MAX_CHANS (bi_num_channels[XY240_BI])
#define masks(K) ((1<<K))
/*xy240 memory structure*/
struct dio_xy240{
char begin_pad[0x80]; /*go to interface block*/
@@ -109,7 +96,7 @@ struct dio_rec
unsigned short sport0_1; /*saved inputs*/
unsigned short sport2_3; /*saved inputs*/
#ifndef EPICS_V2
IOSCANPVT ioscanpvt;
IOSCANPVT ioscanpvt;
#endif
/*short dio_vec;*/ /*interrupt vector*/
/*unsigned int intr_num;*/ /*interrupt count*/
@@ -119,6 +106,34 @@ struct dio_rec
LOCAL
struct dio_rec *dio; /*define array of control structures*/
static long report();
static long init();
struct {
long number;
DRVSUPFUN report;
DRVSUPFUN init;
} drvXy240={
2,
report,
init};
static long report(level)
int level;
{
xy240_io_report(level);
return(0);
}
void xy240_bi_io_report(int card);
void xy240_bo_io_report(int card);
static long init()
{
xy240_init();
return(0);
}
/*dio_int
*
*interrupt service routine
@@ -164,7 +179,7 @@ dio_scan()
#ifdef EPICS_V2
io_scanner_wakeup(IO_BI,XY240_BI,i);
#else
scanIoRequest(dio[i].ioscanpvt);
scanIoRequest(dio[i].ioscanpvt);
#endif
dio[i].sport0_1 = dio[i].dptr->port0_1;
dio[i].sport2_3 = dio[i].dptr->port2_3;
@@ -179,17 +194,19 @@ dio_scan()
}
/*DIO DRIVER INIT
*
*initialize xy240 dig i/o card
*/
xy240_init()
{
short junk;
register short i;
short junk;
register short i;
struct dio_xy240 *pdio_xy240;
static char *name = "scan";
int tid,status;
int tid;
int status;
int at_least_one_present = FALSE;
/*
* allow for runtime reconfiguration of the
@@ -202,41 +219,52 @@ xy240_init()
status = sysBusToLocalAdrs(VME_AM_SUP_SHORT_IO,XY240_ADDR0,&pdio_xy240);
if (status != OK){
printf("Addressing error in xy240 driver\n");
return ERROR;
printf("%s: Unable to map the XY240 A16 base addr\n", __FILE__);
return ERROR;
}
for (i = 0; i < XY240_MAX_CARDS; i++, pdio_xy240++){
if (vxMemProbe(pdio_xy240,READ,2,&junk) == OK){
if (vxMemProbe(pdio_xy240,READ,2,&junk) != OK){
dio[i].dptr = 0;
continue;
}
/*
register initialization
*/
/*
* register initialization
*/
pdio_xy240->csr = 0x3;
pdio_xy240->iclr_vec = 0x00; /*clear interrupt input register latch*/
pdio_xy240->flg_dir = 0xf0; /*ports 0-3,input;ports 4-7,output*/
dio[i].sport2_3 = pdio_xy240->port2_3; /*read and save high values*/
pdio_xy240->iclr_vec = 0x00; /*clear interrupt input register latch*/
pdio_xy240->flg_dir = 0xf0; /*ports 0-3,input;ports 4-7,output*/
dio[i].sport2_3 = pdio_xy240->port2_3; /*read and save high values*/
dio[i].dptr = pdio_xy240;
at_least_one_present = TRUE;
#ifndef EPICS_V2
scanIoInit(&dio[i].ioscanpvt);
scanIoInit(&dio[i].ioscanpvt);
#endif
}
else{
dio[i].dptr = 0;
}
}
}
if (dio[i].dptr)
{
if ((tid = taskNameToId(name)) != ERROR)
taskDelete(tid);
if (taskSpawn(name,111,VX_SUPERVISOR_MODE|VX_STDIO,1000,dio_scan) == ERROR)
printf("Unable to create scan task\n");
}
return(0);
if (at_least_one_present)
{
if ((tid = taskNameToId(XY240_NAME)) != ERROR){
taskDelete(tid);
}
status = taskSpawn(
XY240_NAME,
XY240_PRI,
XY_240_OPT,
XY_240_STACK,
dio_scan);
if (status == ERROR){
printf("Unable to create XY240 scan task\n");
}
}
return OK;
}
#ifndef EPICS_V2
@@ -244,12 +272,13 @@ xy240_getioscanpvt(card,scanpvt)
unsigned short card;
IOSCANPVT *scanpvt;
{
if ((card >= XY240_MAX_CARDS) || (!dio[card].dptr)) return(0);
*scanpvt = dio[card].ioscanpvt;
return(0);
if ((card >= XY240_MAX_CARDS) || (!dio[card].dptr)) return(0);
*scanpvt = dio[card].ioscanpvt;
return(0);
}
#endif
/*
* XY240_BI_DRIVER
*
@@ -307,20 +336,22 @@ xy240_bo_driver(card,val,mask)
register unsigned int val;
{
register unsigned int work;
if ((card >= XY240_MAX_CARDS) || (!dio[card].dptr))
return -1;
/* use structure to handle high and low short swap */
/* get current output */
if ((card >= XY240_MAX_CARDS) || (!dio[card].dptr))
return ERROR;
work = (dio[card].dptr->port4_5 << 16)
/* use structure to handle high and low short swap */
/* get current output */
work = (dio[card].dptr->port4_5 << 16)
+ dio[card].dptr->port6_7;
work = (work & ~mask) | (val & mask);
work = (work & ~mask) | (val & mask);
dio[card].dptr->port6_7 = (unsigned short)(work >> 16);
dio[card].dptr->port4_5 = (unsigned short)work;
return(0);
dio[card].dptr->port6_7 = (unsigned short)(work >> 16);
dio[card].dptr->port4_5 = (unsigned short)work;
return OK;
}
@@ -368,7 +399,10 @@ else if (port == 7)
dio[card].dptr->port6_7 = val;
return -7;
}
return(0);
else{
printf("use ports 4-7\n");
return -8;
}
}
/*XY240_WRITE
@@ -382,124 +416,116 @@ xy240_write(card,val)
{
return xy240_bo_driver(card,val,0xffffffff);
}
#define masks(K) ((1<<K))
long
xy240_io_report(level)
short int level;
{
short int i;
int card;
for (i = 0; i < XY240_MAX_CARDS; i++){
for (card = 0; card < XY240_MAX_CARDS; card++){
if(dio[i].dptr){
printf("B*: XY240:\tcard %d\n",i);
if(dio[card].dptr){
printf("B*: XY240:\tcard %d\n",card);
if (level >= 1){
xy240_bi_io_report();
xy240_bo_io_report();
xy240_bi_io_report(card);
xy240_bo_io_report(card);
}
}
}
}
xy240_bi_io_report(){
short int num_chans,i,j,k,l,m,status;
void xy240_bi_io_report(int card)
{
short int num_chans,j,k,l,m,status;
int ival,jval,kval,lval,mval;
unsigned int *prval;
short int first_time = 0;
printf("\tBinary In Channels 0 - 31\n");
num_chans = XY240_MAX_CHANS;
for (i = 0; i < XY240_MAX_CARDS; i++){
if(dio[i].dptr){
if(first_time < 1){
printf("XY240 BINARY IN CHANNELS:\n");
first_time = 1;
}
for(j=0,k=1,l=2,m=3;j < num_chans,k < num_chans, l< num_chans,
m < num_chans; j+=IOR_MAX_COLS,k+= IOR_MAX_COLS,l+= IOR_MAX_COLS,
m += IOR_MAX_COLS){
if(j < num_chans){
xy240_bi_driver(i,masks(j),&jval);
if (jval != 0)
jval = 1;
printf("Chan %d = %x\t ",j,jval);
}
if(k < num_chans){
xy240_bi_driver(i,masks(k),&kval);
if (kval != 0)
kval = 1;
printf("Chan %d = %x\t ",k,kval);
}
if(l < num_chans){
xy240_bi_driver(i,masks(l),&lval);
if (lval != 0)
lval = 1;
printf("Chan %d = %x \t",l,lval);
}
if(m < num_chans){
xy240_bi_driver(i,masks(m),&mval);
if (mval != 0)
mval = 1;
printf("Chan %d = %x \n",m,mval);
}
}
}
if(!dio[card].dptr){
return;
}
}
xy240_bo_io_report(){
short int num_chans,i,j,k,l,m,status;
int ival,jval,kval,lval,mval;
unsigned int *prval;
short int first_time = 0;
printf("\tXY240 BINARY IN CHANNELS:\n");
for( j=0,k=1,l=2,m=3;
j < num_chans,k < num_chans, l< num_chans, m < num_chans;
j+=IOR_MAX_COLS,k+= IOR_MAX_COLS,l+= IOR_MAX_COLS, m += IOR_MAX_COLS){
printf("\tBinary Out Channels 0 - 31\n");
num_chans = XY240_MAX_CHANS;
for (i = 0; i < XY240_MAX_CARDS; i++){
if(dio[i].dptr){
if(first_time < 1){
printf("XY240 BINARY OUT CHANNELS:\n");
first_time = 1;
}
for(j=0,k=1,l=2,m=3;j < num_chans,k < num_chans, l < num_chans,m
< num_chans; j+=IOR_MAX_COLS,k+= IOR_MAX_COLS,l+= IOR_MAX_COLS,
m += IOR_MAX_COLS){
if(j < num_chans){
xy240_bo_read(i,masks(j),&jval);
if (jval != 0)
jval = 1;
printf("Chan %d = %x\t ",j,jval);
}
if(k < num_chans){
xy240_bo_read(i,masks(k),&kval);
if (kval != 0)
kval = 1;
printf("Chan %d = %x\t ",k,kval);
}
if(l < num_chans){
xy240_bo_read(i,masks(l),&lval);
if (lval != 0)
lval = 1;
printf("Chan %d = %x \t",l,lval);
}
if(m < num_chans){
xy240_bo_read(i,masks(m),&mval);
if (mval != 0)
mval = 1;
printf("Chan %d = %x \n",m,mval);
}
}
if(j < num_chans){
xy240_bi_driver(card,masks(j),&jval);
if (jval != 0)
jval = 1;
printf("\tChan %d = %x\t ",j,jval);
}
if(k < num_chans){
xy240_bi_driver(card,masks(k),&kval);
if (kval != 0)
kval = 1;
printf("Chan %d = %x\t ",k,kval);
}
if(l < num_chans){
xy240_bi_driver(card,masks(l),&lval);
if (lval != 0)
lval = 1;
printf("Chan %d = %x \t",l,lval);
}
if(m < num_chans){
xy240_bi_driver(card,masks(m),&mval);
if (mval != 0)
mval = 1;
printf("Chan %d = %x \n",m,mval);
}
}
}
void xy240_bo_io_report(int card)
{
short int num_chans,j,k,l,m,status;
int ival,jval,kval,lval,mval;
unsigned int *prval;
num_chans = XY240_MAX_CHANS;
if(!dio[card].dptr){
return;
}
printf("\tXY240 BINARY OUT CHANNELS:\n");
for( j=0,k=1,l=2,m=3;
j < num_chans,k < num_chans, l < num_chans,m < num_chans;
j+=IOR_MAX_COLS,k+= IOR_MAX_COLS,l+= IOR_MAX_COLS, m += IOR_MAX_COLS){
if(j < num_chans){
xy240_bo_read(card,masks(j),&jval);
if (jval != 0)
jval = 1;
printf("\tChan %d = %x\t ",j,jval);
}
if(k < num_chans){
xy240_bo_read(card,masks(k),&kval);
if (kval != 0)
kval = 1;
printf("Chan %d = %x\t ",k,kval);
}
if(l < num_chans){
xy240_bo_read(card,masks(l),&lval);
if (lval != 0)
lval = 1;
printf("Chan %d = %x \t",l,lval);
}
if(m < num_chans){
xy240_bo_read(card,masks(m),&mval);
if (mval != 0)
mval = 1;
printf("Chan %d = %x \n",m,mval);
}
}
}

View File

@@ -1,3 +1,4 @@
/* drvXy566.c */
/* share/src/drv $Id$ */
@@ -75,19 +76,22 @@
* raw value if there is a demand.
* .18 08-10-92 joh cleaned up the merge of the xy566 wf and ai
* drivers
* .19 08-25-92 mrk replaced call to ai_driver by ai_xy566_driver
* .20 08-26-92 mrk support epics I/O event scan
* .19 08-25-92 mrk replaced call to ai_driver by ai_xy566_driver
* .20 08-26-92 mrk support epics I/O event scan
* .21 08-27-92 joh fixed routines which return with and without
* status
* .22 08-27-92 joh fixed nonexsistant EPICS init
*/
#include <vxWorks.h>
#include <vme.h>
#include <dbDefs.h>
#include <drvSup.h>
#include <module_types.h>
#include <task_params.h>
#ifndef EPICS_V2
#include <dbScan.h>
#endif
#include <drvSup.h>
#include <module_types.h>
#include <task_params.h>
static char SccsId[] = "$Id$\t$Date$ ";
@@ -100,10 +104,17 @@ static char SccsId[] = "$Id$\t$Date$ ";
* senb/senw Writes to the 566 where the call provides a req'd delay
*/
/* If any of the following does not exist replace it with #define <> NULL */
long report();
long init();
#if 0
long xy566_io_report();
long ai_566_init();
#endif
struct {
long number;
DRVSUPFUN report;
@@ -113,6 +124,12 @@ struct {
report,
init};
static long init()
{
ai_566_init();
xy566_init();
return(0);
}
static long report()
{
@@ -120,13 +137,6 @@ static long report()
xy566_io_report();
}
static long init()
{
ai_566_init();
xy566_init();
return(0);
}
#define MAX_SE_CARDS (ai_num_cards[XY566SE])
#define MAX_DI_CARDS (ai_num_cards[XY566DI])
#define MAX_DIL_CARDS (ai_num_cards[XY566DIL])
@@ -242,11 +252,14 @@ unsigned int **proutine;
/* VME memory Short Address Space is set up in gta_init */
int wfDoneId; /* waveform done task ID */
/* forward references */
void senw();
VOID xy566_reset();
int ai_xy566_init();
int ai_xy566l_init();
VOID rval_convert();
VOID xy566_rval_report();
static acro_intr(ap)
@@ -275,16 +288,18 @@ unsigned char val;
}
ai566_intr(i)
short i;
short i;
{
register struct ai566 *ap = pai_xy566dil[i];
register struct ai566 *ap;
/* wake up the I/O event scanner */
#ifdef EPICS_V2
io_scanner_wakeup(IO_AI,XY566DIL,ap->card_number);
#else
scanIoRequest(paioscanpvt[i]);
#endif
ap = pai_xy566dil[i];
# ifdef EPICS_V2
/* wake up the I/O event scanner */
io_scanner_wakeup(IO_AI,XY566DIL,ap->card_number);
# else
scanIoRequest(paioscanpvt[i]);
# endif
/* reset the CSR - needed to allow next interrupt */
senw(&ap->a566_csr,XY566L_CSR);
@@ -353,14 +368,20 @@ register short ***pppmem_present;
ppmem_present = *pppmem_present;
/* map the io card into the VRTX short address space */
if((status = sysBusToLocalAdrs(VME_AM_SUP_SHORT_IO,base_addr, &pai566)) != OK){
logMsg("Addressing error in 566 analog input driver\n");
status = sysBusToLocalAdrs(VME_AM_SUP_SHORT_IO, base_addr, &pai566);
if(status != OK){
logMsg("%s: failed to map XY566 A16 base addr A16=%x\n",
__FILE__,
base_addr);
return ERROR;
}
/* map the io card into the standard address space */
if((status = sysBusToLocalAdrs(VME_AM_STD_SUP_DATA,paimem, &pai566io)) != OK){
logMsg("Addressing error in 566 analog input driver\n");
status = sysBusToLocalAdrs(VME_AM_STD_SUP_DATA,paimem, &pai566io);
if(status != OK){
logMsg( "%s: failed to map XY566 A24 base addr A24=%x\n",
__FILE__,
paimem);
return ERROR;
}
@@ -444,7 +465,8 @@ register short ***pppmem_present;
/* latch in the first bunch of data and start continuous scan */
senb(&pai566->soft_start,0);
}
return(0);
return OK;
}
/*
@@ -480,11 +502,11 @@ register short ***pppmem_present;
return ERROR;
}
{
int i;
for(i=0; i<num_cards; i++) {
paioscanpvt[i] = NULL;
scanIoInit(&paioscanpvt[i]);
}
int i;
for(i=0; i<num_cards; i++) {
paioscanpvt[i] = NULL;
scanIoInit(&paioscanpvt[i]);
}
}
#endif
@@ -499,13 +521,17 @@ register short ***pppmem_present;
/* map the io card into the VRTX short address space */
if ((status = sysBusToLocalAdrs(VME_AM_SUP_SHORT_IO,base_addr, &pai566)) != OK){
logMsg("Addressing error in 566 latched analog input driver\n");
logMsg( "%s: failed to map XY566 (latched) A16 base addr A16=%x\n",
__FILE__,
base_addr);
return ERROR;
}
/* map the io card into the standard address space */
if((status = sysBusToLocalAdrs(VME_AM_STD_SUP_DATA,paimem, &pai566io)) != OK){
logMsg("Addressing error in 566 analog input driver\n");
logMsg( "%s: failed to map XY566 (latched) A24 base addr A24=%x\n",
__FILE__,
paimem);
return ERROR;
}
@@ -602,19 +628,20 @@ register short ***pppmem_present;
senw(&pai566->a566_csr,XY566L_CSR);
}
return(0);
return OK;
}
#ifndef EPICS_V2
ai_xy566_getioscanpvt(card,scanpvt)
unsigned short card;
unsigned short card;
IOSCANPVT *scanpvt;
{
if((card<=MAX_DIL_CARDS) && paioscanpvt[card]) *scanpvt = paioscanpvt[card];
return(0);
if((card<=MAX_DIL_CARDS) && paioscanpvt[card]) *scanpvt = paioscanpvt[card];
return(0);
}
#endif
ai_xy566_driver(card,chan,type,prval)
register unsigned short card;
unsigned short chan;
@@ -673,9 +700,11 @@ register unsigned short *prval;
rval_convert(prval);
return (0);
}
}
return (0);
}
return (-3);
}
/*
@@ -710,8 +739,12 @@ VOID xy566_reset(){
struct ai566 *pai566; /* memory location of cards */
short int status;
if ((status = sysBusToLocalAdrs(VME_AM_SUP_SHORT_IO,ai_addrs[XY566DIL], &pai566)) != OK){
logMsg("Addressing error in 566 latched analog input driver\n");
status = sysBusToLocalAdrs(
VME_AM_SUP_SHORT_IO,
ai_addrs[XY566DIL],
&pai566);
if (status != OK){
logMsg("%s: unable to map A16 XY566 base\n", __FILE__);
return;
}