Initial revision

This commit is contained in:
Gunther
1992-06-25 10:26:14 +00:00
parent deb251e5ef
commit 359782119e
3 changed files with 746 additions and 0 deletions

184
src/drv/drvBb902.c Normal file
View File

@@ -0,0 +1,184 @@
/* bb902_driver.c */
static char SccsId[] = "@(#)bb902_driver.c $Id$ ";
/* share/src/drv $Id$ */
/*
* subroutines that are used to interface to the binary output cards
*
* Author: Bob Dalesio
* Date: 5-26-88
*
* Experimental Physics and Industrial Control System (EPICS)
*
* Copyright 1991, the Regents of the University of California,
* and the University of Chicago Board of Governors.
*
* This software was produced under U.S. Government contracts:
* (W-7405-ENG-36) at the Los Alamos National Laboratory,
* and (W-31-109-ENG-38) at Argonne National Laboratory.
*
* Initial development by:
* The Controls and Automation Group (AT-8)
* Ground Test Accelerator
* Accelerator Technology Division
* Los Alamos National Laboratory
*
* Co-developed with
* The Controls and Computing Group
* Accelerator Systems Division
* Advanced Photon Source
* Argonne National Laboratory
*
* Modification Log:
* -----------------
* .01 10-31-91 bg broke bb902 code out of bo_driver.c
* .02 02-20-92 bg Added level to io_report. Added ability
* to read out raw values on card if level
* > 0.
*
*/
/*
* Code Portions:
*
* bo_drv_init Finds and initializes all binary output cards present
* bo_driver Interfaces to the binary output cards present
*/
#include <vxWorks.h>
#include <vme.h>
#include <module_types.h>
#include <bo_driver.h>
#include <drvsubs.h>
static char *bb902_shortaddr;
/* pointers to the binary output cards */
struct bo_bb902 *pbo_bb902s[MAX_BB_BO_CARDS]; /* Burr-Brown 902s */
/*
* BO_DRIVER_INIT
*
* intialization for the binary output cards
*/
int bb902_driver_init(){
int bomode;
int status;
register short i;
struct bo_bb902 *pbo_bb902;
/* intialize the Burr-Brown 902 binary output cards */
/* base address of the burr-brown 902 binary output cards */
status = sysBusToLocalAdrs(VME_AM_SUP_SHORT_IO,bo_addrs[BB902],&bb902_shortaddr);
if (status != OK){
printf("Addressing error in bb902 driver\n");
return (ERROR);
}
pbo_bb902 = (struct bo_bb902 *)bb902_shortaddr;
/* determine which cards are present */
for (i = 0; i < bo_num_cards[BB902]; i++,pbo_bb902++){
if (vxMemProbe(pbo_bb902,READ,sizeof(short),&bomode) == OK)
pbo_bb902s[i] = pbo_bb902;
else
pbo_bb902s[i] = 0;
}
return (0);
}
/*
* BB902_DRIVER
*
* interface to the Burr-Brown binary outputs
*/
int bb902_driver(card,val,mask)
register unsigned short card;
register unsigned int *val;
unsigned int mask;
{
register unsigned int work;
/* verify card exists */
if (card < 0 || !pbo_bb902s[card])
return (-1);
/* use structure to handle high and low short swap */
/* get current output */
work = (pbo_bb902s[card]->high_value << 16) /* high */
+ pbo_bb902s[card]->low_value; /* low */
/* alter specified bits */
work = (work & ~mask) | ((*val) & mask);
/* write new output */
pbo_bb902s[card]->high_value = (unsigned short)(work >> 16);
pbo_bb902s[card]->low_value = (unsigned short)work;
return (0);
}
/*
* bb902_read
*
* read the binary output
*/
int bb902_read(card,mask,pval)
register unsigned short card;
unsigned int mask;
register unsigned int *pval;
{
register unsigned int work;
/* verify card exists */
if (card < 0 || !pbo_bb902s[card])
return (-1);
/* readback */
*pval = (pbo_bb902s[card]->high_value << 16) /* high */
+ pbo_bb902s[card]->low_value; /* low */
}
void bb902_io_report(level)
short int level;
{
register short i,j,k,l,m,num_chans;
int jval,kval,lval,mval;
extern masks[];
for (i = 0; i < MAX_BB_BO_CARDS; i++){
if (pbo_bb902s[i]){
printf("BO: BB902: card %d\n",i);
if (level > 1){
num_chans = bo_num_channels[BB902];
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){
bb902_read(i,masks[j],&jval);
if (jval != 0)
jval = 1;
printf("Chan %d = %x\t ",j,jval);
}
if(k < num_chans){
bb902_read(i,masks[k],&kval);
if (kval != 0)
kval = 1;
printf("Chan %d = %x\t ",k,kval);
}
if(l < num_chans){
bb902_read(i,masks[l],&lval);
if (lval != 0)
lval = 1;
printf("Chan %d = %x \t",l,lval);
}
if(m < num_chans){
bb902_read(i,masks[m],&mval);
if (mval != 0)
mval = 1;
printf("Chan %d = %x \n",m,mval);
}
}
}
}
}
}

