Subversion Repositories f9daq

Compare Revisions

Ignore whitespace Rev 11 → Rev 12

/pts/pcivme_ni.h
0,0 → 1,84
#ifndef __PCIVME_NI_H__
#define __PCIVME_NI_H__
 
//-------------------------------------------------------------------------------------------
// pcivme_ni.h - header for ni-labview shared library or dll for ARW pcivme interface
// this library can also be used for other purposes aside from labview
//
// Copyright (C) 2002-2004 ARW Elektronik Germany
//
// this source code is published under LGPL (Open Source). You can use, redistrubute and
// modify it unless this header is not modified or deleted. No warranty is given that
// this software will work like expected.
// This product is not authorized for use as critical component in life support systems
// wihout the express written approval of ARW Elektronik Germany.
//
// Please announce changes and hints to ARW Elektronik
//
// $Log: pcivme_ni.h,v $
// Revision 1.8 2004/08/13 19:23:45 klaus
// conversion to kernel-version 2.6, released version 3.0
//
// Revision 1.7 2002/10/20 18:07:18 klaus
// changed error handling
//
// Revision 1.6 2002/10/18 21:56:28 klaus
// completed functional features, untested
//
// Revision 1.5 2002/10/18 21:56:28 klaus
// completed functional features, untested
//
// Revision 1.4 2002/10/17 21:16:03 klaus
// filled function bodies
//
// Revision 1.3 2002/10/17 21:16:03 klaus
// filled function bodies
//
// Revision 1.2 2002/10/17 19:05:03 klaus
// VME access is working through test to lib to driver
//
// Revision 1.1 2002/10/12 22:04:44 klaus
// first work done
//
// what who when
// first steps AR 17.11.1999
// VMEerror new AR 07.01.2000
// made LINUX shared library from windows template AR 12.10.2002
//
 
//-------------------------------------------------------------------------------------------
// INCLUDES
//
#define BOOLEAN int
#if !defined(TRUE) && !defined(FALSE)
#define FALSE 0
#define TRUE 1
#endif
 
//-------------------------------------------------------------------------------------------
// PROTOTYPES
//
#ifdef __cplusplus
extern "C"
{
#endif
int VMEopen(const char *cszDeviceName, unsigned char ubAddressModifier, int *pnHandle);
int VMEinit(const char *cszDeviceName, unsigned short nVMEMM, unsigned char ubAddressModifier, int *pnHandle);
int setAccessProperties(int nHandle, unsigned char bModifier, unsigned char bAccessType);
int VMEread(int nHandle, unsigned long ulAddress, unsigned char ubAccessWidth, unsigned long ulElementCount, void *pvBuffer);
int VMEwrite(int nHandle, unsigned long ulAddress, unsigned char ubAccessWidth, unsigned long ulElementCount, void *pvBuffer);
int VMEaccessVIC(int nHandle, unsigned char ubAccessMode, unsigned short uwAddress, unsigned char *ubContent);
int VMEreset(int nHandle);
int VMETAS(int nHandle, unsigned long ulAddress, unsigned char *ubResult);
int VMEcontrolInterrupt(int nHandle, BOOLEAN *bEnable);
int VMEinterrupt(int nHandle, unsigned char *ubVector);
int VMEsysfailGet(int nHandle, BOOLEAN *bResult);
int VMEsysfailSet(int nHandle, BOOLEAN bForce);
int VMEerror(int nHandle);
int VMEclose(int nHandle);
int GetLastError(int nHandle);
#ifdef __cplusplus
}
#endif
 
#endif /* __PCIVME_NI_H__ */
/pts/PtsModule.h
0,0 → 1,40
#ifndef PtsModule__H_
#define PtsModule__H_
#include "vme.h"
#define BYTE_PER_DOT 8192
#define ADR_CSR0 0x00 // D[1] LEDTEST; D[0] RESET
#define ADR_CLK 0x04 // D[15:12] CLKOUT1; D[11:8] CLKOUT0;
// D[7:4] SCLK; D[3:0] PCLK
#define ADR_VMECLK 0x08 // D[3] CLKOUT1; D[2] CLKOUT0;
// D[1] SCLK; D[0] PCLK
#define ADR_BUSA_REG 0x10
#define ADR_BUSA_IN 0x14
#define ADR_BUSA_DIR 0x18 // D[9:8] BUSA;
#define ADR_CFG 0x40
#define ADR_CSR1 0x44 // D[8] DONE; D[1] VCS_; D[0] PROGRAM_
#define ADR_MODE 0x48
#define ADR_SYSRESET 0xfc // write D=0 to sysreset
 
