[hal] Remove HAL_GetPort (#7754)

This commit is contained in:
Thad House
2025-01-30 18:59:34 -08:00
committed by GitHub
parent 6e704370b3
commit ad29d45dfb
44 changed files with 84 additions and 272 deletions

View File

@@ -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) {

View File

@@ -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;
}

View File

@@ -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;
}

View File

@@ -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;
}

View File

@@ -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"

View File

@@ -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;
}