195
src/drv/drvXy220.c Normal file
View File

@@ -0,0 +1,195 @@
/* xy220_driver.c */
static char SccsId[] = "@(#)xy220_driver.c $Id$ ";
/* share/src/drv $Id$ */
/*
* subroutines that are used to interface to the binary output cards
*
* Author: Bob Dalesio
* Date: 5-26-88
*
* Experimental Physics and Industrial Control System (EPICS)
*
* Copyright 1991, the Regents of the University of California,
* and the University of Chicago Board of Governors.
*
* This software was produced under U.S. Government contracts:
* (W-7405-ENG-36) at the Los Alamos National Laboratory,
* and (W-31-109-ENG-38) at Argonne National Laboratory.
*
* Initial development by:
* The Controls and Automation Group (AT-8)
* Ground Test Accelerator
* Accelerator Technology Division
* Los Alamos National Laboratory
*
* Co-developed with
* The Controls and Computing Group
* Accelerator Systems Division
* Advanced Photon Source
* Argonne National Laboratory
*
* Modification Log:
* -----------------
* .01 10-31-91 bg broke xy220 driver out of bo_driver.c
* broke xy220 code out of io_report and
* created xy220_io_report().
* Added sysBusToLocalAdrs.
* .02 02-03-92 bg Gave xy220_io_report the ability to
* read raw values from card if level > 1.
*/
/*
* Code Portions:
*
* bo_drv_init Finds and initializes all binary output cards present
* bo_driver Interfaces to the binary output cards present
*/
#include <vxWorks.h>
#include <vme.h>
#include "module_types.h"
#include "bo_driver.h"
#include "drvsubs.h"
static char *xy220_addr;
/* pointers to the binary output cards */
struct bo_xy220 *pbo_xy220s[MAX_XY220_BO_CARDS]; /* Xycom 220s */
/*
* XY220_DRIVER_INIT
*
* intialization for the xy220 binary output cards
*/
int xy220_driver_init(){
int bomode;
int status;
register short i;
struct bo_xy220 *pbo_xy220;
/* initialize the Xycom 220 binary output cards */
/* base address of the xycom 220 binary output cards */
if ((status = sysBusToLocalAdrs(VME_AM_SUP_SHORT_IO,bo_addrs[XY220],&xy220_addr)) != OK){
printf("Addressing error in xy220 driver\n");
return ERROR;
}
pbo_xy220 = (struct bo_xy220 *)xy220_addr;
/* determine which cards are present */
for (i = 0; i < bo_num_cards[XY220]; i++,pbo_xy220++){
if (vxMemProbe(pbo_xy220,READ,sizeof(short),&bomode) == OK){
pbo_xy220s[i] = pbo_xy220;
pbo_xy220s[i]->csr = XY_SOFTRESET;
pbo_xy220s[i]->csr = XY_LED;
}else{
pbo_xy220s[i] = 0;
}
}
}
/*
* XY220_DRIVER
*
* interface to the xy220 binary outputs
*/
int xy220_driver(card,val,mask)
register unsigned short card;
register unsigned int *val;
unsigned int mask;
{
register unsigned int work;
/* verify card exists */
if (card < 0 || !pbo_xy220s[card])
return (-1);
/* use structure to handle high and low short swap */
/* get current output */
work = (pbo_xy220s[card]->high_value << 16)
+ pbo_xy220s[card]->low_value;
/* alter specified bits */
work = (work & ~mask) | ((*val) & mask);
/* write new output */
pbo_xy220s[card]->high_value = (unsigned short)(work >> 16);
pbo_xy220s[card]->low_value = (unsigned short)work;
return (0);
}
/*
* xy220_read
*
* read the binary output
*/
int xy220_read(card,mask,pval)
register unsigned short card;
unsigned int mask;
register unsigned int *pval;
{
register unsigned int work;
/* verify card exists */
if (card < 0 || !pbo_xy220s[card])
return (-1);
/* readback */
*pval = (pbo_xy220s[card]->high_value << 16) + pbo_xy220s[card]->low_value;
*pval &= mask;
return(0);
}
/*
* XY220_IO_REPORT
*
*
*/
void xy220_io_report(level)
short int level;
{
register short i,j,k,l,m,num_chans;
int jval,kval,lval,mval;
extern masks[];
for (i = 0; i < bo_num_cards[XY220]; i++){
if (pbo_xy220s[i]){
printf("BO: XY220: card %d\n",i);
if (level == 1){
num_chans = bo_num_channels[XY220];
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){
xy220_read(i,masks[j],&jval);
if (jval != 0)
jval = 1;
printf("Chan %d = %x\t ",j,jval);
}
if(k < num_chans){
xy220_read(i,masks[k],&kval);
if (kval != 0)
kval = 1;
printf("Chan %d = %x\t ",k,kval);
}
if(l < num_chans){
xy220_read(i,masks[l],&lval);
if (lval != 0)
lval = 1;
printf("Chan %d = %x \t",l,lval);
}
if(m < num_chans){
xy220_read(i,masks[m],&mval);
if (mval != 0)
mval = 1;
printf("Chan %d = %x \n",m,mval);
}
}
}
}
}
}