#define CSR1_PROGRAM_ 0x1
#define CSR1_VCS_ 0x2
#define CSR1_DONE 0x100
 
#define SELECTMAP_MODE 2
#define SLAVESERIAL_MODE 3
 
int Pts_erase(int);
// int Pts_configure( const char *filename, int mode=SLAVESERIAL_MODE,
// int Pts_configure(const char *, int, int );
int Pts_configure_bit(const char *, int, int);
// int Pts_configure_rbt(const char *, int, int);
int Pts_check_configure(int);
int Pts_reset(int);
 
#define PTSADDR 0x50000000
 
 
//#define Pts_write(VME,DATA) VME_write_32(udev,Ext_NoPriv_Data,PTSADDR+(VME),(DATA))
//#define Pts_read(VME,DATA) VME_read_32(udev,Ext_NoPriv_Data,PTSADDR+(VME),(DATA))
 
 
#endif
/pts/wienvme_dll.c
0,0 → 1,264
#include <ctype.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include "pcivme_ni.h"
#include "wienvme_dll.h"
//----------- DEFINES -----------------------------------------------------
#define DEVICENAME_LINUX "/dev/vmemm_1" // a device name 'template' for WINNT
 
 
 
int hHandle24, hHandle32, hHandle16;
int VMEerrors=0;
 
void VME_load (char* module_path)
{
VMEerrors=0;
}
 
int VME_open (int* hHandle, unsigned char AddMod, char* device_name,
unsigned short module_number)
{
int result;
char dname[256];
/* open a path to a device. */
if (device_name == NULL) sprintf(dname,"%s", DEVICENAME_LINUX);
else sprintf(dname,"%s", device_name);
result = VMEinit(dname, module_number, AddMod, hHandle);
if (result) {
printf("Can't open interface \"%s\" to VMEMM-module ! err=%d\n", dname, result);
printf("module_number %d, AddMod %d, hHandle %d\n",module_number, AddMod, *hHandle);
exit(-1);
}
return(result);
}
 
int VME_open24 (void)
{
return (VME_open (&hHandle24, Std_NoPriv_Data, NULL, 1));
}
 
int VME_open32 (void)
{
return (VME_open (&hHandle32, Ext_NoPriv_Data, NULL, 1));
}
 
int VME_open16 (void)
{
return (VME_open (&hHandle16, Short_NoPriv, NULL, 1));
}
 
int VME_start (char* module_path)
{
VME_load(module_path);
VME_open24();
VME_open32();
VME_open16();
return 0;
}
 
void VME_unload ()
{
return;
}
 
int VME_close (int hHandle)
{
int result;
 
/* close the opened path */
printf("VME_Close at addr=%d\n",hHandle);
result = VMEclose(hHandle);
if (result) {
printf("Can't close interface!\n");
}
return (result);
}
 
int VME_close24 ()
{
return (VME_close (hHandle24));
}
 
int VME_close32 ()
{
return (VME_close (hHandle32));
}
 
int VME_close16 ()
{
return (VME_close (hHandle16));
}
 
 
int VME_stop ()
{
VME_close24();
VME_close32();
VME_close16();
VME_unload();
return 0;
}
 
int VME_reset ()
{
int result;
 
/* close the opened path */
result = VMEreset(hHandle16);
if (result) {
printf("Can't reset interface A16!\n");
}
result = VMEreset(hHandle24);
if (result) {
printf("Can't reset interface A24!\n");
}
result = VMEreset(hHandle32);
if (result) {
printf("Can't reset interface A32!\n");
}
return (result);
}
 
