#include <stdio.h>
#include <usb.h>
#include <signal.h>
+#include <pthread.h>
#include "xilinx.h"
static int (*ioctl_func) (int, int, void *) = NULL;
static usb_dev_handle *usb_devhandle = NULL;
static unsigned long card_type;
static int ints_enabled = 0;
+static pthread_mutex_t int_wait = PTHREAD_MUTEX_INITIALIZER;
#define NO_WINDRVR 1
#undef DEBUG
break;
case CARD_REGISTER:
+ /* TODO: Implement for LPT-support */
+#if 0
{
- //struct card_register* cr = (struct card_register*)(wdheader->data);
- /* Todo: LPT-Port already in use */
+ struct card_register* cr = (struct card_register*)(wdheader->data);
}
+#endif
#ifdef DEBUG
fprintf(stderr,"faking CARD_REGISTER\n");
#endif
it->fEnableOk = 1;
ints_enabled = 1;
- //ret = (*ioctl_func) (fd, request, wdioctl);
+ pthread_mutex_trylock(&int_wait);
}
break;
it->dwCounter = 0;
it->fStopped = 1;
ints_enabled = 0;
+ pthread_mutex_unlock(&int_wait);
#endif
#ifdef DEBUG
fprintf(stderr,"Handle: %lu, Options: %lx, ncmds: %lu, enableok: %lu, count: %lu, lost: %lu, stopped: %lu\n", it->hInterrupt, it->dwOptions, it->dwCmds, it->fEnableOk, it->dwCounter, it->dwLost, it->fStopped);
/* FIXME: Select right interface! */
ret = usb_claim_interface(usb_devhandle, usbdevice->config[0].interface[usi->dwInterfaceNum].altsetting[usi->dwAlternateSetting].bInterfaceNumber);
if (!ret) {
- //ret = usb_set_configuration(usb_devhandle, usbdevice->config[0].bConfigurationValue);
if(!ret) {
ret = usb_set_altinterface(usb_devhandle, usi->dwAlternateSetting);
if (ret)
fprintf(stderr, "unique: %lu, bytes: %lu, options: %lx\n", ugdd->dwUniqueID, ugdd->dwBytes, ugdd->dwOptions);
#endif
pSize = ugdd->dwBytes;
- //ret = (*ioctl_func) (fd, request, wdioctl);
if (!ugdd->dwBytes) {
if (usbdevice) {
ugdd->dwBytes = usb_deviceinfo(NULL);
if (it->dwCounter == 0) {
it->dwCounter = 1;
} else {
- while(ints_enabled) {sleep(1);}
+ pthread_mutex_lock(&int_wait);
}
} else {
- while(ints_enabled) {sleep(1);}
+ pthread_mutex_lock(&int_wait);
}
#endif