mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-19 00:41:43 +00:00
[hal] Remove HAL_GetPort (#7754)
This commit is contained in:
@@ -49,18 +49,6 @@ void HandleBase::ResetGlobalHandles() {
|
||||
}
|
||||
}
|
||||
}
|
||||
HAL_PortHandle createPortHandle(uint8_t channel, uint8_t module) {
|
||||
// set last 8 bits, then shift to first 8 bits
|
||||
HAL_PortHandle handle = static_cast<HAL_PortHandle>(HAL_HandleEnum::Port);
|
||||
handle = handle << 24;
|
||||
// shift module and add to 3rd set of 8 bits
|
||||
int32_t temp = module;
|
||||
temp = (temp << 8) & 0xff00;
|
||||
handle += temp;
|
||||
// add channel to last 8 bits
|
||||
handle += channel;
|
||||
return handle;
|
||||
}
|
||||
HAL_Handle createHandle(int16_t index, HAL_HandleEnum handleType,
|
||||
int16_t version) {
|
||||
if (index < 0) {
|
||||
|
||||
@@ -25,12 +25,11 @@ extern "C" {
|
||||
*/
|
||||
JNIEXPORT jint JNICALL
|
||||
Java_edu_wpi_first_hal_AnalogJNI_initializeAnalogInputPort
|
||||
(JNIEnv* env, jclass, jint id)
|
||||
(JNIEnv* env, jclass, jint channel)
|
||||
{
|
||||
int32_t status = 0;
|
||||
auto stack = wpi::java::GetJavaStackTrace(env, "edu.wpi.first");
|
||||
auto analog =
|
||||
HAL_InitializeAnalogInputPort((HAL_PortHandle)id, stack.c_str(), &status);
|
||||
auto analog = HAL_InitializeAnalogInputPort(channel, stack.c_str(), &status);
|
||||
CheckStatusForceThrow(env, status);
|
||||
return (jint)analog;
|
||||
}
|
||||
|
||||
@@ -26,12 +26,12 @@ extern "C" {
|
||||
*/
|
||||
JNIEXPORT jint JNICALL
|
||||
Java_edu_wpi_first_hal_DIOJNI_initializeDIOPort
|
||||
(JNIEnv* env, jclass, jint id, jboolean input)
|
||||
(JNIEnv* env, jclass, jint channel, jboolean input)
|
||||
{
|
||||
int32_t status = 0;
|
||||
auto stack = wpi::java::GetJavaStackTrace(env, "edu.wpi.first");
|
||||
auto dio = HAL_InitializeDIOPort(
|
||||
(HAL_PortHandle)id, static_cast<uint8_t>(input), stack.c_str(), &status);
|
||||
auto dio = HAL_InitializeDIOPort(channel, static_cast<uint8_t>(input),
|
||||
stack.c_str(), &status);
|
||||
CheckStatusForceThrow(env, status);
|
||||
return (jint)dio;
|
||||
}
|
||||
|
||||
@@ -20,12 +20,11 @@ extern "C" {
|
||||
*/
|
||||
JNIEXPORT jint JNICALL
|
||||
Java_edu_wpi_first_hal_DutyCycleJNI_initialize
|
||||
(JNIEnv* env, jclass, jint portHandle)
|
||||
(JNIEnv* env, jclass, jint channel)
|
||||
{
|
||||
int32_t status = 0;
|
||||
auto stack = wpi::java::GetJavaStackTrace(env, "edu.wpi.first");
|
||||
auto handle = HAL_InitializeDutyCycle(static_cast<HAL_Handle>(portHandle),
|
||||
stack.c_str(), &status);
|
||||
auto handle = HAL_InitializeDutyCycle(channel, stack.c_str(), &status);
|
||||
CheckStatus(env, status);
|
||||
return handle;
|
||||
}
|
||||
|
||||
@@ -199,30 +199,4 @@ Java_edu_wpi_first_hal_HAL_getSystemTimeValid
|
||||
return val;
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_HAL
|
||||
* Method: getPortWithModule
|
||||
* Signature: (BB)I
|
||||
*/
|
||||
JNIEXPORT jint JNICALL
|
||||
Java_edu_wpi_first_hal_HAL_getPortWithModule
|
||||
(JNIEnv* env, jclass, jbyte module, jbyte channel)
|
||||
{
|
||||
HAL_PortHandle port = HAL_GetPortWithModule(module, channel);
|
||||
return (jint)port;
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_HAL
|
||||
* Method: getPort
|
||||
* Signature: (B)I
|
||||
*/
|
||||
JNIEXPORT jint JNICALL
|
||||
Java_edu_wpi_first_hal_HAL_getPort
|
||||
(JNIEnv* env, jclass, jbyte channel)
|
||||
{
|
||||
HAL_PortHandle port = HAL_GetPort(channel);
|
||||
return (jint)port;
|
||||
}
|
||||
|
||||
} // extern "C"
|
||||
|
||||
@@ -26,11 +26,11 @@ extern "C" {
|
||||
*/
|
||||
JNIEXPORT jint JNICALL
|
||||
Java_edu_wpi_first_hal_PWMJNI_initializePWMPort
|
||||
(JNIEnv* env, jclass, jint id)
|
||||
(JNIEnv* env, jclass, jint channel)
|
||||
{
|
||||
int32_t status = 0;
|
||||
auto stack = wpi::java::GetJavaStackTrace(env, "edu.wpi.first");
|
||||
auto pwm = HAL_InitializePWMPort((HAL_PortHandle)id, stack.c_str(), &status);
|
||||
auto pwm = HAL_InitializePWMPort(channel, stack.c_str(), &status);
|
||||
CheckStatusForceThrow(env, status);
|
||||
return (jint)pwm;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user