int VME_read8 (int hHandle, unsigned long n, unsigned long at, void* buff)
{
int result;
 
/* D8 read */
result = VMEread(hHandle, at, 1, n, buff);
if (result) {
VMEerrors++;
printf("D8 read at 0x%lX failed!\n", at);
}
// printf("0x%X, 0x%X, 0x%X, 0x%X\n", hHandle, at, n, * (unsigned short *) buff);
return (result);
}
 
int VME_read16 (int hHandle, unsigned long n, unsigned long at, void* buff)
{
int result;
 
/* D16 read */
result = VMEread(hHandle, at, 2, n, buff);
if (result) {
VMEerrors++;
printf("D16 read at 0x%lX failed!\n", at);
}
// printf("0x%X, 0x%X, 0x%X, 0x%X\n", hHandle, at, n, * (unsigned short *) buff);
return (result);
}
 
int VME_read32 (int hHandle, unsigned long n, unsigned long at, void* buff)
{
int result;
 
/* D32 read */
result = VMEread(hHandle, at, 4, n, buff);
if (result) {
VMEerrors++;
printf("D32 read at 0x%lX failed!\n", at);
}
//printf("0x%X, 0x%X, 0x%X, 0x%X\n", hHandle, at, n, * (unsigned short *) buff);
return (result);
}
 
int VME_write8 (int hHandle, unsigned long n, unsigned long at, void* buff)
{
int result;
 
/* D8 write */
result = VMEwrite(hHandle, at, 1, n, buff);
if (result) {
VMEerrors++;
printf("D8 write at 0x%lX failed!\n", at);
}
return (result);
}
 
int VME_write16 (int hHandle, unsigned long n, unsigned long at, void* buff)
{
int result;
 
/* D16 write */
result = VMEwrite(hHandle, at, 2, n, buff);
if (result) {
VMEerrors++;
printf("D16 write at 0x%lX failed!\n", at);
}
return (result);
}
 
int VME_write32 (int hHandle, unsigned long n, unsigned long at, void* buff)
{
int result;
 
/* D32 write */
result = VMEwrite(hHandle, at, 4, n, buff);
if (result) {
VMEerrors++;
printf("D32 write at 0x%lX failed!\n", at);
}
//printf("D32 write at 0x%X buff=0x%X\n", at,((int*) buff)[0]);
return (result);
}
 
 
#ifdef MAIN
int GetHandle(int w){
switch (w){
case 16: return hHandle16;
case 24: return hHandle24;
case 32: return hHandle24;
 
}
return 24;
}
 
