/** * Initialize an analog trigger from a channel. */ void AnalogTrigger::InitTrigger(uint32_t channel) { void* port = getPort(channel); int32_t status = 0; uint32_t index = 0; m_trigger = initializeAnalogTrigger(port, &index, &status); wpi_setErrorWithContext(status, getHALErrorMessage(status)); m_index = index; HALReport(HALUsageReporting::kResourceType_AnalogTrigger, channel); }
/* * Class: edu_wpi_first_wpilibj_hal_AnalogJNI * Method: initializeAnalogTrigger * Signature: (Ljava/nio/ByteBuffer;Ljava/nio/IntBuffer;Ljava/nio/IntBuffer;)Ljava/nio/ByteBuffer; */ JNIEXPORT jobject JNICALL Java_edu_wpi_first_wpilibj_hal_AnalogJNI_initializeAnalogTrigger (JNIEnv * env, jclass, jobject id, jobject index, jobject status) { void ** javaId = (void**)env->GetDirectBufferAddress(id); ANALOGJNI_LOG(logDEBUG) << "Port Ptr = " << *javaId; jint * indexPtr = (jint*)env->GetDirectBufferAddress(index); ANALOGJNI_LOG(logDEBUG) << "Index Ptr = " << indexPtr; jint * statusPtr = (jint*)env->GetDirectBufferAddress(status); ANALOGJNI_LOG(logDEBUG) << "Status Ptr = " << statusPtr; void ** analogTriggerPtr = new void *; *analogTriggerPtr = initializeAnalogTrigger(*javaId, (uint32_t *)indexPtr, statusPtr); ANALOGJNI_LOG(logDEBUG) << "Status = " << *statusPtr; ANALOGJNI_LOG(logDEBUG) << "AnalogTrigger Ptr = " << *analogTriggerPtr; return env->NewDirectByteBuffer(analogTriggerPtr, 4); }