Subversion Repositories f9daq

Rev

Rev 5 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
5 f9daq 1
#include <stdlib.h>
2
#include <stdio.h>
3
#include "pcivme_ni.h"
4
#include "wienvme_dll.h"
5
//----------- DEFINES -----------------------------------------------------
6
#define DEVICENAME_LINUX "/dev/vmemm_1"     // a device name 'template' for WINNT
7
 
8
usb_dev_handle *udev;
9
 
10
 
11
 
12
 
13
int VME_start (char* serial)
14
{
15
 
16
 char serial_default[100];
17
 sprintf(serial_default, "VM0120");
18
 if (serial != NULL)
19
        udev = xxusb_serial_open(serial);
20
 else
21
         udev =  xxusb_serial_open(serial_default);
22
   printf(" VME_start %s--->udev!=NULL ==>%d\n", serial, udev!=NULL);
23
   if (!udev) {
24
      printf(" Check usb udev permissions and restart!  Exiting .....\n", serial, udev!=NULL);
25
      exit(-1);
26
   }
27
  return 0;
28
}
29
 
30
 
31
 
32
int VME_stop ()
33
{
34
  if (udev) xxusb_device_close(udev);
35
 
36
 
37
  return 0;
38
}
39
 
40
short Address_Modifier= Std_NoPriv_Data;
41
 
42
int VME_read16 (Uint32_t at, void* buff)
43
{
44
  int result;
45
 
46
/* D16 read */
47
 
48
  result = VME_read_16(udev, Address_Modifier, at , (Uint32_t *) buff);
49
  if (result <0) {
50
    printf("D16 read at 0x%X failed!  err=%d\n", at,result);
51
  }
52
//  printf("0x%X, 0x%X, 0x%X, 0x%X\n", hHandle, at, n, * (unsigned short *) buff);
53
  return (result);
54
}
55
 
56
int VME_read32 (Uint32_t at, void* buff)
57
{
58
  int result;
59
 
60
/* D32 read */
61
 
62
  result = VME_read_32(udev, Address_Modifier, at , (Uint32_t *) buff);
63
  if (result < 0) {
64
    printf("D32 read at 0x%X failed err=%d!\n", at,result);
65
  }
66
  //printf("0x%X, 0x%X, 0x%X, 0x%X\n", hHandle, at, n, * (unsigned short *) buff);
67
  return (result);
68
}
69
 
70
int VME_write16 (Uint32_t at, void* buff)
71
{
72
  int result;
73
  Uint32_t data= *((short *)buff);
74
 
75
/* D16 write */
76
 
77
        result = VME_write_16(udev, Address_Modifier, at, data );
78
  if (result<0) {
79
    printf("D16 write at 0x%X failed! err=%d\n", at,result);
80
  }
81
  return (result);
82
}
83
 
84
int VME_write32 ( Uint32_t at, void* buff)
85
{
86
  int result;
87
  Uint32_t data= *((Uint32_t *)buff);
88
 
89
/* D32 write */
90
 
91
        result = VME_write_32(udev, Address_Modifier, at, data );
92
 
93
  if (result<0) {
94
    printf("D32 write at 0x%X failed!  err=%d\n", at,result);
95
  }
96
  //printf("D32 write at 0x%lX buff=0x%X\n", at,((int*) buff)[0]);
97
  return (result);
98
}