367
src/drv/drvXy240.c Normal file
View File

@@ -0,0 +1,367 @@
/*xy240_driver.c
*routines used to test and interface with Xycom240
*digital i/o module
*
*B. Kornke
*
*11/20/91
*/
#include "vxWorks.h"
#include "module_types.h"
#include "vme.h"
#include "xy240_driver.h"
#include "taskLib.h"
struct dio_rec dio[XY240_MAX_CARDS]; /*define array of control structures*/
/*dio_int
*
*interrupt service routine
*
*/
/*dio_int(ptr)
register struct dio_rec *ptr;
{
register struct dio_xy240 *regptr;
regptr = ptr->dptr;
}*/
/*
*
*dio_scan
*
*task to check for change of state
*
*/
dio_scan()
{
int i;
for (;;)
{
for (i = 0; i < XY240_MAX_CARDS; i++)
{
if (dio[i].dptr)
if (((dio[i].dptr->port0_1) ^ (dio[i].sport0_1)) ||
((dio[i].dptr->port2_3) ^ (dio[i].sport2_3)))
{
/* printf("io_scanner_wakeup for card no %d\n",i); */
io_scanner_wakeup(IO_BI,XY240,i);
dio[i].sport0_1 = dio[i].dptr->port0_1;
dio[i].sport2_3 = dio[i].dptr->port2_3;
}
}
taskDelay(1);
}
}
/*DIO DRIVER INIT
*
*initialize xy240 dig i/o card
*/
xy240_init()
{
short junk;
register short i;
struct dio_xy240 *pdio_xy240;
static char *name = "scan";
int tid,status;
pdio_xy240 = (struct dio_xy240 *) XY240_ADDR0; /*point to card*/
if ((status = sysBusToLocalAdrs(VME_AM_SUP_SHORT_IO,XY240_ADDR0,&pdio_xy240)) != OK){
printf("Addressing error in xy240 driver\n");
return ERROR;
}
for (i = 0; i < XY240_MAX_CARDS; i++, pdio_xy240++){
if (vxMemProbe(pdio_xy240,READ,2,&junk) == OK){
/*
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*/
dio[i].dptr = pdio_xy240;
}
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");
}
}
/*
* XY240_BI_DRIVER
*
*interface to binary inputs
*/
xy240_bi_driver(card,mask,prval)
register unsigned short card;
unsigned int mask;
register unsigned int *prval;
{
register unsigned int work;
if ((card >= XY240_MAX_CARDS) || (!dio[card].dptr))
return -1;
/* printf("%d\n",dio[card].num);*/
work = (dio[card].dptr->port0_1 << 16)
+ dio[card].dptr->port2_3;
*prval = work & mask;
return(0);
}
/*
*
*XY240_BO_READ
*
*interface to binary outputs
*/
xy240_bo_read(card,mask,prval)
register unsigned short card;
unsigned int mask;
register unsigned int *prval;
{
register unsigned int work;
if ((card >= XY240_MAX_CARDS) || (!dio[card].dptr)){
return -1;
}
/* printf("%d\n",dio[card].num); */
work = (dio[card].dptr->port4_5 << 16)
+ dio[card].dptr->port6_7;
*prval = work &= mask;
return(0);
}
/* XY240_DRIVER
*
*interface to binary outputs
*/
xy240_bo_driver(card,val,mask)
register unsigned short card;
unsigned int 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 */
work = (dio[card].dptr->port4_5 << 16)
+ dio[card].dptr->port6_7;
work = (work & ~mask) | (val & mask);
dio[card].dptr->port6_7 = (unsigned short)(work >> 16);
dio[card].dptr->port4_5 = (unsigned short)work;
}
/*dio_out
*
*test routine for xy240 output
*/
dio_out(card,port,val)
unsigned short card,port,val;
{
if ((card > XY240_MAX_CARDS-1)) /*test to see if card# is allowable*/
{
printf("card # out of range\n");
return -1;
}
else if (!dio[card].dptr) /*see if card exists*/
{
printf("can't find card %d\n", card);
return -2;
}
else if ((port >7) || (port <4)) /*make sure they're output ports*/
{
printf("use ports 4-7\n");
return -3;
}
else if (port == 4)
{
dio[card].dptr->port4_5 = val<< 8;
return -4;
}
else if (port == 5)
{
dio[card].dptr->port4_5 = val;
return -5;
}
else if (port == 6)
{
dio[card].dptr->port6_7 = val<< 8;
return -6;
}
else if (port == 7)
{
dio[card].dptr->port6_7 = val;
return -7;
}
}
/*XY240_WRITE
*
*command line interface to test bo driver
*
*/
xy240_write(card,val)
short card;
unsigned int val;
{
return xy240_bo_driver(card,val,0xffffffff);
}
xy240_io_report(level)
short int level;
{
short int i;
for (i = 0; i < XY240_MAX_CARDS; i++){
if(dio[i].dptr){
printf("XY240: card %d\n",i);
if (level < 1){
printf("\tBinary In Channels 0 - 31\n");
printf("\tBinary Out Channels 0 - 31\n");
}
}
}
}
xy240_bi_io_report(){
extern masks[];
short int num_chans,i,j,k,l,m,status;
int ival,jval,kval,lval,mval;
unsigned int *prval;
short int first_time = 0;
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);
}
}
}
}
}
xy240_bo_io_report(){
extern masks[];
short int num_chans,i,j,k,l,m,status;
int ival,jval,kval,lval,mval;
unsigned int *prval;
short int first_time = 0;
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);
}
}
}
}
}