From f131bcfa94be6f33e1cb542e498ac8f1ab6941d9 Mon Sep 17 00:00:00 2001 From: Jeff Hill Date: Tue, 11 Aug 1992 17:59:51 +0000 Subject: [PATCH] cleaned up merge of wf and ai 566 drivers --- src/drv/drvXy566.c | 414 ++++++++++++++++++++++++++++++--------------- 1 file changed, 276 insertions(+), 138 deletions(-) diff --git a/src/drv/drvXy566.c b/src/drv/drvXy566.c index 8e3ebe658..b75ed6bb1 100644 --- a/src/drv/drvXy566.c +++ b/src/drv/drvXy566.c @@ -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 -#include +#include #include #include #include -#include -#include #include -#include -/* 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;icard_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