void attachInterrupt(uint8_t pin, InterruptCallback callback, GPIO_INT_TYPE mode) { if (pin >= 16) return; // WTF o_O _gpioInterruptsList[pin] = callback; _delegateFunctionList[pin] = nullptr; attachInterruptHandler(pin, mode); }
void attachInterrupt(uint8_t pin, Delegate<void()> delegateFunction, GPIO_INT_TYPE mode) { if (pin >= 16) return; // WTF o_O _gpioInterruptsList[pin] = NULL; _delegateFunctionList[pin] = delegateFunction; attachInterruptHandler(pin, mode); }
/* * Class: edu_wpi_first_wpilibj_hal_InterruptJNI * Method: attachInterruptHandler * Signature: (JLedu/wpi/first/wpilibj/hal/InterruptJNI/InterruptHandlerFunction;Ljava/nio/ByteBuffer;)V */ JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_InterruptJNI_attachInterruptHandler (JNIEnv * env, jclass, jlong interrupt_pointer, jobject handler, jobject param) { INTERRUPTJNI_LOG(logDEBUG) << "Calling INTERRUPTJNI attachInterruptHandler"; INTERRUPTJNI_LOG(logDEBUG) << "Interrupt Ptr = " << (void*)interrupt_pointer; jclass cls = env->GetObjectClass(handler); INTERRUPTJNI_LOG(logDEBUG) << "class = " << cls; if (cls == 0) { INTERRUPTJNI_LOG(logERROR) << "Error getting java class"; assert(false); return; } jmethodID mid = env->GetMethodID(cls, "apply", "(ILjava/lang/Object;)V"); INTERRUPTJNI_LOG(logDEBUG) << "method = " << mid; if (mid == 0) { INTERRUPTJNI_LOG(logERROR) << "Error getting java method ID"; assert(false); return; } InterruptJNI* intr = new InterruptJNI; intr->Start(); intr->SetFunc(env, handler, mid, param); INTERRUPTJNI_LOG(logDEBUG) << "InterruptThreadJNI Ptr = " << intr; int32_t status = 0; attachInterruptHandler((void*)interrupt_pointer, interruptHandler, intr, &status); INTERRUPTJNI_LOG(logDEBUG) << "Status = " << status; CheckStatus(env, status); }
/** * Request one of the 8 interrupts asynchronously on this digital input. * Request interrupts in asynchronous mode where the user's interrupt handler * will be * called when the interrupt fires. Users that want control over the thread * priority * should use the synchronous method with their own spawned thread. * The default is interrupt on rising edges only. */ void InterruptableSensorBase::RequestInterrupts( InterruptHandlerFunction handler, void *param) { if (StatusIsFatal()) return; uint32_t index = m_interrupts->Allocate("Async Interrupt"); if (index == std::numeric_limits<uint32_t>::max()) { CloneError(*m_interrupts); return; } m_interruptIndex = index; // Creates a manager too AllocateInterrupts(false); int32_t status = 0; requestInterrupts(m_interrupt, GetModuleForRouting(), GetChannelForRouting(), GetAnalogTriggerForRouting(), &status); SetUpSourceEdge(true, false); attachInterruptHandler(m_interrupt, handler, param, &status); wpi_setErrorWithContext(status, getHALErrorMessage(status)); }
void detachInterrupt(uint8_t pin) { _gpioInterruptsList[pin] = NULL; _delegateFunctionList[pin] = nullptr; attachInterruptHandler(pin, GPIO_PIN_INTR_DISABLE); }