mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-20 00:51:42 +00:00
[hal] [wpilib] Add initial support for the REV PDH (#3503)
This commit is contained in:
@@ -197,11 +197,11 @@ Java_edu_wpi_first_hal_PortsJNI_getNumRelayHeaders
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_PortsJNI
|
||||
* Method: getNumPCMModules
|
||||
* Method: getNumCTREPCMModules
|
||||
* Signature: ()I
|
||||
*/
|
||||
JNIEXPORT jint JNICALL
|
||||
Java_edu_wpi_first_hal_PortsJNI_getNumPCMModules
|
||||
Java_edu_wpi_first_hal_PortsJNI_getNumCTREPCMModules
|
||||
(JNIEnv* env, jclass)
|
||||
{
|
||||
jint value = HAL_GetNumCTREPCMModules();
|
||||
@@ -210,40 +210,66 @@ Java_edu_wpi_first_hal_PortsJNI_getNumPCMModules
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_PortsJNI
|
||||
* Method: getNumSolenoidChannels
|
||||
* Method: getNumCTRESolenoidChannels
|
||||
* Signature: ()I
|
||||
*/
|
||||
JNIEXPORT jint JNICALL
|
||||
Java_edu_wpi_first_hal_PortsJNI_getNumSolenoidChannels
|
||||
Java_edu_wpi_first_hal_PortsJNI_getNumCTRESolenoidChannels
|
||||
(JNIEnv* env, jclass)
|
||||
{
|
||||
jint value = HAL_GetNumSolenoidChannels();
|
||||
jint value = HAL_GetNumCTRESolenoidChannels();
|
||||
return value;
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_PortsJNI
|
||||
* Method: getNumPDPModules
|
||||
* Method: getNumCTREPDPModules
|
||||
* Signature: ()I
|
||||
*/
|
||||
JNIEXPORT jint JNICALL
|
||||
Java_edu_wpi_first_hal_PortsJNI_getNumPDPModules
|
||||
Java_edu_wpi_first_hal_PortsJNI_getNumCTREPDPModules
|
||||
(JNIEnv* env, jclass)
|
||||
{
|
||||
jint value = HAL_GetNumPDPModules();
|
||||
jint value = HAL_GetNumCTREPDPModules();
|
||||
return value;
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_PortsJNI
|
||||
* Method: getNumPDPChannels
|
||||
* Method: getNumCTREPDPChannels
|
||||
* Signature: ()I
|
||||
*/
|
||||
JNIEXPORT jint JNICALL
|
||||
Java_edu_wpi_first_hal_PortsJNI_getNumPDPChannels
|
||||
Java_edu_wpi_first_hal_PortsJNI_getNumCTREPDPChannels
|
||||
(JNIEnv* env, jclass)
|
||||
{
|
||||
jint value = HAL_GetNumPDPChannels();
|
||||
jint value = HAL_GetNumCTREPDPChannels();
|
||||
return value;
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_PortsJNI
|
||||
* Method: getNumREVPDHModules
|
||||
* Signature: ()I
|
||||
*/
|
||||
JNIEXPORT jint JNICALL
|
||||
Java_edu_wpi_first_hal_PortsJNI_getNumREVPDHModules
|
||||
(JNIEnv* env, jclass)
|
||||
{
|
||||
jint value = HAL_GetNumREVPDHModules();
|
||||
return value;
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_PortsJNI
|
||||
* Method: getNumREVPDHChannels
|
||||
* Signature: ()I
|
||||
*/
|
||||
JNIEXPORT jint JNICALL
|
||||
Java_edu_wpi_first_hal_PortsJNI_getNumREVPDHChannels
|
||||
(JNIEnv* env, jclass)
|
||||
{
|
||||
jint value = HAL_GetNumREVPDHChannels();
|
||||
return value;
|
||||
}
|
||||
} // extern "C"
|
||||
|
||||
@@ -2,6 +2,10 @@
|
||||
// Open Source Software; you can modify and/or share it under the terms of
|
||||
// the WPILib BSD license file in the root directory of this project.
|
||||
|
||||
#include <jni.h>
|
||||
|
||||
#include <wpi/jni_util.h>
|
||||
|
||||
#include "HALUtil.h"
|
||||
#include "edu_wpi_first_hal_PowerDistributionJNI.h"
|
||||
#include "hal/Ports.h"
|
||||
@@ -9,6 +13,15 @@
|
||||
|
||||
using namespace hal;
|
||||
|
||||
static_assert(edu_wpi_first_hal_PowerDistributionJNI_AUTOMATIC_TYPE ==
|
||||
HAL_PowerDistributionType::HAL_PowerDistributionType_kAutomatic);
|
||||
static_assert(edu_wpi_first_hal_PowerDistributionJNI_CTRE_TYPE ==
|
||||
HAL_PowerDistributionType::HAL_PowerDistributionType_kCTRE);
|
||||
static_assert(edu_wpi_first_hal_PowerDistributionJNI_REV_TYPE ==
|
||||
HAL_PowerDistributionType::HAL_PowerDistributionType_kRev);
|
||||
static_assert(edu_wpi_first_hal_PowerDistributionJNI_DEFAULT_MODULE ==
|
||||
HAL_DEFAULT_POWER_DISTRIBUTION_MODULE);
|
||||
|
||||
extern "C" {
|
||||
|
||||
/*
|
||||
@@ -21,12 +34,41 @@ Java_edu_wpi_first_hal_PowerDistributionJNI_initialize
|
||||
(JNIEnv* env, jclass, jint module, jint type)
|
||||
{
|
||||
int32_t status = 0;
|
||||
auto stack = wpi::java::GetJavaStackTrace(env, "edu.wpi.first");
|
||||
auto handle = HAL_InitializePowerDistribution(
|
||||
module, static_cast<HAL_PowerDistributionType>(type), &status);
|
||||
module, static_cast<HAL_PowerDistributionType>(type), stack.c_str(),
|
||||
&status);
|
||||
CheckStatusForceThrow(env, status);
|
||||
return static_cast<jint>(handle);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_PowerDistributionJNI
|
||||
* Method: free
|
||||
* Signature: (I)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL
|
||||
Java_edu_wpi_first_hal_PowerDistributionJNI_free
|
||||
(JNIEnv*, jclass, jint handle)
|
||||
{
|
||||
HAL_CleanPowerDistribution(handle);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_PowerDistributionJNI
|
||||
* Method: getModuleNumber
|
||||
* Signature: (I)I
|
||||
*/
|
||||
JNIEXPORT jint JNICALL
|
||||
Java_edu_wpi_first_hal_PowerDistributionJNI_getModuleNumber
|
||||
(JNIEnv* env, jclass, jint handle)
|
||||
{
|
||||
int32_t status = 0;
|
||||
auto result = HAL_GetPowerDistributionModuleNumber(handle, &status);
|
||||
CheckStatus(env, status, false);
|
||||
return result;
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_PowerDistributionJNI
|
||||
* Method: checkChannel
|
||||
@@ -67,6 +109,21 @@ Java_edu_wpi_first_hal_PowerDistributionJNI_getType
|
||||
return result;
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_PowerDistributionJNI
|
||||
* Method: getNumChannels
|
||||
* Signature: (I)I
|
||||
*/
|
||||
JNIEXPORT jint JNICALL
|
||||
Java_edu_wpi_first_hal_PowerDistributionJNI_getNumChannels
|
||||
(JNIEnv* env, jclass, jint handle)
|
||||
{
|
||||
int32_t status = 0;
|
||||
auto result = HAL_GetPowerDistributionNumChannels(handle, &status);
|
||||
CheckStatus(env, status);
|
||||
return result;
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_PowerDistributionJNI
|
||||
* Method: getTemperature
|
||||
@@ -100,11 +157,11 @@ Java_edu_wpi_first_hal_PowerDistributionJNI_getVoltage
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_PowerDistributionJNI
|
||||
* Method: getChannelCurrent
|
||||
* Signature: (BI)D
|
||||
* Signature: (II)D
|
||||
*/
|
||||
JNIEXPORT jdouble JNICALL
|
||||
Java_edu_wpi_first_hal_PowerDistributionJNI_getChannelCurrent
|
||||
(JNIEnv* env, jclass, jbyte channel, jint handle)
|
||||
(JNIEnv* env, jclass, jint handle, jint channel)
|
||||
{
|
||||
int32_t status = 0;
|
||||
double current =
|
||||
@@ -206,4 +263,33 @@ Java_edu_wpi_first_hal_PowerDistributionJNI_clearStickyFaults
|
||||
CheckStatus(env, status, false);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_PowerDistributionJNI
|
||||
* Method: setSwitchableChannel
|
||||
* Signature: (IZ)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL
|
||||
Java_edu_wpi_first_hal_PowerDistributionJNI_setSwitchableChannel
|
||||
(JNIEnv* env, jclass, jint handle, jboolean enabled)
|
||||
{
|
||||
int32_t status = 0;
|
||||
HAL_SetPowerDistributionSwitchableChannel(handle, enabled, &status);
|
||||
CheckStatus(env, status, false);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_PowerDistributionJNI
|
||||
* Method: getSwitchableChannel
|
||||
* Signature: (I)Z
|
||||
*/
|
||||
JNIEXPORT jboolean JNICALL
|
||||
Java_edu_wpi_first_hal_PowerDistributionJNI_getSwitchableChannel
|
||||
(JNIEnv* env, jclass, jint handle)
|
||||
{
|
||||
int32_t status = 0;
|
||||
auto state = HAL_GetPowerDistributionSwitchableChannel(handle, &status);
|
||||
CheckStatus(env, status, false);
|
||||
return state;
|
||||
}
|
||||
|
||||
} // extern "C"
|
||||
|
||||
Reference in New Issue
Block a user