cleaned up merge of wf and ai 566 drivers

This commit is contained in:
Jeff Hill
1992-08-11 17:59:51 +00:00
parent 999d33dc4b
commit f131bcfa94

View File

@@ -3,7 +3,7 @@
/* share/src/drv $Id$ */
/*
* subroutines that are used to interface to the vme analog input cards
* drvXy566.c - Driver Support Routines for xy566
*
* Author: Bob Dalesio
* Date: 6-13-88
@@ -31,48 +31,75 @@
*
* Modification Log:
* -----------------
* .00 09-14-88 lrd check for IGEN card present before initing
* .01 9-27-88 lrd removed test code
* .02 11-10-88 lrd change addresses per HW Tech Note #2
* .02 09-27-88 lrd removed call to xy_mem_init
* .03 10-04-88 lrd remove IGEN support
* .04 10-07-88 lrd add support for the Xycom 085 arm mechanism
* added external latched AI and made
* others scan continuously
* .03 02-08-89 lrd moved module addresses into a table in
* .05 11-10-88 lrd change addresses per HW Tech Note #2
* .06 02-08-89 lrd moved module addresses into a table in
* module_types.h from ai_driver.h
* .04 02-24-89 lrd modify for vxWorks 4.0
* .07 02-24-89 lrd modify for vxWorks 4.0
* changed sysSetBCL to sysIntEnable
* .05 05-10-89 lrd increased performance for xycom 566 interface
* .08 04-17-89 lrd add callback mechanism for data take complete
* .09 05-10-89 lrd increased performance for xycom 566 interface
* by keeping the address of the memory buffers
* thus removing the need to calculate on each read
* .06 11-20-89 joh added call to the at5vxi ai driver
* .07 08-27-91 bg broke the 566 driver out of ai_driver.c
* thus removing the need to calculate on each
* read
* .10 07-27-89 lrd modified to use channel 0 not channel 1
* .11 11-20-89 joh added call to the at5vxi ai driver
* .12 02-15-90 lrd modified for new 085 card
* 02/04/91 ges Change taskDelay from 6 to 2 in
* "xy566DoneTask". Allows rearm and data reads
* for successive waveform scans up thru
* 10 Hz rates.
* .13 08-27-91 bg broke the 566 driver out of ai_driver.c
* and moved it to this file. Moved io_report code
* to this file.
* added arguments and raw value read out for analog
* in cards.
* .08 11-30-91 bg Added sysBusToLocalAdrs to both ai and waveform
* sections.
* .09 02-05-92 bg Changed io_report so it has an argument level and
* so if the level > 1, the raw value from the card
* will be printed out for analog ins only.
* added arguments and raw value read out
* for analog in cards.
* .14 10/30/91 bg Combined the xy566 waveform driver with the
* xy566 analog in drivers. Changed addressing to
* use sysBusToLocalAddrs and VME_AM_STD_SUP or
* VME_AM_SUP_SHORT_IO
* .15 11-30-91 bg Added sysBusToLocalAdrs to both ai and
* waveform sections.
* .16 02-05-92 bg Changed io_report so it has an argument
* level and so if the level > 1, the raw
* value from the card will be printed out
* for analog ins only.
* .17 03/20/92 bg Added the argument level to io_report,
* but so far it doesn't do anything. Will
* add ability to report ability to read out
* raw value if there is a demand.
* .18 08-10-92 joh cleaned up the merge of the xy566 wf and ai
* drivers
*/
#include <vxWorks.h>
#include <stdioLib.h>
#include <vme.h>
#include <dbDefs.h>
#include <drvSup.h>
#include <module_types.h>
#include <vme.h>
#include <wf_driver.h>
#include <task_params.h>
#include <ai_driver.h>
/* drvXy566.c - Driver Support Routines for xy566 */
static char SccsId[] = "@(#)ai_xy566_driver.c $Id$ ";
static char SccsId[] = "$Id$\t$Date$ ";
/*
* Code Portions
*
* xy566DoneTask Task to handle data take completion for the 566 waveform
* xy566_init Initializes the 566 waveform cards
* 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 */
static long report();
static long init();
long xy566_io_report();
long init();
struct {
long number;
@@ -80,14 +107,9 @@ struct {
DRVSUPFUN init;
} drvXy566={
2,
report,
xy566_io_report,
init};
static long report()
{
xy566_io_report();
return(0);
}
static long init()
{
@@ -95,18 +117,62 @@ static long 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])
#define XY566_MEM_INCR 0x10000 /* size of data memory area */
/* memory structure of the 566 interface */
struct ai566 { /* struct XVME 566 */
char dum[0x80]; /* odd bytes 1 - 3f contain
module identification */
unsigned short a566_csr; /* control status register */
unsigned char soft_start; /* software start register */
unsigned char int_vect; /* interrupt vector register */
unsigned short dram_ptr; /* pointer to data ram */
char dum1; /* unused */
unsigned char sram_ptr; /* sequence ram pointer */
char dum2[0xc0 - 0x88];
unsigned short stc_data; /* timing chip data port */
unsigned short stc_control; /* timing chip control port */
char dum3[0x101 - 0xc4];
unsigned char gram_base; /* base of gain ram 101,103 to 13f */
char dum5[0x201 - 0x102];
unsigned char sram_base; /* base of sequence ram 210,203 to 3ff */
char dum6[0x3ff -0x202];
unsigned char card_number; /* logical card number */
};
/* memory structure of the 566 interface */
struct wf085 { /* struct XVME 566 */
char dum[0x80]; /* odd bytes 1 - 3f contain
module identification */
unsigned short csr; /* control status register */
unsigned char soft_start; /* software start register */
unsigned char int_vect; /* interrupt vector register */
unsigned short dram_ptr; /* pointer to data ram */
char dum1; /* unused */
unsigned char sram_ptr; /* sequence ram pointer */
char dum2[0xc0 - 0x88];
unsigned short stc_data; /* timing chip data port */
unsigned short stc_control; /* timing chip control port */
char dum3[0x101 - 0xc4];
unsigned char gram_base; /* base of gain ram 101,103,..
... to 13f */
char dum5[0x201 - 0x102];
unsigned char sram_base; /* base of sequence ram 210,203,
... to 3ff */
char dum6[0x400 -0x202];
};
/* arrays which keep track of which cards are found at initialization */
struct ai566 *pai_xy566se[MAX_AI_XY_CARDS];
struct ai566 *pai_xy566di[MAX_AI_XY_CARDS];
struct ai566 *pai_xy566dil[MAX_AI_XY_CARDS];
unsigned short *pai_xy566se_mem[MAX_AI_XY_CARDS];
unsigned short *pai_xy566di_mem[MAX_AI_XY_CARDS];
unsigned short *pai_xy566dil_mem[MAX_AI_XY_CARDS];
/* VME memory Short Address Space is set up in gta_init */
static char *shortaddr;
static char *stdaddr;
struct ai566 **pai_xy566se;
struct ai566 **pai_xy566di;
struct ai566 **pai_xy566dil;
unsigned short **pai_xy566se_mem;
unsigned short **pai_xy566di_mem;
unsigned short **pai_xy566dil_mem;
/* reset the counter interrupt 0x8000 */
@@ -122,6 +188,47 @@ static char *stdaddr;
#define XY566L_CSR 0xb94b
#define XY566_INT_LEVEL 6
/* max card and channel definitions move to module types.h */
#define MAX_WF_XY_CARDS (wf_num_cards[XY566WF])
/* card interface */
#define WF_XY566_BASE (wf_addrs[XY566WF]) /* XYCOM 566 waveform */
#define WF_XY085_BASE (wf_armaddrs[XY566WF]) /* XYCOM 085 arm */
/* Data RAM area into which the 566 stores the latched data */
/* This needs to be different for each type of IO card */
#define WF_XY566_MEMBASE ((unsigned short *)0x1080000)
/* figure out what these are */
#define WF566_MEM_INCR 0x10000 /* 65535 bytes per waveform */
#define WF566_VNUM 0xf1 /* this is currently incorrect */
#define WF_READ 0x00 /* read a waveform */
#define WF_ARM 0x01 /* arm a waveform */
#define WF_LATCH 0x02 /* latch a waveform */
#define WF_SETUP 0x03 /* set up a waveform */
/* xycom 085 encoder pulse mechanism */
#define XY_ARM 0x10 /* arm the encoder pulse circuitry */
#define XY_BUSY 0x20 /* indicates the waveform is still being taken */
#define XY_LED 0x3 /* set the Xycom status LEDs to OK */
#define XY_SOFTRESET 0x10 /* reset the IO card */
/* arrays which keep track of which cards are found at initialization */
struct ai566 **pwf_xy566;
struct wf085 **pwf_xy085;
char **pwf_mem;
/* the routine to call when the data is read and the argument to send */
unsigned int **pargument;
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();
@@ -171,46 +278,60 @@ register struct ai566 *ap;
* Initialize all VME analog input cards
*/
ai_566_init()
long ai_566_init()
{
/* intialize the Xycom 566 Unipolar Single Ended Analog Inputs */
ai_xy566_init(pai_xy566se,ai_addrs[XY566SE],ai_num_channels[XY566SE],
ai_num_cards[XY566SE],ai_memaddrs[XY566SE],pai_xy566se_mem);
ai_xy566_init(&pai_xy566se,ai_addrs[XY566SE],ai_num_channels[XY566SE],
ai_num_cards[XY566SE],ai_memaddrs[XY566SE],&pai_xy566se_mem);
/* intialize the Xycom 566 Unipolar Differential Analog Inputs */
ai_xy566_init(pai_xy566di,ai_addrs[XY566DI],ai_num_channels[XY566DI],
ai_num_cards[XY566DI],ai_memaddrs[XY566DI],pai_xy566di_mem);
ai_xy566_init(&pai_xy566di,ai_addrs[XY566DI],ai_num_channels[XY566DI],
ai_num_cards[XY566DI],ai_memaddrs[XY566DI],&pai_xy566di_mem);
/* intialize the Xycom 566 Unipolar Differential Analog Inputs Latched */
ai_xy566l_init(pai_xy566dil,ai_addrs[XY566DIL],ai_num_channels[XY566DIL],
ai_num_cards[XY566DIL],ai_memaddrs[XY566DIL],pai_xy566dil_mem);
ai_xy566l_init(&pai_xy566dil,ai_addrs[XY566DIL],ai_num_channels[XY566DIL],
ai_num_cards[XY566DIL],ai_memaddrs[XY566DIL],&pai_xy566dil_mem);
return (0);
}
/*
* Driver Support Routines for Ai
*
/*
* ai_XY566_INIT
*
* intialize the xycom 566 analog input card
*/
int ai_xy566_init(pcards_present,base_addr,num_channels,num_cards,paimem,pmem_present)
register struct ai566 **pcards_present;
int ai_xy566_init(pppcards_present,base_addr,num_channels,num_cards,paimem,pppmem_present)
register struct ai566 ***pppcards_present;
register unsigned short *base_addr;
register short num_channels;
short num_cards;
register char *paimem; /* mem loc of I/O buffer */
register short **pmem_present;
register short ***pppmem_present;
{
short shval;
register short i,n;
struct ai566 *pai566; /* memory location of cards */
char *pai566io; /* mem loc of I/O buffer */
short status;
struct ai566 **ppcards_present;
short **ppmem_present;
*pppcards_present = (struct ai566 **)
calloc(num_cards, sizeof(**pppcards_present));
if(!*pppcards_present){
return ERROR;
}
*pppmem_present = (short **)
calloc(num_cards, sizeof(**pppmem_present));
if(!*pppmem_present){
return ERROR;
}
ppcards_present = *pppcards_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){
@@ -226,18 +347,18 @@ register short **pmem_present;
/* mark each card present into the card present array */
for (i = 0; i < num_cards;
i++, pai566++, pcards_present+=1, pai566io+=XY566_MEM_INCR,pmem_present+=1) {
i++, pai566++, ppcards_present++, pai566io+=XY566_MEM_INCR,ppmem_present++) {
if (vxMemProbe(pai566,READ,sizeof(short),&shval) != OK){
*pcards_present = 0;
*ppcards_present = 0;
continue;
}
if (vxMemProbe(pai566io,READ,sizeof(short),&shval) != OK){
*pcards_present = 0;
*ppcards_present = 0;
continue;
}
*pcards_present = pai566;
*pmem_present = (short *)pai566io;
*ppcards_present = pai566;
*ppmem_present = (short *)pai566io;
/* reset the Xycom 566 board */
senw(&pai566->a566_csr,0x00); /* off seq control */
@@ -311,19 +432,36 @@ register short **pmem_present;
*
* intialize the xycom 566 latched analog input card
*/
int ai_xy566l_init(pcards_present,base_addr,num_channels,num_cards,paimem,pmem_present)
register struct ai566 **pcards_present;
int ai_xy566l_init(pppcards_present,base_addr,num_channels,num_cards,paimem,pppmem_present)
register struct ai566 ***pppcards_present;
register unsigned short *base_addr;
register short num_channels;
short num_cards;
register char *paimem; /* mem loc of I/O buffer */
register short **pmem_present;
register short ***pppmem_present;
{
short shval;
register short i,n;
struct ai566 *pai566; /* memory location of cards */
char *pai566io; /* mem loc of I/O buffer */
int status;
struct ai566 **ppcards_present;
short **ppmem_present;
*pppcards_present = (struct ai566 **)
calloc(num_cards, sizeof(**pppcards_present));
if(!*pppcards_present){
return ERROR;
}
*pppmem_present = (short **)
calloc(num_cards, sizeof(**pppmem_present));
if(!*pppmem_present){
return ERROR;
}
ppcards_present = *pppcards_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){
@@ -341,18 +479,18 @@ register short **pmem_present;
/* mark each card present into the card present array */
for (i=0;i<num_cards;
i++, pai566++, pcards_present+=1, pai566io+=XY566_MEM_INCR,pmem_present+=1){
i++, pai566++, ppcards_present++, pai566io+=XY566_MEM_INCR,ppmem_present++){
if (vxMemProbe(pai566,READ,sizeof(short),&shval) != OK){
*pcards_present = 0;
*ppcards_present = 0;
continue;
}
if (vxMemProbe(pai566io,READ,sizeof(short),&shval) != OK){
*pcards_present = 0;
*ppcards_present = 0;
continue;
}
*pcards_present = pai566;
*pmem_present = (short *)pai566io;
*ppcards_present = pai566;
*ppmem_present = (short *)pai566io;
/* put the card number in the dual ported memory */
senb(&pai566->card_number,i);
@@ -532,7 +670,7 @@ VOID xy566_reset(){
if ((status = sysBusToLocalAdrs(VME_AM_SUP_SHORT_IO,ai_addrs[XY566DIL], &pai566)) != OK){
logMsg("Addressing error in 566 latched analog input driver\n");
return ERROR;
return;
}
for (i=0;i<ai_num_cards[XY566DIL]; i++, pai566++ ){
@@ -552,32 +690,26 @@ VOID xy566_reset(){
* io_report (or dbior) subroutine for 566 card.
*
*
*
* .c - Driver Support Routines for Ai
*/
static long report();
static long init();
int ai_xy566_io_report(level)
*/
long ai_xy566_io_report(level)
char level;
{
short i,j;
unsigned short rval;
for (i = 0; i < MAX_AI_XY_CARDS; i++){
for (i = 0; i < MAX_SE_CARDS; i++){
if (pai_xy566se[i]){
printf("AI: XY566-SE: card %d\n",i);
printf("AI: XY566-SE:\tcard %d\n",i);
if (level == 1){
xy566_rval_report(i,XY566SE);
}
}
}
for (i = 0; i < MAX_AI_XY_CARDS; i++){
for (i = 0; i < MAX_DI_CARDS; i++){
if (pai_xy566di[i]){
printf("AI: XY566-DI: card %d\n",i);
printf("AI: XY566-DI:\tcard %d\n",i);
if (level == 1){
xy566_rval_report(i,XY566DI);
}
@@ -585,9 +717,9 @@ int ai_xy566_io_report(level)
}
for (i = 0; i < MAX_AI_XY_CARDS; i++){
for (i = 0; i < MAX_DIL_CARDS; i++){
if (pai_xy566dil[i]){
printf("AI: XY566-DIL: card %d\n",i);
printf("AI: XY566-DIL:\tcard %d\n",i);
if (level == 1){
xy566_rval_report(i,XY566DIL);
}
@@ -642,52 +774,8 @@ VOID xy566_rval_report(card,type)
}
}
}
/* Driver for 566 card as wave form card.
*
* Modification Log
* -----------------
* .00 09-14-88 lrd check for IGEN card present before initing
* .01 09-27-88 lrd removed call to xy_mem_init
* .02 10-04-88 lrd remove IGEN support
* .03 10-07-88 lrd add support for the Xycom 085 arm mechanism
* .04 04-17-89 lrd add callback mechanism for data take complete
* .05 02-15-90 lrd modified for new 085 card
* .05 07-27-89 lrd modified to use channel 0 not channel 1
* 02/04/91 ges Change taskDelay from 6 to 2 in "xy566DoneTask".
* Allows rearm and data reads for successive
* waveform scans up thru 10 Hz rates.
* .07 10/30/91 bg Combined the xy566 waveform driver with the
* xy566 analog in drivers. Changed addressing to
* use sysBusToLocalAddrs and VME_AM_STD_SUP or
* VME_AM_SUP_SHORT_IO
* .08 03/20/92 bg Added the argument level to io_report, but so far
* it doesn't do anything. Will add ability to report
* ability to read out raw value if there is a demand.
*/
/*
* Code Portions
*
* xy566DoneTask Task to handle data take completion for the 566 waveform
* xy566_init Initializes the 566 waveform cards
* senb/senw Writes to the 566 where the call provides a req'd delay
*/
/* arrays which keep track of which cards are found at initialization */
struct ai566 *pwf_xy566[MAX_AI_XY_CARDS];
struct wf085 *pwf_xy085[MAX_AI_XY_CARDS];
char *pwf_mem[MAX_AI_XY_CARDS];
/* the routine to call when the data is read and the argument to send */
unsigned int *pargument[MAX_AI_XY_CARDS];
unsigned int *proutine[MAX_AI_XY_CARDS];
/* VME memory Short Address Space is set up in gta_init */
int wfDoneId; /* waveform done task ID */
/* forward references */
@@ -737,14 +825,15 @@ register unsigned int *parg; /* number of values read */
* polls the busy bit on the Xycom 566 latched waveform records
* The busy bit is set externally when data collection is completed
*/
xy566DoneTask(){
xy566DoneTask()
{
register unsigned int **pproutines;
register unsigned int (*pcbroutine)();
register short i;
while(TRUE){
pproutines = proutine;
for (i=0; i<MAX_AI_XY_CARDS; i++,pproutines++){
for (i=0; i<MAX_WF_XY_CARDS; i++,pproutines++){
/* check if the waveform is armed */
if (*pproutines == 0) continue;
@@ -781,24 +870,67 @@ xy566_init()
short shval,status;
register short i,got_one;
register struct ai566 *pwf566; /* VME location of cards */
struct wf085 *pwf085; /* VME location of arm module */
struct ai566 *pwf566; /* VME location of cards */
struct wf085 *pwf085; /* VME location of arm */
char *pwfMem; /* VME 566 memory buffer */
/* map the io card into the VRTX short address space */
if(( status = sysBusToLocalAdrs(VME_AM_SUP_SHORT_IO,0, &shortaddr)) != OK){
logMsg("Addressing error in 566 wf driver\n");
pwf_xy566 = (struct ai566 **)
calloc(wf_num_cards[XY566WF], sizeof(*pwf_xy566));
if(!pwf_xy566){
return ERROR;
}
pwf_xy085 = (struct wf085 **)
calloc(wf_num_cards[XY566WF], sizeof(*pwf_xy085));
if(!pwf_xy085){
return ERROR;
}
pwf_mem = (char **)
calloc(wf_num_cards[XY566WF], sizeof(*pwf_mem));
if(!pwf_mem){
return ERROR;
}
pargument = (unsigned int **)
calloc(wf_num_cards[XY566WF], sizeof(*pargument));
if(!pargument){
return ERROR;
}
proutine = (unsigned int **)
calloc(wf_num_cards[XY566WF], sizeof(*proutine));
if(!proutine){
return ERROR;
}
pcards_present = pwf_xy566;
parms_present = pwf_xy085;
pmem_present = pwf_mem;
/* map the io card into the VME short address space */
status = sysBusToLocalAdrs(
VME_AM_SUP_SHORT_IO,
WF_XY566_BASE,
&pwf566);
if(status<0){
logMsg("%s: unable to map A16 XY566 base\n", __FILE__);
return ERROR;
}
pwf085 = (struct wf085 *)((int)shortaddr + (int)wf_armaddrs[XY566WF]);
pwf566 = (struct ai566 *)((int)shortaddr + (int)wf_addrs[XY566WF]);
if ((status = sysBusToLocalAdrs(VME_AM_STD_SUP_DATA,wf_memaddrs[XY566WF],&pwfMem)) != OK){
logMsg("Addressing error in 566 wf ram\n");
status = sysBusToLocalAdrs(
VME_AM_SUP_SHORT_IO,
WF_XY085_BASE,
&pwf085);
if(status<0){
logMsg("%s: unable to map A16 XY085 base\n", __FILE__);
return ERROR;
}
status = sysBusToLocalAdrs(
VME_AM_STD_SUP_DATA,
wf_memaddrs[XY566WF],
&pwfMem);
if (status != OK){
logMsg("%s: unable to map A24 XY566 base\n", __FILE__);
return ERROR;
}
/* mark each card present into the card present array */
got_one = 0;
@@ -919,7 +1051,12 @@ xy566_init()
/* start the 566 waveform readback task */
if (got_one)
wfDoneId =
taskSpawn(WFDONE_NAME,WFDONE_PRI,WFDONE_OPT,WFDONE_STACK,xy566DoneTask);
taskSpawn(
WFDONE_NAME,
WFDONE_PRI,
WFDONE_OPT,
WFDONE_STACK,
xy566DoneTask);
return 0;
}
@@ -932,8 +1069,9 @@ xy566_init()
*
*
*/
long
xy566_io_report(level)
short int level;
short int level;
{
int i,xy566_bytes;