+
+void xpcu_int_state(struct xpcu_s *xpcu, struct interrupt *it, int enable) {
+ static pthread_mutex_t *interrupt = &dummy_interrupt;
+
+ if (it->hInterrupt != (unsigned long)xpcu)
+ return;
+
+ if (xpcu)
+ interrupt = &xpcu->interrupt;
+
+ if (enable == ENABLE_INTERRUPT) {
+ it->fEnableOk = 1;
+ it->fStopped = 0;
+ pthread_mutex_trylock(interrupt);
+ } else {
+ it->dwCounter = 0;
+ it->fStopped = 1;
+ if (pthread_mutex_trylock(interrupt) == EBUSY)
+ pthread_mutex_unlock(interrupt);
+ }
+}
+
+void xpcu_int_wait(struct xpcu_s *xpcu, struct interrupt *it) {
+ if (it->hInterrupt != (unsigned long)xpcu)
+ return;
+
+ if (xpcu) {
+ if (it->dwCounter == 0) {
+ it->dwCounter = 1;
+ } else {
+ pthread_mutex_lock(&xpcu->interrupt);
+ pthread_mutex_unlock(&xpcu->interrupt);
+ }
+ } else {
+ pthread_mutex_lock(&dummy_interrupt);
+ pthread_mutex_unlock(&dummy_interrupt);
+ }
+}