mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-07-03 03:01:44 +00:00
Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f5a292dadd |
@@ -198,6 +198,23 @@ void HAL_SetDIO(HAL_DigitalHandle dioPortHandle, HAL_Bool value,
|
|||||||
SimDIOData[port->channel].SetValue(value);
|
SimDIOData[port->channel].SetValue(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set direction of a DIO channel.
|
||||||
|
*
|
||||||
|
* @param channel The Digital I/O channel
|
||||||
|
* @param input true to set input, false for output
|
||||||
|
*/
|
||||||
|
void HAL_SetDIODirection(HAL_DigitalHandle dioPortHandle, HAL_Bool input,
|
||||||
|
int32_t* status) {
|
||||||
|
auto port = digitalChannelHandles->Get(dioPortHandle, HAL_HandleEnum::DIO);
|
||||||
|
if (port == nullptr) {
|
||||||
|
*status = HAL_HANDLE_ERROR;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
SimDIOData[port->channel].SetIsInput(input);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Read a digital I/O bit from the FPGA.
|
* Read a digital I/O bit from the FPGA.
|
||||||
* Get a single value from a digital I/O channel.
|
* Get a single value from a digital I/O channel.
|
||||||
|
|||||||
@@ -15,8 +15,11 @@ public class DIOJNI extends JNIWrapper {
|
|||||||
|
|
||||||
public static native void freeDIOPort(int dioPortHandle);
|
public static native void freeDIOPort(int dioPortHandle);
|
||||||
|
|
||||||
|
// TODO(Thad): Switch this to use boolean
|
||||||
public static native void setDIO(int dioPortHandle, short value);
|
public static native void setDIO(int dioPortHandle, short value);
|
||||||
|
|
||||||
|
public static native void setDIODirection(int dioPortHandle, boolean input);
|
||||||
|
|
||||||
public static native boolean getDIO(int dioPortHandle);
|
public static native boolean getDIO(int dioPortHandle);
|
||||||
|
|
||||||
public static native boolean getDIODirection(int dioPortHandle);
|
public static native boolean getDIODirection(int dioPortHandle);
|
||||||
|
|||||||
@@ -90,6 +90,22 @@ JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_DIOJNI_setDIO(
|
|||||||
CheckStatus(env, status);
|
CheckStatus(env, status);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Class: edu_wpi_first_wpilibj_hal_DIOJNI
|
||||||
|
* Method: setDIODirection
|
||||||
|
* Signature: (IZ)V
|
||||||
|
*/
|
||||||
|
JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_DIOJNI_setDIODirection(
|
||||||
|
JNIEnv *env, jclass, jint id, jboolean input) {
|
||||||
|
// DIOJNI_LOG(logDEBUG) << "Calling DIOJNI setDIO";
|
||||||
|
// DIOJNI_LOG(logDEBUG) << "Port Handle = " << (HAL_DigitalHandle)id;
|
||||||
|
// DIOJNI_LOG(logDEBUG) << "IsInput = " << input;
|
||||||
|
int32_t status = 0;
|
||||||
|
HAL_SetDIODirection((HAL_DigitalHandle)id, input, &status);
|
||||||
|
// DIOJNI_LOG(logDEBUG) << "Status = " << status;
|
||||||
|
CheckStatus(env, status);
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Class: edu_wpi_first_wpilibj_hal_DIOJNI
|
* Class: edu_wpi_first_wpilibj_hal_DIOJNI
|
||||||
* Method: getDIO
|
* Method: getDIO
|
||||||
|
|||||||
Reference in New Issue
Block a user