+ free(xpcu_event);
+ }
+
+ return 0;
+}
+
+int xpcu_int_state(struct interrupt *it, int enable) {
+ struct xpcu_event_s *xpcu_event = (struct xpcu_event_s*)it->hInterrupt;
+
+ if (!xpcu_event)
+ return -ENODEV;
+
+ if (enable == ENABLE_INTERRUPT) {
+ it->fEnableOk = 1;
+ it->fStopped = 0;
+ it->dwCounter = 0;
+ pthread_mutex_trylock(&xpcu_event->interrupt);
+ } else {
+ it->dwCounter = 0;
+ it->fStopped = 1;
+ if (pthread_mutex_trylock(&xpcu_event->interrupt) == EBUSY)
+ pthread_mutex_unlock(&xpcu_event->interrupt);
+ }
+
+ return 0;
+}
+
+int xpcu_int_wait(struct interrupt *it) {
+ struct xpcu_event_s *xpcu_event = (struct xpcu_event_s*)it->hInterrupt;
+
+ if (!xpcu_event)
+ return -ENODEV;
+
+ if (it->dwCounter < xpcu_event->count) {
+ it->dwCounter++;
+ } else {
+ pthread_mutex_lock(&xpcu_event->interrupt);
+ pthread_mutex_unlock(&xpcu_event->interrupt);