mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-20 00:51:42 +00:00
Moves Interrupts over to Handles instead of pointers (#99)
This commit is contained in:
committed by
Peter Johnson
parent
74fc10999b
commit
046e043c4e
@@ -119,23 +119,22 @@ extern "C" {
|
||||
/*
|
||||
* Class: edu_wpi_first_wpilibj_hal_InterruptJNI
|
||||
* Method: initializeInterrupts
|
||||
* Signature: (IZ)J
|
||||
* Signature: (Z)I
|
||||
*/
|
||||
JNIEXPORT jlong JNICALL
|
||||
JNIEXPORT jint JNICALL
|
||||
Java_edu_wpi_first_wpilibj_hal_InterruptJNI_initializeInterrupts(
|
||||
JNIEnv* env, jclass, jint interruptIndex, jboolean watcher) {
|
||||
JNIEnv* env, jclass, jboolean watcher) {
|
||||
INTERRUPTJNI_LOG(logDEBUG) << "Calling INTERRUPTJNI initializeInterrupts";
|
||||
INTERRUPTJNI_LOG(logDEBUG) << "interruptIndex = " << interruptIndex;
|
||||
INTERRUPTJNI_LOG(logDEBUG) << "watcher = " << (bool)watcher;
|
||||
|
||||
int32_t status = 0;
|
||||
void* interrupt = initializeInterrupts(interruptIndex, watcher, &status);
|
||||
HalInterruptHandle interrupt = initializeInterrupts(watcher, &status);
|
||||
|
||||
INTERRUPTJNI_LOG(logDEBUG) << "Interrupt Ptr = " << interrupt;
|
||||
INTERRUPTJNI_LOG(logDEBUG) << "Interrupt Handle = " << interrupt;
|
||||
INTERRUPTJNI_LOG(logDEBUG) << "Status = " << status;
|
||||
|
||||
CheckStatus(env, status);
|
||||
return (jlong)interrupt;
|
||||
return (jint)interrupt;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -145,16 +144,16 @@ Java_edu_wpi_first_wpilibj_hal_InterruptJNI_initializeInterrupts(
|
||||
*/
|
||||
JNIEXPORT void JNICALL
|
||||
Java_edu_wpi_first_wpilibj_hal_InterruptJNI_cleanInterrupts(
|
||||
JNIEnv* env, jclass, jlong interrupt_pointer) {
|
||||
JNIEnv* env, jclass, jint interrupt_handle) {
|
||||
INTERRUPTJNI_LOG(logDEBUG) << "Calling INTERRUPTJNI cleanInterrupts";
|
||||
INTERRUPTJNI_LOG(logDEBUG) << "Interrupt Ptr = " << (void*)interrupt_pointer;
|
||||
INTERRUPTJNI_LOG(logDEBUG) << "Interrupt Handle = " << (HalInterruptHandle)interrupt_handle;
|
||||
|
||||
int32_t status = 0;
|
||||
cleanInterrupts((void*)interrupt_pointer, &status);
|
||||
cleanInterrupts((HalInterruptHandle)interrupt_handle, &status);
|
||||
|
||||
INTERRUPTJNI_LOG(logDEBUG) << "Status = " << status;
|
||||
|
||||
CheckStatus(env, status);
|
||||
// ignore status, as an invalid handle just needs to be ignored.
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -164,13 +163,13 @@ Java_edu_wpi_first_wpilibj_hal_InterruptJNI_cleanInterrupts(
|
||||
*/
|
||||
JNIEXPORT int JNICALL
|
||||
Java_edu_wpi_first_wpilibj_hal_InterruptJNI_waitForInterrupt(
|
||||
JNIEnv* env, jclass, jlong interrupt_pointer, jdouble timeout,
|
||||
JNIEnv* env, jclass, jint interrupt_handle, jdouble timeout,
|
||||
jboolean ignorePrevious) {
|
||||
INTERRUPTJNI_LOG(logDEBUG) << "Calling INTERRUPTJNI waitForInterrupt";
|
||||
INTERRUPTJNI_LOG(logDEBUG) << "Interrupt Ptr = " << (void*)interrupt_pointer;
|
||||
INTERRUPTJNI_LOG(logDEBUG) << "Interrupt Handle = " << (HalInterruptHandle)interrupt_handle;
|
||||
|
||||
int32_t status = 0;
|
||||
int result = waitForInterrupt((void*)interrupt_pointer, timeout,
|
||||
int result = waitForInterrupt((HalInterruptHandle)interrupt_handle, timeout,
|
||||
ignorePrevious, &status);
|
||||
|
||||
INTERRUPTJNI_LOG(logDEBUG) << "Status = " << status;
|
||||
@@ -186,12 +185,12 @@ Java_edu_wpi_first_wpilibj_hal_InterruptJNI_waitForInterrupt(
|
||||
*/
|
||||
JNIEXPORT void JNICALL
|
||||
Java_edu_wpi_first_wpilibj_hal_InterruptJNI_enableInterrupts(
|
||||
JNIEnv* env, jclass, jlong interrupt_pointer) {
|
||||
JNIEnv* env, jclass, jint interrupt_handle) {
|
||||
INTERRUPTJNI_LOG(logDEBUG) << "Calling INTERRUPTJNI enableInterrupts";
|
||||
INTERRUPTJNI_LOG(logDEBUG) << "Interrupt Ptr = " << (void*)interrupt_pointer;
|
||||
INTERRUPTJNI_LOG(logDEBUG) << "Interrupt Handle = " << (HalInterruptHandle)interrupt_handle;
|
||||
|
||||
int32_t status = 0;
|
||||
enableInterrupts((void*)interrupt_pointer, &status);
|
||||
enableInterrupts((HalInterruptHandle)interrupt_handle, &status);
|
||||
|
||||
INTERRUPTJNI_LOG(logDEBUG) << "Status = " << status;
|
||||
|
||||
@@ -205,12 +204,12 @@ Java_edu_wpi_first_wpilibj_hal_InterruptJNI_enableInterrupts(
|
||||
*/
|
||||
JNIEXPORT void JNICALL
|
||||
Java_edu_wpi_first_wpilibj_hal_InterruptJNI_disableInterrupts(
|
||||
JNIEnv* env, jclass, jlong interrupt_pointer) {
|
||||
JNIEnv* env, jclass, jint interrupt_handle) {
|
||||
INTERRUPTJNI_LOG(logDEBUG) << "Calling INTERRUPTJNI disableInterrupts";
|
||||
INTERRUPTJNI_LOG(logDEBUG) << "Interrupt Ptr = " << (void*)interrupt_pointer;
|
||||
INTERRUPTJNI_LOG(logDEBUG) << "Interrupt Handle = " << (HalInterruptHandle)interrupt_handle;
|
||||
|
||||
int32_t status = 0;
|
||||
disableInterrupts((void*)interrupt_pointer, &status);
|
||||
disableInterrupts((HalInterruptHandle)interrupt_handle, &status);
|
||||
|
||||
INTERRUPTJNI_LOG(logDEBUG) << "Status = " << status;
|
||||
|
||||
@@ -224,12 +223,12 @@ Java_edu_wpi_first_wpilibj_hal_InterruptJNI_disableInterrupts(
|
||||
*/
|
||||
JNIEXPORT jdouble JNICALL
|
||||
Java_edu_wpi_first_wpilibj_hal_InterruptJNI_readRisingTimestamp(
|
||||
JNIEnv* env, jclass, jlong interrupt_pointer) {
|
||||
JNIEnv* env, jclass, jint interrupt_handle) {
|
||||
INTERRUPTJNI_LOG(logDEBUG) << "Calling INTERRUPTJNI readRisingTimestamp";
|
||||
INTERRUPTJNI_LOG(logDEBUG) << "Interrupt Ptr = " << (void*)interrupt_pointer;
|
||||
INTERRUPTJNI_LOG(logDEBUG) << "Interrupt Handle = " << (HalInterruptHandle)interrupt_handle;
|
||||
|
||||
int32_t status = 0;
|
||||
jdouble timeStamp = readRisingTimestamp((void*)interrupt_pointer, &status);
|
||||
jdouble timeStamp = readRisingTimestamp((HalInterruptHandle)interrupt_handle, &status);
|
||||
|
||||
INTERRUPTJNI_LOG(logDEBUG) << "Status = " << status;
|
||||
CheckStatus(env, status);
|
||||
@@ -243,12 +242,12 @@ Java_edu_wpi_first_wpilibj_hal_InterruptJNI_readRisingTimestamp(
|
||||
*/
|
||||
JNIEXPORT jdouble JNICALL
|
||||
Java_edu_wpi_first_wpilibj_hal_InterruptJNI_readFallingTimestamp(
|
||||
JNIEnv* env, jclass, jlong interrupt_pointer) {
|
||||
JNIEnv* env, jclass, jint interrupt_handle) {
|
||||
INTERRUPTJNI_LOG(logDEBUG) << "Calling INTERRUPTJNI readFallingTimestamp";
|
||||
INTERRUPTJNI_LOG(logDEBUG) << "Interrupt Ptr = " << (void*)interrupt_pointer;
|
||||
INTERRUPTJNI_LOG(logDEBUG) << "Interrupt Handle = " << (HalInterruptHandle)interrupt_handle;
|
||||
|
||||
int32_t status = 0;
|
||||
jdouble timeStamp = readFallingTimestamp((void*)interrupt_pointer, &status);
|
||||
jdouble timeStamp = readFallingTimestamp((HalInterruptHandle)interrupt_handle, &status);
|
||||
|
||||
INTERRUPTJNI_LOG(logDEBUG) << "Status = " << status;
|
||||
CheckStatus(env, status);
|
||||
@@ -262,17 +261,17 @@ Java_edu_wpi_first_wpilibj_hal_InterruptJNI_readFallingTimestamp(
|
||||
*/
|
||||
JNIEXPORT void JNICALL
|
||||
Java_edu_wpi_first_wpilibj_hal_InterruptJNI_requestInterrupts(
|
||||
JNIEnv* env, jclass, jlong interrupt_pointer, jbyte routing_module,
|
||||
JNIEnv* env, jclass, jint interrupt_handle, jbyte routing_module,
|
||||
jint routing_pin, jboolean routing_analog_trigger) {
|
||||
INTERRUPTJNI_LOG(logDEBUG) << "Calling INTERRUPTJNI requestInterrupts";
|
||||
INTERRUPTJNI_LOG(logDEBUG) << "Interrupt Ptr = " << (void*)interrupt_pointer;
|
||||
INTERRUPTJNI_LOG(logDEBUG) << "Interrupt Handle = " << (HalInterruptHandle)interrupt_handle;
|
||||
INTERRUPTJNI_LOG(logDEBUG) << "routing module = " << (jint)routing_module;
|
||||
INTERRUPTJNI_LOG(logDEBUG) << "routing pin = " << routing_pin;
|
||||
INTERRUPTJNI_LOG(logDEBUG) << "routing analog trigger = "
|
||||
<< (jint)routing_analog_trigger;
|
||||
|
||||
int32_t status = 0;
|
||||
requestInterrupts((void*)interrupt_pointer, (uint8_t)routing_module,
|
||||
requestInterrupts((HalInterruptHandle)interrupt_handle, (uint8_t)routing_module,
|
||||
(uint32_t)routing_pin, routing_analog_trigger, &status);
|
||||
|
||||
INTERRUPTJNI_LOG(logDEBUG) << "Status = " << status;
|
||||
@@ -287,10 +286,10 @@ Java_edu_wpi_first_wpilibj_hal_InterruptJNI_requestInterrupts(
|
||||
*/
|
||||
JNIEXPORT void JNICALL
|
||||
Java_edu_wpi_first_wpilibj_hal_InterruptJNI_attachInterruptHandler(
|
||||
JNIEnv* env, jclass, jlong interrupt_pointer, jobject handler,
|
||||
JNIEnv* env, jclass, jint interrupt_handle, jobject handler,
|
||||
jobject param) {
|
||||
INTERRUPTJNI_LOG(logDEBUG) << "Calling INTERRUPTJNI attachInterruptHandler";
|
||||
INTERRUPTJNI_LOG(logDEBUG) << "Interrupt Ptr = " << (void*)interrupt_pointer;
|
||||
INTERRUPTJNI_LOG(logDEBUG) << "Interrupt Handle = " << (HalInterruptHandle)interrupt_handle;
|
||||
|
||||
jclass cls = env->GetObjectClass(handler);
|
||||
INTERRUPTJNI_LOG(logDEBUG) << "class = " << cls;
|
||||
@@ -314,7 +313,7 @@ Java_edu_wpi_first_wpilibj_hal_InterruptJNI_attachInterruptHandler(
|
||||
INTERRUPTJNI_LOG(logDEBUG) << "InterruptThreadJNI Ptr = " << intr;
|
||||
|
||||
int32_t status = 0;
|
||||
attachInterruptHandler((void*)interrupt_pointer, interruptHandler, intr,
|
||||
attachInterruptHandler((HalInterruptHandle)interrupt_handle, interruptHandler, intr,
|
||||
&status);
|
||||
|
||||
INTERRUPTJNI_LOG(logDEBUG) << "Status = " << status;
|
||||
@@ -328,15 +327,15 @@ Java_edu_wpi_first_wpilibj_hal_InterruptJNI_attachInterruptHandler(
|
||||
*/
|
||||
JNIEXPORT void JNICALL
|
||||
Java_edu_wpi_first_wpilibj_hal_InterruptJNI_setInterruptUpSourceEdge(
|
||||
JNIEnv* env, jclass, jlong interrupt_pointer, jboolean risingEdge,
|
||||
JNIEnv* env, jclass, jint interrupt_handle, jboolean risingEdge,
|
||||
jboolean fallingEdge) {
|
||||
INTERRUPTJNI_LOG(logDEBUG) << "Calling INTERRUPTJNI setInterruptUpSourceEdge";
|
||||
INTERRUPTJNI_LOG(logDEBUG) << "Interrupt Ptr = " << (void*)interrupt_pointer;
|
||||
INTERRUPTJNI_LOG(logDEBUG) << "Interrupt Handle = " << (HalInterruptHandle)interrupt_handle;
|
||||
INTERRUPTJNI_LOG(logDEBUG) << "Rising Edge = " << (bool)risingEdge;
|
||||
INTERRUPTJNI_LOG(logDEBUG) << "Falling Edge = " << (bool)fallingEdge;
|
||||
|
||||
int32_t status = 0;
|
||||
setInterruptUpSourceEdge((void*)interrupt_pointer, risingEdge, fallingEdge,
|
||||
setInterruptUpSourceEdge((HalInterruptHandle)interrupt_handle, risingEdge, fallingEdge,
|
||||
&status);
|
||||
|
||||
INTERRUPTJNI_LOG(logDEBUG) << "Status = " << status;
|
||||
|
||||
Reference in New Issue
Block a user