int main(int argc, char **argv){
unsigned long address=0x32100000, value;
unsigned char modifier=24;
int hHandle, result=0;
int width=4;
int c;
opterr = 0;
VME_start(NULL);
while ((c = getopt (argc, argv, "a:w:rm:osd:")) != -1)
switch (c)
{
case 's':
VME_reset();
break; // reset
case 'a':
address = strtoul (optarg,NULL,0);
break; // address
case 'm':
modifier = strtoul (optarg,NULL,0);
break; // modifier
case 'd':
width = strtoul (optarg,NULL,0);
printf("Width= %d\n",width);
break; // data width
case 'w':
value = strtoul (optarg,NULL,0);
hHandle = GetHandle(modifier);
result = VMEwrite(hHandle, address, width, 1, &value);
if (result) printf("A%d D%d write at 0x%lX failed! result=%d err=%d\n", modifier, width*8, address, result, GetLastError(hHandle));
break; // write
case 'r':
hHandle = GetHandle(modifier);
result = VMEread(hHandle, address, width, 1, &value);
if (result) printf("A%d D%d read at 0x%lX failed! result=%d err=%d\n", modifier,width*8, address, result, GetLastError(hHandle));
break; // read
default:
printf("Unknown command %c\n",c);
}
 
VME_stop();
}
#endif
Property changes:
Added: svn:executable
Index: pts/wienvme_dll.h
===================================================================
--- pts/wienvme_dll.h (nonexistent)
+++ pts/wienvme_dll.h (revision 12)
@@ -0,0 +1,59 @@
+#ifndef _WIENVME_DLL_H
+#define _WIENVME_DLL_H
+
+extern int VMEerrors;
+extern int hHandle24, hHandle32, hHandle16;
+
+void VME_load (char*);
+int VME_open (int*, unsigned char, char*, unsigned short);
+int VME_open24 (void);
+int VME_open32 (void);
+int VME_open16 (void);
+int VME_start (char*);
+void VME_unload (void);
+int VME_close (int);
+int VME_close24 (void);
+int VME_close32 (void);
+int VME_close16 (void);
+int VME_stop (void);
+int VME_reset (void);
+
+int VME_read8 (int, unsigned long, unsigned long, void*);
+int VME_read16 (int, unsigned long, unsigned long, void*);
+int VME_read32 (int, unsigned long, unsigned long, void*);
+int VME_write8 (int, unsigned long, unsigned long, void*);
+int VME_write16 (int, unsigned long, unsigned long, void*);
+int VME_write32 (int, unsigned long, unsigned long, void*);
+
+#define VME_START(NODE) VME_start((NODE))
+#define VME_STOP() VME_stop()
+#define VME_RESET() VME_reset()
+#define VME_A24D8_R(VME,DATA) VME_read8(hHandle24, 1, (VME), (DATA))
+#define VME_A24D16_R(VME,DATA) VME_read16(hHandle24, 1, (VME), (DATA))
+#define VME_A24D32_R(VME,DATA) VME_read32(hHandle24, 1, (VME), (DATA))
+#define VME_A24D8_W(VME,DATA) VME_write8(hHandle24, 1, (VME), (DATA))
+#define VME_A24D16_W(VME,DATA) VME_write16(hHandle24, 1, (VME), (DATA))
+#define VME_A24D32_W(VME,DATA) VME_write32(hHandle24, 1, (VME), (DATA))
+#define VME_A32D8_R(VME,DATA) VME_read8(hHandle32, 1, (VME), (DATA))
+#define VME_A32D16_R(VME,DATA) VME_read16(hHandle32, 1, (VME), (DATA))
+#define VME_A32D32_R(VME,DATA) VME_read32(hHandle32, 1, (VME), (DATA))
+#define VME_A32D8_W(VME,DATA) VME_write8(hHandle32, 1, (VME), (DATA))
+#define VME_A32D16_W(VME,DATA) VME_write16(hHandle32, 1, (VME), (DATA))
+#define VME_A32D32_W(VME,DATA) VME_write32(hHandle32, 1, (VME), (DATA))
+
+typedef unsigned short ADDRESS_MODIFIER;
+
+#define Std_Sup_Data (ADDRESS_MODIFIER)0x3d
+#define Std_Sup_Prog (ADDRESS_MODIFIER)0x3e
+#define Std_NoPriv_Data (ADDRESS_MODIFIER)0x39
+#define Std_NoPriv_Prog (ADDRESS_MODIFIER)0x3a
+
+#define Short_Sup (ADDRESS_MODIFIER)0x2d
+#define Short_NoPriv (ADDRESS_MODIFIER)0x29
+
+#define Ext_Sup_Data (ADDRESS_MODIFIER)0x0d
+#define Ext_Sup_Prog (ADDRESS_MODIFIER)0x0e
+#define Ext_NoPriv_Data (ADDRESS_MODIFIER)0x09
+#define Ext_NoPriv_Prog (ADDRESS_MODIFIER)0x0a
+
+#endif
/pts/wienvme_dll.h
Property changes:
Added: svn:executable
Index: pts/pts.h
===================================================================
--- pts/pts.h (nonexistent)
+++ pts/pts.h (revision 12)
@@ -0,0 +1,15 @@
+#ifndef PTS__H_
+#define PTS__H_
+
+// S0x.h
+
+#define MAX_PTS 1
+#define NCHAINS_PTS 4
+#define NCHIPS_CHAIN 4
+#define NCH_CHIP 18
+
+#define NBPAR_CH 8
+#define NBDATA_CH 4
+#define NB_WORD 32
+
+#endif
Index: pts/Makefile
===================================================================
--- pts/Makefile (nonexistent)
+++ pts/Makefile (revision 12)
@@ -0,0 +1,75 @@
+CC = gcc
+
+
+INC=-I. -I$(ROOTINC)
+
+LIBS=$(ROOTLIB) -L./ -lm
+
+
+
+
+SRC = .
+INC1 = -I. -I../lib -I/usr/include
+DBG =
+CFLAGS = $(DBG) $(INC) -fPIC -DLINUX -Wall
+
+
+TARGET = daq
+
+FILES = $(SRC)/daq.C
+
+VMELIB = libf9vme.a
+
+SHLIB = -lpcivme -lz
+
+OBJ_FILES = PtsModule.o
+
+
+all: pts
+
+pts: PtsModule.c wienvme_dll.c
+ $(CXX) $(CFLAGS) PtsModule.c wienvme_dll.c $(SHLIB) -o pts
+# cp sa02_ctrl ../bin
+
+
+
+
+
+
+.cpp.o:
+ $(CXX) -c $(CFLAGS) $<
+ ar r $(VMELIB) $@
+
+.C.o:
+ $(CXX) -c $(CFLAGS) $<
+ ar r $(VMELIB) $@
+
+
+.cc.o:
+ $(CXX) -c $(CFLAGS) $<
+ ar r $(VMELIB) $@
+
+.c.o:
+ $(CXX) -c $(CFLAGS) $<
+ ar r $(VMELIB) $@
+
+vme: $(OBJ_FILES)
+
+
+
+VMEModule.o: VMEModule.hh VMEModule.cc
+
+CAENV965.o: CAENV965.h CAENV965_DEF.h CAENV965.c
+
+
+$(TARGET): $(FILES) $(OBJ_FILES)
+ $(CXX) -DMAIN $(CFLAGS) $(FILES) $(OBJ_FILES) $(SHLIB) -o $(TARGET)
+
+
+
+clean:
+ rm Dict.C libdaq.so $(TARGET1)
+
+
+tgz:
+ tar czvf vme.tgz Makefile *.c *.h *.C *.cc *.hh
Index: pts/PtsModule.c
===================================================================
--- pts/PtsModule.c (nonexistent)
+++ pts/PtsModule.c (revision 12)
@@ -0,0 +1,250 @@
+// ./pts -a 0x1000000 -v 1 -w 2 turn LED ON
+// ./pts -a 0x1000000 -v 1 -w 1 turn LED OFF
+#include <stdlib.h>
+#include <stdio.h>
+#include <stdint.h>
+#include <ctype.h>
+#include <unistd.h>
+#include <string.h>
+#include "PtsModule.h"
+
+void Delay(double t){
+usleep(t*1e6);
+}
+
+
+uint32_t ptaddr=0;
+
+int Pts_write(uint32_t addr, uint32_t data ){
+VME_A32D32_W(ptaddr+addr,&data);
+return 0;
+}
+
+int Pts_read(uint32_t addr, uint32_t *data ){
+VME_A32D32_R(ptaddr+addr,data);
+return 0;
+}
+
+
+int Pts_erase( int verbose ) {
+ uint32_t dum;
+ Pts_write( ADR_CSR1, 0 );
+ Delay(0.1);
+ Pts_read( ADR_CSR1, &dum);
+ if( verbose ) printf( "CSR1(0x%02x) = 0x%04x\n", ADR_CSR1,
+ dum & 0xffff );
+ Pts_write( ADR_CSR1, CSR1_PROGRAM_ );
+ Delay(0.1);
+ Pts_read( ADR_CSR1, &dum);
+ if( verbose ) printf( "CSR1(0x%02x) = 0x%04x\n", ADR_CSR1,
+ dum & 0xffff );
+ return 1;
+}
+/*
+int Pts_configure( const char *filename, int mode, int verbose ) {
+ int len = strlen( filename );
+ if( len > 4 ) {
+ const char *p = filename+len-4;
+ if( strcmp(p,".bit")==0 ) return Pts_configure_bit( filename, mode, verbose );
+ if( strcmp(p,".rbt")==0 ) return Pts_configure_rbt( filename, mode, verbose );
+ }
+ if( verbose ) fprintf( stderr, "Bad filename: \"%s\" .\n" );
+ return -1;
+}
+
+int PtsModule::configure_rbt( const char *filename, int mode, int verbose ) {
+ long n, pos;
+ char cs[1024];
+ FILE *fp;
+ if( ( fp = fopen( filename, "r" ) ) == NULL ) {
+ if( verbose ) fprintf( stderr, "cannot open \"%s\"\n", filename );
+ return -1;
+ }
+ if( verbose ) printf( "file \"%s\" opened.\n", filename );
+
+ do{
+ pos = ftell(fp);
+ fgets( cs, sizeof(cs), fp );
+ puts(cs);
+ n=strlen(cs);
+ } while( n==0 || strspn( cs, " \t\n01" )!=n );
+ fseek( fp, pos, SEEK_SET );
+
+ long nchar = 0;
+ if( mode == SLAVESERIAL_MODE ) {
+ write( ADR_MODE, SLAVESERIAL_MODE );
+ erase( verbose );
+ int c;
+ const long bit_per_dot = BYTE_PER_DOT*8;
+ while( (c=getc(fp))!=EOF ){
+ if( c=='0' || c=='1' ) {
+ write( ADR_CFG, c=='0' ? 0 : 1 );
+ nchar++;
+ if( verbose && ++nchar%bit_per_dot==0 ) putchar('.');
+ }
+ else if( isspace(c) ) continue;
+ else {
+ fprintf( stderr, "(%ld) illegal character : %c\n", nchar, c );
+ fclose(fp);
+ return -1;
+ }
+ }
+ } else if(mode == SELECTMAP_MODE) {
+ if(verbose) fprintf(stderr, "\nselectmap mode (rbt file) not supported\n");
+ return -1;
+ } else {
+ if(verbose) fprintf(stderr, "\nIllegal mode\n");
+ return -1;
+ }
+ if(verbose) printf("\ntotal %ld bits\n", nchar);
+ fclose(fp);
+ return check_configure( verbose );
+}
+*/
+int Pts_configure_bit( const char *filename, int mode, int verbose ) {
+ int c,j;
+ int dummyword;
+ FILE *fp;
+ const long byte_per_dot = BYTE_PER_DOT;
+ unsigned long nchar = 0;
+
+ if( ( fp = fopen( filename, "rb" ) ) == NULL ) {
+ if( verbose ) fprintf( stderr, "cannot open \"%s\"\n", filename );
+ return -1;
+ }
+ if(verbose) printf( "file \"%s\" opened.\n", filename );
+
+ /* ------------------------------------------------------------ *\
+ The data for the configuration start from 0xffff_ffff_aa99_aa66
+ ( cf. xapp138; we don't know the definition of the BIT file )
+ \* ------------------------------------------------------------ */
+ dummyword = 0;
+ do{
+ if( (c = getc( fp )) == EOF ) {
+ if(verbose) fprintf(stderr, "EOF detected. Exit.\n");
+ return -1;
+ }
+ (c == 0xff) ? dummyword++ : (dummyword=0);
+ } while( dummyword < 4 );
+
+// const long byte_per_dot = BYTE_PER_DOT;
+// unsigned long nchar = 0;
+ if( mode == SLAVESERIAL_MODE ) {
+ if(verbose) puts("slave serial mode");
+ Pts_write( ADR_MODE, mode );
+ Pts_erase( verbose );
+ for( j=0; j<32; j++ ) Pts_write( ADR_CFG, 0x1 );
+ while( (c=getc(fp))!=EOF ){
+ for( j=0; j<8; j++ ) Pts_write( ADR_CFG, (c>>(7-j))&0x1 );
+ nchar++;
+ if( verbose && nchar%byte_per_dot==0 ) putchar('.');
+ }
+ } else if( mode == SELECTMAP_MODE ) {
+ if( verbose ) puts("select map mode");
+ Pts_write( ADR_MODE, SELECTMAP_MODE );
+ Pts_erase( verbose );
+ for( j=0; j<4; j++ ) Pts_write( ADR_CFG, 0xff );
+ while( (c=getc(fp))!=EOF ){
+ int cc = 0;
+ for(j=0; j<8; j++) cc |= ((c&(1<<j))>>j)<<(7-j);
+ Pts_write( ADR_CFG, cc );
+ nchar++;
+ if( verbose && nchar%byte_per_dot==0 ) putchar('.');
+ }
+ } else {
+ if(verbose) fprintf(stderr, "\nIllegal mode\n");
+ return -1;
+ }
+ if(verbose) printf("\ntotal %ld bits\n", nchar);
+ fclose(fp);
+ return Pts_check_configure( verbose );
+}
+
+int Pts_check_configure( int verbose ) {
+ uint32_t csr1_value;
+ Pts_read(ADR_CSR1,&csr1_value);
+ if(verbose) printf("CSR1(0x%02x)=0x%04x\n",ADR_CSR1,csr1_value&0xffff);
+ if(csr1_value&CSR1_DONE) {
+ if(verbose) puts("configure complete.");
+ return 1;
+ } else {
+ if(verbose) puts("configure not complete.");
+ return -1;
+ }
+}
+
+int Pts_reset( int verbose ) {
+ Pts_write(ADR_CSR0,1);
+ if( verbose ) printf( "CSR0(0x%02x) = 0x01\n", ADR_CSR0 );
+ return 1;
+}
+
+int Pts_write_csr( int verbose, uint32_t value ) {
+ Pts_write(ADR_CSR0,value);
+ if( verbose ) printf( "Pts_write_csr 0x%08x\n", value );
+ return 1;
+}
+
+
+void help(char *argv){
+ printf("Usage: %s -a <ptsaddr> -v <verbose> -c .... Pts_check_configure\n", argv);
+ printf("Usage: %s -a <ptsaddr> -v <verbose> -i <filename> -b mode ... Pts_configure_bit\n", argv);
+ printf("Usage: %s -a <ptsaddr> -v <verbose> -e .... Pts_erase\n", argv);
+ printf("Usage: %s -a <ptsaddr> -v <verbose> -r .... Pts_reset\n", argv);
+ printf("Usage: %s -a <ptsaddr> -v <verbose> -w <value> .... Pts_write_csr\n", argv);
+}
+
+int main (int argc, char ** argv){
+unsigned long value;
+
+ int verbose=0;
+ char filename[256]="file.bit";
+ int c;
+ opterr = 0;
+
+if (argc<2) {
+ help(argv[0]);
+ exit(-1);
+}
+
+VME_START(NULL);
+ while ((c = getopt (argc, argv, "v:rea:cw:i:b:h")) != -1)
+ switch (c)
+ {
+ case 'v':
+ verbose = atoi(optarg);
+ break;
+ case 'r':
+ Pts_reset(verbose);
+ break; // reset
+ case 'e':
+ Pts_erase(verbose);
+ break; // erase
+ case 'a':
+ ptaddr = strtoul (optarg,NULL,0);
+ break; // address
+ case 'c':
+ Pts_check_configure( verbose );
+ break;
+ case 'w':
+ value = strtoul (optarg,NULL,0);
+ Pts_write_csr( verbose, value );
+ break;
+ case 'i':
+ sprintf(filename,"%s",optarg);
+ break; // data width
+ case 'b':
+//#define SELECTMAP_MODE 2
+//#define SLAVESERIAL_MODE 3
+ value = strtoul (optarg,NULL,0);
+ Pts_configure_bit( filename, value, verbose );
+ break;
+ case 'h':
+ help(argv[0]);
+ break;
+ default:
+ printf("Unknown command %c\n",c);
+ }
+VME_STOP();
+}
+
Index: pts/README
===================================================================
--- pts/README (nonexistent)
+++ pts/README (revision 12)
@@ -0,0 +1,106 @@
+control of the KEK PTS with the Wiener VME controller
+
+
+<< PTS module specification >>
+
+- Block diagram is shown in ptsblock.ps.gz (ptsblock.obj).
+- The standard CPLD logic is assumed below.
+
+[clock, NIM in/out selection in the CPLD]
+ << CPLD logic >>
+ (input) (output)
+ ICLK
+ EXTCLK0_ --------> EXT[0]
+ EXTCLK1_ --------> EXT[1]
+ EXTCLK2_ --------> GCLK[2]
+ EXTCLK3_ --------> GCLK[3]
+ VOUT[0] GCLK[0] = PCLK
+ VOUT[1] GCLK[1] = SCLK
+ BUSA[0] CLKOUT[0]
+ BUSA[1] CLKOUT[1]
+ (internal)
+ VMECLK
+
+ - EXT[1:0], VOUT[1:0] are lines between the CPLD and FPGA.
+ - BUSA[1:0] are lines connected to the connecter in the front panel.
+ - VMECLK is an internal register.
+ - CLKOUT[1:0] and GCLK[1:0] can be connected to any
+ of input signals and VMECLK. This can be set by
+ accessing ADR_CLK.
+
+[VME addressed]
+ A[31:12] must be selected by dip-switches.
+ A[11:0] is available in the module.
+ A[11:0] = 12'b0000xxxxxxxx : reserved by CPLD (see pts_h.v)
+ others : available to FPGA
+
+[Direction of BUS A-D]
+ output = high(1'b1), input = low(1'b0)
+
+[Pin assignment of BUS line]
+ Front View
+ +---------+
+ | GND GND |
+ | GND 15 |
+ | GND 14 |
+ .......
+ | GND 1 |
+ | GND 0 |
+ +---------+
+
+
+
+
+
+// pts_h.v
+//
+// 2000/09/09 ver 1.00 S.Nishida (for ptscpld ver 1.00)
+//
+
+/* address */
+`define ADR_CSR0 6'b000000
+ // D[1] LEDTEST
+ // D[0] RESET
+`define ADR_CLK 6'b000001
+ // D[15:12] CLKOUT1
+ // D[11:8] CLKOUT0
+ // D[7:4] SCLK
+ // D[3:0] PCLK
+`define ADR_VMECLK 6'b000010
+ // D[3] CLKOUT1
+ // D[2] CLKOUT0
+ // D[1] SCLK
+ // D[0] PCLK
+`define ADR_BUSA_REG 6'b000100
+`define ADR_BUSA_IN 6'b000101
+`define ADR_BUSA_DIR 6'b000110
+ // D[1:0] BUSA direction
+`define ADR_CFG 6'b010000
+`define ADR_CSR1 6'b010001
+ // D[8] DONE
+ // D[1] VCS_
+ // D[0] PROGRAM_
+`define ADR_MODE 6'b010010
+`define ADR_SYSRESET 6'b111111
+ // D[15:0] = 0x0000 is necessaly
+
+/* BUSA direction */
+`define DIRA_FPGA 2'b00
+`define DIRA_IN 2'b10
+`define DIRA_OUT 2'b11
+
+/* CLK source */
+`define CLK_IN 4'b0000
+`define CLK_EXT0 4'b0001
+`define CLK_EXT1 4'b0010
+`define CLK_EXT2 4'b0011
+`define CLK_EXT3 4'b0100
+`define CLK_VME 4'b0101
+`define CLK_VOUT0 4'b0110
+`define CLK_VOUT1 4'b0111
+`define CLK_BUSA0 4'b1000
+`define CLK_BUSA1 4'b1001
+
+/* Configuration Mode */
+`define SELECTMAP_MODE 3'b010
+`define SLAVESERIAL_MODE 3'b011
Index: pts/vme.h
===================================================================
--- pts/vme.h (nonexistent)
+++ pts/vme.h (revision 12)
@@ -0,0 +1,13 @@
+#ifndef _VME_H_
+#define _VME_H_
+
+#define _VI_FUNC
+#include "wienvme_dll.h"
+#endif
+
+#define VME_MWEXEC()
+#define VME_MWRST()
+#define VME_MRRST()
+
+#define VME_A24D32_MW VME_A24D32_W
+#define VME_A24D32_MR VME_A24D32_R