Rev 5 |
Blame |
Compare with Previous |
Last modification |
View Log
| RSS feed
#include <stdlib.h>
#include <stdio.h>
#include "pcivme_ni.h"
#include "wienvme_dll.h"
//----------- DEFINES -----------------------------------------------------
#define DEVICENAME_LINUX "/dev/vmemm_1" // a device name 'template' for WINNT
usb_dev_handle
*udev
;
int VME_start
(char* serial
)
{
char serial_default
[100];
sprintf(serial_default
, "VM0120");
if (serial
!= NULL
)
udev
= xxusb_serial_open
(serial
);
else
udev
= xxusb_serial_open
(serial_default
);
printf(" VME_start %s--->udev!=NULL ==>%d\n", serial
, udev
!=NULL
);
if (!udev
) {
printf(" Check usb udev permissions and restart! Exiting .....\n", serial
, udev
!=NULL
);
exit(-1);
}
return 0;
}
int VME_stop
()
{
if (udev
) xxusb_device_close
(udev
);
return 0;
}
short Address_Modifier
= Std_NoPriv_Data
;
int VME_read16
(Uint32_t at
, void* buff
)
{
int result
;
/* D16 read */
result
= VME_read_16
(udev
, Address_Modifier
, at
, (Uint32_t
*) buff
);
if (result
<0) {
printf("D16 read at 0x%X failed! err=%d\n", at
,result
);
}
// printf("0x%X, 0x%X, 0x%X, 0x%X\n", hHandle, at, n, * (unsigned short *) buff);
return (result
);
}
int VME_read32
(Uint32_t at
, void* buff
)
{
int result
;
/* D32 read */
result
= VME_read_32
(udev
, Address_Modifier
, at
, (Uint32_t
*) buff
);
if (result
< 0) {
printf("D32 read at 0x%X failed err=%d!\n", at
,result
);
}
//printf("0x%X, 0x%X, 0x%X, 0x%X\n", hHandle, at, n, * (unsigned short *) buff);
return (result
);
}
int VME_write16
(Uint32_t at
, void* buff
)
{
int result
;
Uint32_t data
= *((short *)buff
);
/* D16 write */
result
= VME_write_16
(udev
, Address_Modifier
, at
, data
);
if (result
<0) {
printf("D16 write at 0x%X failed! err=%d\n", at
,result
);
}
return (result
);
}
int VME_write32
( Uint32_t at
, void* buff
)
{
int result
;
Uint32_t data
= *((Uint32_t
*)buff
);
/* D32 write */
result
= VME_write_32
(udev
, Address_Modifier
, at
, data
);
if (result
<0) {
printf("D32 write at 0x%X failed! err=%d\n", at
,result
);
}
//printf("D32 write at 0x%lX buff=0x%X\n", at,((int*) buff)[0]);
return (result
);
}