From ddd64aa70c407f10aa131a51df021f9722d5e39d Mon Sep 17 00:00:00 2001 From: Ryan Blue Date: Thu, 1 Aug 2024 19:45:20 -0400 Subject: [PATCH] [docs] Add documentation for various HAL/wpilib items (NFC) (#6898) --- .../java/edu/wpi/first/hal/CANAPITypes.java | 2 + .../main/java/edu/wpi/first/hal/CANData.java | 1 + .../edu/wpi/first/hal/CANStreamMessage.java | 5 ++ .../java/edu/wpi/first/hal/ControlWord.java | 30 ++++++++ .../java/edu/wpi/first/hal/CounterJNI.java | 7 ++ .../main/java/edu/wpi/first/hal/DIOJNI.java | 5 ++ .../edu/wpi/first/hal/DriverStationJNI.java | 28 +++++++ hal/src/main/java/edu/wpi/first/hal/HAL.java | 2 + .../main/java/edu/wpi/first/hal/HALUtil.java | 20 +++++ .../main/java/edu/wpi/first/hal/HALValue.java | 17 +++++ .../java/edu/wpi/first/hal/InterruptJNI.java | 1 + .../java/edu/wpi/first/hal/JNIWrapper.java | 5 ++ .../main/java/edu/wpi/first/hal/LEDJNI.java | 12 +++ .../main/java/edu/wpi/first/hal/PWMJNI.java | 5 ++ .../first/hal/PowerDistributionFaults.java | 31 ++++++++ .../wpi/first/hal/PowerDistributionJNI.java | 7 ++ .../hal/PowerDistributionStickyFaults.java | 32 ++++++++ .../java/edu/wpi/first/hal/REVPHFaults.java | 23 ++++++ .../main/java/edu/wpi/first/hal/REVPHJNI.java | 7 ++ .../edu/wpi/first/hal/REVPHStickyFaults.java | 8 ++ .../java/edu/wpi/first/hal/REVPHVersion.java | 7 ++ .../main/java/edu/wpi/first/hal/SPIJNI.java | 18 +++++ .../java/edu/wpi/first/hal/SimDevice.java | 1 + .../java/edu/wpi/first/hal/SimDeviceJNI.java | 10 +++ .../main/java/edu/wpi/first/hal/SimValue.java | 1 + hal/src/main/native/include/hal/Counter.h | 4 + .../main/native/include/hal/DriverStation.h | 11 +++ .../native/include/hal/DriverStationTypes.h | 22 +++++- hal/src/main/native/include/hal/HALBase.h | 6 ++ hal/src/main/native/include/hal/PWM.h | 2 +- .../native/include/hal/PowerDistribution.h | 63 ++++++++++++++++ hal/src/main/native/include/hal/REVPH.h | 39 ++++++++++ hal/src/main/native/include/hal/SPITypes.h | 12 +++ hal/src/main/native/include/hal/Value.h | 37 +++++++++- .../main/native/include/frc/PneumaticHub.h | 44 +++++++++++ .../native/include/frc/PowerDistribution.h | 74 +++++++++++++++++++ .../wpi/first/wpilibj/PowerDistribution.java | 6 +- 37 files changed, 599 insertions(+), 6 deletions(-) diff --git a/hal/src/main/java/edu/wpi/first/hal/CANAPITypes.java b/hal/src/main/java/edu/wpi/first/hal/CANAPITypes.java index 5a8a3e6f86..2d8e0dd6f5 100644 --- a/hal/src/main/java/edu/wpi/first/hal/CANAPITypes.java +++ b/hal/src/main/java/edu/wpi/first/hal/CANAPITypes.java @@ -50,6 +50,7 @@ public final class CANAPITypes { /** Firmware update. */ kFirmwareUpdate(31); + /** The device type ID. */ @SuppressWarnings("PMD.MemberName") public final int id; @@ -104,6 +105,7 @@ public final class CANAPITypes { /** Vivid-Hosting. */ kVividHosting(16); + /** The manufacturer ID. */ @SuppressWarnings("PMD.MemberName") public final int id; diff --git a/hal/src/main/java/edu/wpi/first/hal/CANData.java b/hal/src/main/java/edu/wpi/first/hal/CANData.java index ffd2f3919f..f91e4163bd 100644 --- a/hal/src/main/java/edu/wpi/first/hal/CANData.java +++ b/hal/src/main/java/edu/wpi/first/hal/CANData.java @@ -4,6 +4,7 @@ package edu.wpi.first.hal; +/** Represents a received CAN message. */ @SuppressWarnings("MemberName") public class CANData { /** Contents of the CAN frame. */ diff --git a/hal/src/main/java/edu/wpi/first/hal/CANStreamMessage.java b/hal/src/main/java/edu/wpi/first/hal/CANStreamMessage.java index 5706aa080b..56331efdc8 100644 --- a/hal/src/main/java/edu/wpi/first/hal/CANStreamMessage.java +++ b/hal/src/main/java/edu/wpi/first/hal/CANStreamMessage.java @@ -4,16 +4,21 @@ package edu.wpi.first.hal; +/** Represents a CAN message read from a stream. */ public class CANStreamMessage { + /** The message data. */ @SuppressWarnings("MemberName") public final byte[] data = new byte[8]; + /** The length of the data received (0-8 bytes). */ @SuppressWarnings("MemberName") public int length; + /** Timestamp message was received, in milliseconds (based off of CLOCK_MONOTONIC). */ @SuppressWarnings("MemberName") public long timestamp; + /** The message ID. */ @SuppressWarnings("MemberName") public int messageID; diff --git a/hal/src/main/java/edu/wpi/first/hal/ControlWord.java b/hal/src/main/java/edu/wpi/first/hal/ControlWord.java index 31f8a7d006..d19c68b2b1 100644 --- a/hal/src/main/java/edu/wpi/first/hal/ControlWord.java +++ b/hal/src/main/java/edu/wpi/first/hal/ControlWord.java @@ -45,26 +45,56 @@ public class ControlWord { m_dsAttached = word.m_dsAttached; } + /** + * Gets the Enabled flag. + * + * @return the Enabled flag + */ public boolean getEnabled() { return m_enabled; } + /** + * Gets the Autonomous mode flag. + * + * @return the Autonomous mode flag + */ public boolean getAutonomous() { return m_autonomous; } + /** + * Gets the Test mode flag. + * + * @return the Test mode flag + */ public boolean getTest() { return m_test; } + /** + * Gets the E-Stop flag. + * + * @return the E-Stop flag + */ public boolean getEStop() { return m_emergencyStop; } + /** + * Gets the FMS attached flag. + * + * @return the FMS attached flag + */ public boolean getFMSAttached() { return m_fmsAttached; } + /** + * Gets the DS attached flag. + * + * @return the DS attached flag + */ public boolean getDSAttached() { return m_dsAttached; } diff --git a/hal/src/main/java/edu/wpi/first/hal/CounterJNI.java b/hal/src/main/java/edu/wpi/first/hal/CounterJNI.java index 6823185137..4f1e56b815 100644 --- a/hal/src/main/java/edu/wpi/first/hal/CounterJNI.java +++ b/hal/src/main/java/edu/wpi/first/hal/CounterJNI.java @@ -12,9 +12,16 @@ import java.nio.IntBuffer; * @see "hal/Counter.h" */ public class CounterJNI extends JNIWrapper { + /** Two pulse mode. */ public static final int TWO_PULSE = 0; + + /** Semi-period mode. */ public static final int SEMI_PERIOD = 1; + + /** Pulse length mode. */ public static final int PULSE_LENGTH = 2; + + /** External direction mode. */ public static final int EXTERNAL_DIRECTION = 3; /** diff --git a/hal/src/main/java/edu/wpi/first/hal/DIOJNI.java b/hal/src/main/java/edu/wpi/first/hal/DIOJNI.java index 4d597cccdd..ad75e3956f 100644 --- a/hal/src/main/java/edu/wpi/first/hal/DIOJNI.java +++ b/hal/src/main/java/edu/wpi/first/hal/DIOJNI.java @@ -123,6 +123,11 @@ public class DIOJNI extends JNIWrapper { */ public static native boolean isAnyPulsing(); + /** + * Gets the loop timing of the PWM system. + * + * @return the loop time in clock ticks + */ public static native short getLoopTiming(); /** diff --git a/hal/src/main/java/edu/wpi/first/hal/DriverStationJNI.java b/hal/src/main/java/edu/wpi/first/hal/DriverStationJNI.java index 55e0628cf8..33cbac62fc 100644 --- a/hal/src/main/java/edu/wpi/first/hal/DriverStationJNI.java +++ b/hal/src/main/java/edu/wpi/first/hal/DriverStationJNI.java @@ -147,12 +147,25 @@ public class DriverStationJNI extends JNIWrapper { */ private static native int nativeGetAllianceStation(); + /** Unknown Alliance Station ID. */ public static final int kUnknownAllianceStation = 0; + + /** Red Alliance Station 1 ID. */ public static final int kRed1AllianceStation = 1; + + /** Red Alliance Station 2 ID. */ public static final int kRed2AllianceStation = 2; + + /** Red Alliance Station 3 ID. */ public static final int kRed3AllianceStation = 3; + + /** Blue Alliance Station 1 ID. */ public static final int kBlue1AllianceStation = 4; + + /** Blue Alliance Station 2 ID. */ public static final int kBlue2AllianceStation = 5; + + /** Blue Alliance Station 3 ID. */ public static final int kBlue3AllianceStation = 6; /** @@ -174,8 +187,13 @@ public class DriverStationJNI extends JNIWrapper { }; } + /** The maximum number of axes. */ public static final int kMaxJoystickAxes = 12; + + /** The maximum number of POVs. */ public static final int kMaxJoystickPOVs = 12; + + /** The maximum number of joysticks. */ public static final int kMaxJoysticks = 6; /** @@ -353,8 +371,18 @@ public class DriverStationJNI extends JNIWrapper { */ public static native boolean refreshDSData(); + /** + * Adds an event handle to be signalled when new data arrives. + * + * @param handle the event handle to be signalled + */ public static native void provideNewDataEventHandle(int handle); + /** + * Removes the event handle from being signalled when new data arrives. + * + * @param handle the event handle to remove + */ public static native void removeNewDataEventHandle(int handle); /** diff --git a/hal/src/main/java/edu/wpi/first/hal/HAL.java b/hal/src/main/java/edu/wpi/first/hal/HAL.java index 88a799e431..7fa3fef2b3 100644 --- a/hal/src/main/java/edu/wpi/first/hal/HAL.java +++ b/hal/src/main/java/edu/wpi/first/hal/HAL.java @@ -82,6 +82,7 @@ public final class HAL extends JNIWrapper { private static final List s_simPeriodicBefore = new ArrayList<>(); + /** A callback to be run by IterativeRobotBase prior to the user's simulationPeriodic code. */ public static final class SimPeriodicBeforeCallback implements AutoCloseable { private SimPeriodicBeforeCallback(Runnable r) { m_run = r; @@ -128,6 +129,7 @@ public final class HAL extends JNIWrapper { private static final List s_simPeriodicAfter = new ArrayList<>(); + /** A callback to be run by IterativeRobotBase after the user's simulationPeriodic code. */ public static final class SimPeriodicAfterCallback implements AutoCloseable { private SimPeriodicAfterCallback(Runnable r) { m_run = r; diff --git a/hal/src/main/java/edu/wpi/first/hal/HALUtil.java b/hal/src/main/java/edu/wpi/first/hal/HALUtil.java index 0cadf3914c..0ff306f839 100644 --- a/hal/src/main/java/edu/wpi/first/hal/HALUtil.java +++ b/hal/src/main/java/edu/wpi/first/hal/HALUtil.java @@ -10,17 +10,37 @@ package edu.wpi.first.hal; * @see "hal/HALBase.h" */ public final class HALUtil extends JNIWrapper { + /** A pointer parameter to a method is NULL. */ public static final int NULL_PARAMETER = -1005; + + /** Analog module sample rate is too high. */ public static final int SAMPLE_RATE_TOO_HIGH = 1001; + + /** Voltage to convert to raw value is out of range [0; 5]. */ public static final int VOLTAGE_OUT_OF_RANGE = 1002; + + /** Digital module loop timing is not the expected value. */ public static final int LOOP_TIMING_ERROR = 1004; + + /** The operation cannot be completed. */ public static final int INCOMPATIBLE_STATE = 1015; + + /** Attempted to read AnalogTrigger pulse output. */ public static final int ANALOG_TRIGGER_PULSE_OUTPUT_ERROR = -1011; + + /** No available resources to allocate. */ public static final int NO_AVAILABLE_RESOURCES = -104; + + /** A parameter is out of range. */ public static final int PARAMETER_OUT_OF_RANGE = -1028; + /** roboRIO 1.0. */ public static final int RUNTIME_ROBORIO = 0; + + /** roboRIO 2.0. */ public static final int RUNTIME_ROBORIO2 = 1; + + /** Simulation runtime. */ public static final int RUNTIME_SIMULATION = 2; /** diff --git a/hal/src/main/java/edu/wpi/first/hal/HALValue.java b/hal/src/main/java/edu/wpi/first/hal/HALValue.java index 947ffc765c..24099e93b4 100644 --- a/hal/src/main/java/edu/wpi/first/hal/HALValue.java +++ b/hal/src/main/java/edu/wpi/first/hal/HALValue.java @@ -4,12 +4,24 @@ package edu.wpi.first.hal; +/** Represents a HAL entry value. */ public final class HALValue { + /** Unassigned type. */ public static final int kUnassigned = 0; + + /** Boolean. */ public static final int kBoolean = 0x01; + + /** Double. */ public static final int kDouble = 0x02; + + /** Enum. */ public static final int kEnum = 0x04; + + /** Int. */ public static final int kInt = 0x08; + + /** Long. */ public static final int kLong = 0x10; private int m_type; @@ -132,6 +144,11 @@ public final class HALValue { return new HALValue(value, kDouble); } + /** + * Build a HAL unassigned value. + * + * @return HAL value + */ public static HALValue makeUnassigned() { return new HALValue(); } diff --git a/hal/src/main/java/edu/wpi/first/hal/InterruptJNI.java b/hal/src/main/java/edu/wpi/first/hal/InterruptJNI.java index ec60b83923..0ef806e434 100644 --- a/hal/src/main/java/edu/wpi/first/hal/InterruptJNI.java +++ b/hal/src/main/java/edu/wpi/first/hal/InterruptJNI.java @@ -10,6 +10,7 @@ package edu.wpi.first.hal; * @see "hal/Interrupts.h" */ public class InterruptJNI extends JNIWrapper { + /** Invalid handle value. */ public static final int HalInvalidHandle = 0; /** diff --git a/hal/src/main/java/edu/wpi/first/hal/JNIWrapper.java b/hal/src/main/java/edu/wpi/first/hal/JNIWrapper.java index 985d30a5ee..5cc2e12655 100644 --- a/hal/src/main/java/edu/wpi/first/hal/JNIWrapper.java +++ b/hal/src/main/java/edu/wpi/first/hal/JNIWrapper.java @@ -63,6 +63,11 @@ public class JNIWrapper { libraryLoaded = true; } + /** + * Dummy function to suppress unused variable warnings. + * + * @param object variable to suppress + */ public static void suppressUnused(Object object) {} /** Utility class. */ diff --git a/hal/src/main/java/edu/wpi/first/hal/LEDJNI.java b/hal/src/main/java/edu/wpi/first/hal/LEDJNI.java index 397328eac4..64a71de55c 100644 --- a/hal/src/main/java/edu/wpi/first/hal/LEDJNI.java +++ b/hal/src/main/java/edu/wpi/first/hal/LEDJNI.java @@ -4,10 +4,22 @@ package edu.wpi.first.hal; +/** + * LED JNI Functions. + * + * @see "hal/LEDs.h" + */ public class LEDJNI extends JNIWrapper { + /** LED Off state. */ public static final int RADIO_LED_STATE_OFF = 0; + + /** LED Green state. */ public static final int RADIO_LED_STATE_GREEN = 1; + + /** LED Red state. */ public static final int RADIO_LED_STATE_RED = 2; + + /** LED Orange state. */ public static final int RADIO_LED_STATE_ORANGE = 3; /** diff --git a/hal/src/main/java/edu/wpi/first/hal/PWMJNI.java b/hal/src/main/java/edu/wpi/first/hal/PWMJNI.java index 3f0e3d4be6..700b27a2a1 100644 --- a/hal/src/main/java/edu/wpi/first/hal/PWMJNI.java +++ b/hal/src/main/java/edu/wpi/first/hal/PWMJNI.java @@ -4,6 +4,11 @@ package edu.wpi.first.hal; +/** + * PWM JNI Functions. + * + * @see "hal/PWM.h" + */ public class PWMJNI extends DIOJNI { /** * Initializes a PWM port. diff --git a/hal/src/main/java/edu/wpi/first/hal/PowerDistributionFaults.java b/hal/src/main/java/edu/wpi/first/hal/PowerDistributionFaults.java index 44271897fe..052c72b4cd 100644 --- a/hal/src/main/java/edu/wpi/first/hal/PowerDistributionFaults.java +++ b/hal/src/main/java/edu/wpi/first/hal/PowerDistributionFaults.java @@ -4,60 +4,91 @@ package edu.wpi.first.hal; +/** + * Faults for a PowerDistribution device. These faults are only active while the condition is + * active. + */ @SuppressWarnings("MemberName") public class PowerDistributionFaults { + /** Breaker fault on channel 0. */ public final boolean Channel0BreakerFault; + /** Breaker fault on channel 1. */ public final boolean Channel1BreakerFault; + /** Breaker fault on channel 2. */ public final boolean Channel2BreakerFault; + /** Breaker fault on channel 3. */ public final boolean Channel3BreakerFault; + /** Breaker fault on channel 4. */ public final boolean Channel4BreakerFault; + /** Breaker fault on channel 5. */ public final boolean Channel5BreakerFault; + /** Breaker fault on channel 6. */ public final boolean Channel6BreakerFault; + /** Breaker fault on channel 7. */ public final boolean Channel7BreakerFault; + /** Breaker fault on channel 8. */ public final boolean Channel8BreakerFault; + /** Breaker fault on channel 9. */ public final boolean Channel9BreakerFault; + /** Breaker fault on channel 10. */ public final boolean Channel10BreakerFault; + /** Breaker fault on channel 11. */ public final boolean Channel11BreakerFault; + /** Breaker fault on channel 12. */ public final boolean Channel12BreakerFault; + /** Breaker fault on channel 13. */ public final boolean Channel13BreakerFault; + /** Breaker fault on channel 14. */ public final boolean Channel14BreakerFault; + /** Breaker fault on channel 15. */ public final boolean Channel15BreakerFault; + /** Breaker fault on channel 16. */ public final boolean Channel16BreakerFault; + /** Breaker fault on channel 17. */ public final boolean Channel17BreakerFault; + /** Breaker fault on channel 18. */ public final boolean Channel18BreakerFault; + /** Breaker fault on channel 19. */ public final boolean Channel19BreakerFault; + /** Breaker fault on channel 20. */ public final boolean Channel20BreakerFault; + /** Breaker fault on channel 21. */ public final boolean Channel21BreakerFault; + /** Breaker fault on channel 22. */ public final boolean Channel22BreakerFault; + /** Breaker fault on channel 23. */ public final boolean Channel23BreakerFault; + /** The input voltage is below the minimum voltage. */ public final boolean Brownout; + /** A warning was raised by the device's CAN controller. */ public final boolean CanWarning; + /** The hardware on the device has malfunctioned. */ public final boolean HardwareFault; /** diff --git a/hal/src/main/java/edu/wpi/first/hal/PowerDistributionJNI.java b/hal/src/main/java/edu/wpi/first/hal/PowerDistributionJNI.java index f2b096ccf7..2586e3a85b 100644 --- a/hal/src/main/java/edu/wpi/first/hal/PowerDistributionJNI.java +++ b/hal/src/main/java/edu/wpi/first/hal/PowerDistributionJNI.java @@ -10,9 +10,16 @@ package edu.wpi.first.hal; * @see "hal/PowerDistribution.h" */ public class PowerDistributionJNI extends JNIWrapper { + /** Automatically determines the module type. */ public static final int AUTOMATIC_TYPE = 0; + + /** CTRE (Cross The Road Electronics) Power Distribution Panel (PDP). */ public static final int CTRE_TYPE = 1; + + /** REV Power Distribution Hub (PDH). */ public static final int REV_TYPE = 2; + + /** Use the default module number for the selected module type. */ public static final int DEFAULT_MODULE = -1; /** diff --git a/hal/src/main/java/edu/wpi/first/hal/PowerDistributionStickyFaults.java b/hal/src/main/java/edu/wpi/first/hal/PowerDistributionStickyFaults.java index 91e3473ef1..f81f5471e6 100644 --- a/hal/src/main/java/edu/wpi/first/hal/PowerDistributionStickyFaults.java +++ b/hal/src/main/java/edu/wpi/first/hal/PowerDistributionStickyFaults.java @@ -4,62 +4,94 @@ package edu.wpi.first.hal; +/** + * Sticky faults for a PowerDistribution device. These faults will remain active until they are + * reset by the user. + */ @SuppressWarnings("MemberName") public class PowerDistributionStickyFaults { + /** Breaker fault on channel 0. */ public final boolean Channel0BreakerFault; + /** Breaker fault on channel 1. */ public final boolean Channel1BreakerFault; + /** Breaker fault on channel 2. */ public final boolean Channel2BreakerFault; + /** Breaker fault on channel 3. */ public final boolean Channel3BreakerFault; + /** Breaker fault on channel 4. */ public final boolean Channel4BreakerFault; + /** Breaker fault on channel 5. */ public final boolean Channel5BreakerFault; + /** Breaker fault on channel 6. */ public final boolean Channel6BreakerFault; + /** Breaker fault on channel 7. */ public final boolean Channel7BreakerFault; + /** Breaker fault on channel 8. */ public final boolean Channel8BreakerFault; + /** Breaker fault on channel 9. */ public final boolean Channel9BreakerFault; + /** Breaker fault on channel 10. */ public final boolean Channel10BreakerFault; + /** Breaker fault on channel 11. */ public final boolean Channel11BreakerFault; + /** Breaker fault on channel 12. */ public final boolean Channel12BreakerFault; + /** Breaker fault on channel 13. */ public final boolean Channel13BreakerFault; + /** Breaker fault on channel 14. */ public final boolean Channel14BreakerFault; + /** Breaker fault on channel 15. */ public final boolean Channel15BreakerFault; + /** Breaker fault on channel 16. */ public final boolean Channel16BreakerFault; + /** Breaker fault on channel 17. */ public final boolean Channel17BreakerFault; + /** Breaker fault on channel 18. */ public final boolean Channel18BreakerFault; + /** Breaker fault on channel 19. */ public final boolean Channel19BreakerFault; + /** Breaker fault on channel 20. */ public final boolean Channel20BreakerFault; + /** Breaker fault on channel 21. */ public final boolean Channel21BreakerFault; + /** Breaker fault on channel 22. */ public final boolean Channel22BreakerFault; + /** Breaker fault on channel 23. */ public final boolean Channel23BreakerFault; + /** The input voltage was below the minimum voltage. */ public final boolean Brownout; + /** A warning was raised by the device's CAN controller. */ public final boolean CanWarning; + /** The device's CAN controller experienced a "Bus Off" event. */ public final boolean CanBusOff; + /** The device has rebooted. */ public final boolean HasReset; /** diff --git a/hal/src/main/java/edu/wpi/first/hal/REVPHFaults.java b/hal/src/main/java/edu/wpi/first/hal/REVPHFaults.java index fab9b872b1..024d0dfbf5 100644 --- a/hal/src/main/java/edu/wpi/first/hal/REVPHFaults.java +++ b/hal/src/main/java/edu/wpi/first/hal/REVPHFaults.java @@ -4,50 +4,73 @@ package edu.wpi.first.hal; +/** Faults for a REV PH. These faults are only active while the condition is active. */ @SuppressWarnings("MemberName") public class REVPHFaults { + /** Fault on channel 0. */ public final boolean Channel0Fault; + /** Fault on channel 1. */ public final boolean Channel1Fault; + /** Fault on channel 2. */ public final boolean Channel2Fault; + /** Fault on channel 3. */ public final boolean Channel3Fault; + /** Fault on channel 4. */ public final boolean Channel4Fault; + /** Fault on channel 5. */ public final boolean Channel5Fault; + /** Fault on channel 6. */ public final boolean Channel6Fault; + /** Fault on channel 7. */ public final boolean Channel7Fault; + /** Fault on channel 8. */ public final boolean Channel8Fault; + /** Fault on channel 9. */ public final boolean Channel9Fault; + /** Fault on channel 10. */ public final boolean Channel10Fault; + /** Fault on channel 11. */ public final boolean Channel11Fault; + /** Fault on channel 12. */ public final boolean Channel12Fault; + /** Fault on channel 13. */ public final boolean Channel13Fault; + /** Fault on channel 14. */ public final boolean Channel14Fault; + /** Fault on channel 15. */ public final boolean Channel15Fault; + /** An overcurrent event occurred on the compressor output. */ public final boolean CompressorOverCurrent; + /** The compressor output has an open circuit. */ public final boolean CompressorOpen; + /** An overcurrent event occurred on a solenoid ouput. */ public final boolean SolenoidOverCurrent; + /** The input voltage is below the minimum voltage. */ public final boolean Brownout; + /** A warning was raised by the device's CAN controller. */ public final boolean CanWarning; + /** The hardware on the device has malfunctioned. */ public final boolean HardwareFault; /** diff --git a/hal/src/main/java/edu/wpi/first/hal/REVPHJNI.java b/hal/src/main/java/edu/wpi/first/hal/REVPHJNI.java index 8ad9351d85..e0ee27eb2e 100644 --- a/hal/src/main/java/edu/wpi/first/hal/REVPHJNI.java +++ b/hal/src/main/java/edu/wpi/first/hal/REVPHJNI.java @@ -10,9 +10,16 @@ package edu.wpi.first.hal; * @see "REVPH.h" */ public class REVPHJNI extends JNIWrapper { + /** Disabled. */ public static final int COMPRESSOR_CONFIG_TYPE_DISABLED = 0; + + /** Digital. */ public static final int COMPRESSOR_CONFIG_TYPE_DIGITAL = 1; + + /** Analog. */ public static final int COMPRESSOR_CONFIG_TYPE_ANALOG = 2; + + /** Hybrid. */ public static final int COMPRESSOR_CONFIG_TYPE_HYBRID = 3; /** diff --git a/hal/src/main/java/edu/wpi/first/hal/REVPHStickyFaults.java b/hal/src/main/java/edu/wpi/first/hal/REVPHStickyFaults.java index 614389eabe..648458de78 100644 --- a/hal/src/main/java/edu/wpi/first/hal/REVPHStickyFaults.java +++ b/hal/src/main/java/edu/wpi/first/hal/REVPHStickyFaults.java @@ -4,20 +4,28 @@ package edu.wpi.first.hal; +/** Sticky faults for a REV PH. These faults will remain active until they are reset by the user. */ @SuppressWarnings("MemberName") public class REVPHStickyFaults { + /** An overcurrent event occurred on the compressor output. */ public final boolean CompressorOverCurrent; + /** The compressor output has an open circuit. */ public final boolean CompressorOpen; + /** An overcurrent event occurred on a solenoid ouput. */ public final boolean SolenoidOverCurrent; + /** The input voltage is below the minimum voltage. */ public final boolean Brownout; + /** A warning was raised by the device's CAN controller. */ public final boolean CanWarning; + /** The device's CAN controller experienced a "Bus Off" event. */ public final boolean CanBusOff; + /** The device has rebooted. */ public final boolean HasReset; /** diff --git a/hal/src/main/java/edu/wpi/first/hal/REVPHVersion.java b/hal/src/main/java/edu/wpi/first/hal/REVPHVersion.java index 86d0743e54..bb6ad017e4 100644 --- a/hal/src/main/java/edu/wpi/first/hal/REVPHVersion.java +++ b/hal/src/main/java/edu/wpi/first/hal/REVPHVersion.java @@ -4,18 +4,25 @@ package edu.wpi.first.hal; +/** Version and device data received from a REV PH. */ @SuppressWarnings("MemberName") public class REVPHVersion { + /** The firmware major version. */ public final int firmwareMajor; + /** The firmware minor version. */ public final int firmwareMinor; + /** The firmware fix version. */ public final int firmwareFix; + /** The hardware minor version. */ public final int hardwareMinor; + /** The hardware major version. */ public final int hardwareMajor; + /** The device's unique ID. */ public final int uniqueId; /** diff --git a/hal/src/main/java/edu/wpi/first/hal/SPIJNI.java b/hal/src/main/java/edu/wpi/first/hal/SPIJNI.java index 18a0a8e767..242053ec38 100644 --- a/hal/src/main/java/edu/wpi/first/hal/SPIJNI.java +++ b/hal/src/main/java/edu/wpi/first/hal/SPIJNI.java @@ -12,16 +12,34 @@ import java.nio.ByteBuffer; * @see "SPI.h" */ public class SPIJNI extends JNIWrapper { + /** Invalid port number. */ public static final int INVALID_PORT = -1; + + /** Onboard SPI bus port CS0. */ public static final int ONBOARD_CS0_PORT = 0; + + /** Onboard SPI bus port CS1. */ public static final int ONBOARD_CS1_PORT = 1; + + /** Onboard SPI bus port CS2. */ public static final int ONBOARD_CS2_PORT = 2; + + /** Onboard SPI bus port CS3. */ public static final int ONBOARD_CS3_PORT = 3; + + /** MXP (roboRIO MXP) SPI bus port. */ public static final int MXP_PORT = 4; + /** Clock idle low, data sampled on rising edge. */ public static final int SPI_MODE0 = 0; + + /** Clock idle low, data sampled on falling edge. */ public static final int SPI_MODE1 = 1; + + /** Clock idle high, data sampled on falling edge. */ public static final int SPI_MODE2 = 2; + + /** Clock idle high, data sampled on rising edge. */ public static final int SPI_MODE3 = 3; /** diff --git a/hal/src/main/java/edu/wpi/first/hal/SimDevice.java b/hal/src/main/java/edu/wpi/first/hal/SimDevice.java index 7f1491c5b6..ab97d6122c 100644 --- a/hal/src/main/java/edu/wpi/first/hal/SimDevice.java +++ b/hal/src/main/java/edu/wpi/first/hal/SimDevice.java @@ -25,6 +25,7 @@ public class SimDevice implements AutoCloseable { /** Bidirectional direction for simulation devices. */ kBidir(SimDeviceJNI.kBidir); + /** The native value of this Direction. */ public final int m_value; Direction(int value) { diff --git a/hal/src/main/java/edu/wpi/first/hal/SimDeviceJNI.java b/hal/src/main/java/edu/wpi/first/hal/SimDeviceJNI.java index 6941db3b27..398adfa2aa 100644 --- a/hal/src/main/java/edu/wpi/first/hal/SimDeviceJNI.java +++ b/hal/src/main/java/edu/wpi/first/hal/SimDeviceJNI.java @@ -4,9 +4,19 @@ package edu.wpi.first.hal; +/** + * SimDevice JNI Functions. + * + * @see "hal/SimDevice.h" + */ public class SimDeviceJNI extends JNIWrapper { + /** Input to user code from the simulator. */ public static final int kInput = 0; + + /** Output from user code to the simulator. */ public static final int kOutput = 1; + + /** Bidirectional between user code and simulator. */ public static final int kBidir = 2; /** diff --git a/hal/src/main/java/edu/wpi/first/hal/SimValue.java b/hal/src/main/java/edu/wpi/first/hal/SimValue.java index a486981e3a..f83131050c 100644 --- a/hal/src/main/java/edu/wpi/first/hal/SimValue.java +++ b/hal/src/main/java/edu/wpi/first/hal/SimValue.java @@ -42,5 +42,6 @@ public class SimValue { SimDeviceJNI.setSimValue(m_handle, value); } + /** The native handle for this SimValue. */ protected final int m_handle; } diff --git a/hal/src/main/native/include/hal/Counter.h b/hal/src/main/native/include/hal/Counter.h index 9c9d3af401..246562c207 100644 --- a/hal/src/main/native/include/hal/Counter.h +++ b/hal/src/main/native/include/hal/Counter.h @@ -19,9 +19,13 @@ * The counter mode. */ HAL_ENUM(HAL_Counter_Mode) { + /** Two pulse mode. */ HAL_Counter_kTwoPulse = 0, + /** Semi-period mode. */ HAL_Counter_kSemiperiod = 1, + /** Pulse length mode. */ HAL_Counter_kPulseLength = 2, + /** External direction mode. */ HAL_Counter_kExternalDirection = 3 }; diff --git a/hal/src/main/native/include/hal/DriverStation.h b/hal/src/main/native/include/hal/DriverStation.h index 8c5fea0c23..59270afae1 100644 --- a/hal/src/main/native/include/hal/DriverStation.h +++ b/hal/src/main/native/include/hal/DriverStation.h @@ -219,7 +219,18 @@ int32_t HAL_GetMatchInfo(HAL_MatchInfo* info); */ HAL_Bool HAL_RefreshDSData(void); +/** + * Adds an event handle to be signalled when new data arrives. + * + * @param handle the event handle to be signalled + */ void HAL_ProvideNewDataEventHandle(WPI_EventHandle handle); + +/** + * Removes the event handle from being signalled when new data arrives. + * + * @param handle the event handle to remove + */ void HAL_RemoveNewDataEventHandle(WPI_EventHandle handle); /** diff --git a/hal/src/main/native/include/hal/DriverStationTypes.h b/hal/src/main/native/include/hal/DriverStationTypes.h index 8282024a2b..b0b2a425ba 100644 --- a/hal/src/main/native/include/hal/DriverStationTypes.h +++ b/hal/src/main/native/include/hal/DriverStationTypes.h @@ -41,12 +41,19 @@ struct HAL_ControlWord { typedef struct HAL_ControlWord HAL_ControlWord; HAL_ENUM(HAL_AllianceStationID) { + /** Unknown Alliance Station */ HAL_AllianceStationID_kUnknown = 0, + /** Red Alliance Station 1 */ HAL_AllianceStationID_kRed1, + /** Red Alliance Station 2 */ HAL_AllianceStationID_kRed2, + /** Red Alliance Station 3 */ HAL_AllianceStationID_kRed3, + /** Blue Alliance Station 1 */ HAL_AllianceStationID_kBlue1, + /** Blue Alliance Station 2 */ HAL_AllianceStationID_kBlue2, + /** Blue Alliance Station 3 */ HAL_AllianceStationID_kBlue3, }; @@ -57,12 +64,21 @@ HAL_ENUM(HAL_MatchType) { HAL_kMatchType_elimination, }; -/* The maximum number of axes that will be stored in a single HALJoystickAxes - * struct. This is used for allocating buffers, not bounds checking, since - * there are usually less axes in practice. +/** + * The maximum number of axes that will be stored in a single HAL_JoystickAxes + * struct. This is used for allocating buffers, not bounds checking, since there + * are usually less axes in practice. */ #define HAL_kMaxJoystickAxes 12 +/** + * The maximum number of POVs that will be stored in a single HAL_JoystickPOVs + * struct. This is used for allocating buffers, not bounds checking, since there + * are usually less POVs in practice. + */ #define HAL_kMaxJoystickPOVs 12 +/** + * The maximum number of joysticks. + */ #define HAL_kMaxJoysticks 6 struct HAL_JoystickAxes { diff --git a/hal/src/main/native/include/hal/HALBase.h b/hal/src/main/native/include/hal/HALBase.h index e59b26cbae..0359665985 100644 --- a/hal/src/main/native/include/hal/HALBase.h +++ b/hal/src/main/native/include/hal/HALBase.h @@ -24,9 +24,15 @@ * @{ */ +/** + * Runtime type. + */ HAL_ENUM(HAL_RuntimeType) { + /** roboRIO 1.0 */ HAL_Runtime_RoboRIO, + /** roboRIO 2.0 */ HAL_Runtime_RoboRIO2, + /** Simulation runtime */ HAL_Runtime_Simulation }; diff --git a/hal/src/main/native/include/hal/PWM.h b/hal/src/main/native/include/hal/PWM.h index d308f8e59e..14566fcd7a 100644 --- a/hal/src/main/native/include/hal/PWM.h +++ b/hal/src/main/native/include/hal/PWM.h @@ -216,7 +216,7 @@ void HAL_SetPWMAlwaysHighMode(HAL_DigitalHandle pwmPortHandle, int32_t* status); * Gets the loop timing of the PWM system. * * @param[out] status Error status variable. 0 on success. - * @return the loop time + * @return the loop time in clock ticks */ int32_t HAL_GetPWMLoopTiming(int32_t* status); diff --git a/hal/src/main/native/include/hal/PowerDistribution.h b/hal/src/main/native/include/hal/PowerDistribution.h index 835f2eaf4c..1241d1ee31 100644 --- a/hal/src/main/native/include/hal/PowerDistribution.h +++ b/hal/src/main/native/include/hal/PowerDistribution.h @@ -19,11 +19,15 @@ * The types of power distribution devices. */ HAL_ENUM(HAL_PowerDistributionType) { + /** Automatically determines the module type */ HAL_PowerDistributionType_kAutomatic = 0, + /** CTRE (Cross The Road Electronics) Power Distribution Panel (PDP). */ HAL_PowerDistributionType_kCTRE = 1, + /** REV Power Distribution Hub (PDH). */ HAL_PowerDistributionType_kRev = 2, }; +/** Use the default module number for the selected module type */ #define HAL_DEFAULT_POWER_DISTRIBUTION_MODULE -1 #ifdef __cplusplus @@ -244,32 +248,59 @@ struct HAL_PowerDistributionVersion { }; struct HAL_PowerDistributionFaults { + /** Breaker fault on channel 0. */ uint32_t channel0BreakerFault : 1; + /** Breaker fault on channel 1. */ uint32_t channel1BreakerFault : 1; + /** Breaker fault on channel 2. */ uint32_t channel2BreakerFault : 1; + /** Breaker fault on channel 3. */ uint32_t channel3BreakerFault : 1; + /** Breaker fault on channel 4. */ uint32_t channel4BreakerFault : 1; + /** Breaker fault on channel 5. */ uint32_t channel5BreakerFault : 1; + /** Breaker fault on channel 6. */ uint32_t channel6BreakerFault : 1; + /** Breaker fault on channel 7. */ uint32_t channel7BreakerFault : 1; + /** Breaker fault on channel 8. */ uint32_t channel8BreakerFault : 1; + /** Breaker fault on channel 9. */ uint32_t channel9BreakerFault : 1; + /** Breaker fault on channel 10. */ uint32_t channel10BreakerFault : 1; + /** Breaker fault on channel 12. */ uint32_t channel11BreakerFault : 1; + /** Breaker fault on channel 13. */ uint32_t channel12BreakerFault : 1; + /** Breaker fault on channel 14. */ uint32_t channel13BreakerFault : 1; + /** Breaker fault on channel 15. */ uint32_t channel14BreakerFault : 1; + /** Breaker fault on channel 16. */ uint32_t channel15BreakerFault : 1; + /** Breaker fault on channel 17. */ uint32_t channel16BreakerFault : 1; + /** Breaker fault on channel 18. */ uint32_t channel17BreakerFault : 1; + /** Breaker fault on channel 19. */ uint32_t channel18BreakerFault : 1; + /** Breaker fault on channel 20. */ uint32_t channel19BreakerFault : 1; + /** Breaker fault on channel 21. */ uint32_t channel20BreakerFault : 1; + /** Breaker fault on channel 22. */ uint32_t channel21BreakerFault : 1; + /** Breaker fault on channel 23. */ uint32_t channel22BreakerFault : 1; + /** Breaker fault on channel 24. */ uint32_t channel23BreakerFault : 1; + /** The input voltage is below the minimum voltage. */ uint32_t brownout : 1; + /** A warning was raised by the device's CAN controller. */ uint32_t canWarning : 1; + /** The hardware on the device has malfunctioned. */ uint32_t hardwareFault : 1; }; @@ -277,33 +308,61 @@ struct HAL_PowerDistributionFaults { * Storage for REV PDH Sticky Faults */ struct HAL_PowerDistributionStickyFaults { + /** Breaker fault on channel 0. */ uint32_t channel0BreakerFault : 1; + /** Breaker fault on channel 1. */ uint32_t channel1BreakerFault : 1; + /** Breaker fault on channel 2. */ uint32_t channel2BreakerFault : 1; + /** Breaker fault on channel 3. */ uint32_t channel3BreakerFault : 1; + /** Breaker fault on channel 4. */ uint32_t channel4BreakerFault : 1; + /** Breaker fault on channel 5. */ uint32_t channel5BreakerFault : 1; + /** Breaker fault on channel 6. */ uint32_t channel6BreakerFault : 1; + /** Breaker fault on channel 7. */ uint32_t channel7BreakerFault : 1; + /** Breaker fault on channel 8. */ uint32_t channel8BreakerFault : 1; + /** Breaker fault on channel 9. */ uint32_t channel9BreakerFault : 1; + /** Breaker fault on channel 10. */ uint32_t channel10BreakerFault : 1; + /** Breaker fault on channel 12. */ uint32_t channel11BreakerFault : 1; + /** Breaker fault on channel 13. */ uint32_t channel12BreakerFault : 1; + /** Breaker fault on channel 14. */ uint32_t channel13BreakerFault : 1; + /** Breaker fault on channel 15. */ uint32_t channel14BreakerFault : 1; + /** Breaker fault on channel 16. */ uint32_t channel15BreakerFault : 1; + /** Breaker fault on channel 17. */ uint32_t channel16BreakerFault : 1; + /** Breaker fault on channel 18. */ uint32_t channel17BreakerFault : 1; + /** Breaker fault on channel 19. */ uint32_t channel18BreakerFault : 1; + /** Breaker fault on channel 20. */ uint32_t channel19BreakerFault : 1; + /** Breaker fault on channel 21. */ uint32_t channel20BreakerFault : 1; + /** Breaker fault on channel 22. */ uint32_t channel21BreakerFault : 1; + /** Breaker fault on channel 23. */ uint32_t channel22BreakerFault : 1; + /** Breaker fault on channel 24. */ uint32_t channel23BreakerFault : 1; + /** The input voltage is below the minimum voltage. */ uint32_t brownout : 1; + /** A warning was raised by the device's CAN controller. */ uint32_t canWarning : 1; + /** The device's CAN controller experienced a "Bus Off" event. */ uint32_t canBusOff : 1; + /** The device has rebooted. */ uint32_t hasReset : 1; }; @@ -320,6 +379,8 @@ void HAL_GetPowerDistributionVersion(HAL_PowerDistributionHandle handle, /** * Get the current faults of the PowerDistribution. * + * On a CTRE PDP, this will return an object with no faults active. + * * @param[in] handle the module handle * @param[out] faults the HAL_PowerDistributionFaults to populate * @param[out] status Error status variable. 0 on success. @@ -331,6 +392,8 @@ void HAL_GetPowerDistributionFaults(HAL_PowerDistributionHandle handle, /** * Gets the sticky faults of the PowerDistribution. * + * On a CTRE PDP, this will return an object with no faults active. + * * @param[in] handle the module handle * @param[out] stickyFaults the HAL_PowerDistributionStickyFaults to populate * @param[out] status Error status variable. 0 on success. diff --git a/hal/src/main/native/include/hal/REVPH.h b/hal/src/main/native/include/hal/REVPH.h index c90ea52037..6e9ff79639 100644 --- a/hal/src/main/native/include/hal/REVPH.h +++ b/hal/src/main/native/include/hal/REVPH.h @@ -18,9 +18,13 @@ * The compressor configuration type */ HAL_ENUM(HAL_REVPHCompressorConfigType) { + /** Disabled. */ HAL_REVPHCompressorConfigType_kDisabled = 0, + /** Digital. */ HAL_REVPHCompressorConfigType_kDigital = 1, + /** Analog. */ HAL_REVPHCompressorConfigType_kAnalog = 2, + /** Hybrid. */ HAL_REVPHCompressorConfigType_kHybrid = 3, }; @@ -28,11 +32,17 @@ HAL_ENUM(HAL_REVPHCompressorConfigType) { * Storage for REV PH Version */ struct HAL_REVPHVersion { + /** The firmware major version. */ uint32_t firmwareMajor; + /** The firmware minor version. */ uint32_t firmwareMinor; + /** The firmware fix version. */ uint32_t firmwareFix; + /** The hardware minor version. */ uint32_t hardwareMinor; + /** The hardware major version. */ uint32_t hardwareMajor; + /** The device's unique ID. */ uint32_t uniqueId; }; @@ -50,27 +60,49 @@ struct HAL_REVPHCompressorConfig { * Storage for REV PH Faults */ struct HAL_REVPHFaults { + /** Fault on channel 0. */ uint32_t channel0Fault : 1; + /** Fault on channel 1. */ uint32_t channel1Fault : 1; + /** Fault on channel 2. */ uint32_t channel2Fault : 1; + /** Fault on channel 3. */ uint32_t channel3Fault : 1; + /** Fault on channel 4. */ uint32_t channel4Fault : 1; + /** Fault on channel 5. */ uint32_t channel5Fault : 1; + /** Fault on channel 6. */ uint32_t channel6Fault : 1; + /** Fault on channel 7. */ uint32_t channel7Fault : 1; + /** Fault on channel 8. */ uint32_t channel8Fault : 1; + /** Fault on channel 9. */ uint32_t channel9Fault : 1; + /** Fault on channel 10. */ uint32_t channel10Fault : 1; + /** Fault on channel 11. */ uint32_t channel11Fault : 1; + /** Fault on channel 12. */ uint32_t channel12Fault : 1; + /** Fault on channel 13. */ uint32_t channel13Fault : 1; + /** Fault on channel 14. */ uint32_t channel14Fault : 1; + /** Fault on channel 15. */ uint32_t channel15Fault : 1; + /** An overcurrent event occurred on the compressor output. */ uint32_t compressorOverCurrent : 1; + /** The compressor output has an open circuit. */ uint32_t compressorOpen : 1; + /** An overcurrent event occurred on a solenoid ouput. */ uint32_t solenoidOverCurrent : 1; + /** The input voltage is below the minimum voltage. */ uint32_t brownout : 1; + /** A warning was raised by the device's CAN controller. */ uint32_t canWarning : 1; + /** The hardware on the device has malfunctioned. */ uint32_t hardwareFault : 1; }; @@ -78,12 +110,19 @@ struct HAL_REVPHFaults { * Storage for REV PH Sticky Faults */ struct HAL_REVPHStickyFaults { + /** An overcurrent event occurred on the compressor output. */ uint32_t compressorOverCurrent : 1; + /** The compressor output has an open circuit. */ uint32_t compressorOpen : 1; + /** An overcurrent event occurred on a solenoid ouput. */ uint32_t solenoidOverCurrent : 1; + /** The input voltage is below the minimum voltage. */ uint32_t brownout : 1; + /** A warning was raised by the device's CAN controller. */ uint32_t canWarning : 1; + /** The device's CAN controller experienced a "Bus Off" event. */ uint32_t canBusOff : 1; + /** The device has rebooted. */ uint32_t hasReset : 1; }; diff --git a/hal/src/main/native/include/hal/SPITypes.h b/hal/src/main/native/include/hal/SPITypes.h index d521665607..b032c0313a 100644 --- a/hal/src/main/native/include/hal/SPITypes.h +++ b/hal/src/main/native/include/hal/SPITypes.h @@ -14,19 +14,31 @@ * @{ */ +/** SPI port. */ HAL_ENUM(HAL_SPIPort) { + /** Invalid port number. */ HAL_SPI_kInvalid = -1, + /** Onboard SPI bus port CS0. */ HAL_SPI_kOnboardCS0, + /** Onboard SPI bus port CS1. */ HAL_SPI_kOnboardCS1, + /** Onboard SPI bus port CS2. */ HAL_SPI_kOnboardCS2, + /** Onboard SPI bus port CS3. */ HAL_SPI_kOnboardCS3, + /** MXP (roboRIO MXP) SPI bus port. */ HAL_SPI_kMXP }; +/** SPI mode. */ HAL_ENUM(HAL_SPIMode) { + /** Clock idle low, data sampled on rising edge. */ HAL_SPI_kMode0 = 0, + /** Clock idle low, data sampled on falling edge. */ HAL_SPI_kMode1 = 1, + /** Clock idle high, data sampled on falling edge. */ HAL_SPI_kMode2 = 2, + /** Clock idle high, data sampled on rising edge. */ HAL_SPI_kMode3 = 3, }; diff --git a/hal/src/main/native/include/hal/Value.h b/hal/src/main/native/include/hal/Value.h index ff72ee738e..7617611b35 100644 --- a/hal/src/main/native/include/hal/Value.h +++ b/hal/src/main/native/include/hal/Value.h @@ -8,11 +8,17 @@ /** HAL data types. */ enum HAL_Type { + /** Unassigned type. */ HAL_UNASSIGNED = 0, + /** Boolean. */ HAL_BOOLEAN = 0x01, + /** Double. */ HAL_DOUBLE = 0x02, + /** Enum. */ HAL_ENUM = 0x04, + /** Int. */ HAL_INT = 0x08, + /** Long. */ HAL_LONG = 0x10, }; @@ -31,7 +37,12 @@ struct HAL_Value { #ifdef __cplusplus extern "C" { #endif - +/** + * Build a HAL boolean value. + * + * @param v value + * @return HAL value + */ inline struct HAL_Value HAL_MakeBoolean(HAL_Bool v) { struct HAL_Value value; value.type = HAL_BOOLEAN; @@ -39,6 +50,12 @@ inline struct HAL_Value HAL_MakeBoolean(HAL_Bool v) { return value; } +/** + * Build a HAL enum value. + * + * @param v value + * @return HAL value + */ inline struct HAL_Value HAL_MakeEnum(int v) { struct HAL_Value value; value.type = HAL_ENUM; @@ -46,6 +63,12 @@ inline struct HAL_Value HAL_MakeEnum(int v) { return value; } +/** + * Build a HAL int value. + * + * @param v value + * @return HAL value + */ inline struct HAL_Value HAL_MakeInt(int v) { struct HAL_Value value; value.type = HAL_INT; @@ -53,6 +76,12 @@ inline struct HAL_Value HAL_MakeInt(int v) { return value; } +/** + * Build a HAL long value. + * + * @param v value + * @return HAL value + */ inline struct HAL_Value HAL_MakeLong(int64_t v) { struct HAL_Value value; value.type = HAL_LONG; @@ -60,6 +89,12 @@ inline struct HAL_Value HAL_MakeLong(int64_t v) { return value; } +/** + * Build a HAL double value. + * + * @param v value + * @return HAL value + */ inline struct HAL_Value HAL_MakeDouble(double v) { struct HAL_Value value; value.type = HAL_DOUBLE; diff --git a/wpilibc/src/main/native/include/frc/PneumaticHub.h b/wpilibc/src/main/native/include/frc/PneumaticHub.h index 790a9d0a86..f2ff204f3e 100644 --- a/wpilibc/src/main/native/include/frc/PneumaticHub.h +++ b/wpilibc/src/main/native/include/frc/PneumaticHub.h @@ -119,12 +119,19 @@ class PneumaticHub : public PneumaticsBase { int reverseChannel) override; Compressor MakeCompressor() override; + /** Version and device data received from a REV PH. */ struct Version { + /** The firmware major version. */ uint32_t FirmwareMajor; + /** The firmware minor version. */ uint32_t FirmwareMinor; + /** The firmware fix version. */ uint32_t FirmwareFix; + /** The hardware minor version. */ uint32_t HardwareMinor; + /** The hardware major version. */ uint32_t HardwareMajor; + /** The device's unique ID. */ uint32_t UniqueId; }; @@ -135,28 +142,54 @@ class PneumaticHub : public PneumaticsBase { */ Version GetVersion() const; + /** + * Faults for a REV PH. These faults are only active while the condition is + * active. + */ struct Faults { + /** Fault on channel 0. */ uint32_t Channel0Fault : 1; + /** Fault on channel 1. */ uint32_t Channel1Fault : 1; + /** Fault on channel 2. */ uint32_t Channel2Fault : 1; + /** Fault on channel 3. */ uint32_t Channel3Fault : 1; + /** Fault on channel 4. */ uint32_t Channel4Fault : 1; + /** Fault on channel 5. */ uint32_t Channel5Fault : 1; + /** Fault on channel 6. */ uint32_t Channel6Fault : 1; + /** Fault on channel 7. */ uint32_t Channel7Fault : 1; + /** Fault on channel 8. */ uint32_t Channel8Fault : 1; + /** Fault on channel 9. */ uint32_t Channel9Fault : 1; + /** Fault on channel 10. */ uint32_t Channel10Fault : 1; + /** Fault on channel 11. */ uint32_t Channel11Fault : 1; + /** Fault on channel 12. */ uint32_t Channel12Fault : 1; + /** Fault on channel 13. */ uint32_t Channel13Fault : 1; + /** Fault on channel 14. */ uint32_t Channel14Fault : 1; + /** Fault on channel 15. */ uint32_t Channel15Fault : 1; + /** An overcurrent event occurred on the compressor output. */ uint32_t CompressorOverCurrent : 1; + /** The compressor output has an open circuit. */ uint32_t CompressorOpen : 1; + /** An overcurrent event occurred on a solenoid ouput. */ uint32_t SolenoidOverCurrent : 1; + /** The input voltage is below the minimum voltage. */ uint32_t Brownout : 1; + /** A warning was raised by the device's CAN controller. */ uint32_t CanWarning : 1; + /** The hardware on the device has malfunctioned. */ uint32_t HardwareFault : 1; /** @@ -176,13 +209,24 @@ class PneumaticHub : public PneumaticsBase { */ Faults GetFaults() const; + /** + * Sticky faults for a REV PH. These faults will remain active until they + * are reset by the user. + */ struct StickyFaults { + /** An overcurrent event occurred on the compressor output. */ uint32_t CompressorOverCurrent : 1; + /** The compressor output has an open circuit. */ uint32_t CompressorOpen : 1; + /** An overcurrent event occurred on a solenoid ouput. */ uint32_t SolenoidOverCurrent : 1; + /** The input voltage is below the minimum voltage. */ uint32_t Brownout : 1; + /** A warning was raised by the device's CAN controller. */ uint32_t CanWarning : 1; + /** The device's CAN controller experienced a "Bus Off" event. */ uint32_t CanBusOff : 1; + /** The device has rebooted. */ uint32_t HasReset : 1; }; diff --git a/wpilibc/src/main/native/include/frc/PowerDistribution.h b/wpilibc/src/main/native/include/frc/PowerDistribution.h index 0b79b2c954..28db7fc9b9 100644 --- a/wpilibc/src/main/native/include/frc/PowerDistribution.h +++ b/wpilibc/src/main/native/include/frc/PowerDistribution.h @@ -155,44 +155,82 @@ class PowerDistribution : public wpi::Sendable, */ void SetSwitchableChannel(bool enabled); + /** Version and device data received from a PowerDistribution device */ struct Version { + /** Firmware major version number. */ uint32_t FirmwareMajor; + /** Firmware minor version number. */ uint32_t FirmwareMinor; + /** Firmware fix version number. */ uint32_t FirmwareFix; + /** Hardware minor version number. */ uint32_t HardwareMinor; + /** Hardware major version number. */ uint32_t HardwareMajor; + /** Unique ID. */ uint32_t UniqueId; }; Version GetVersion() const; + /** + * Faults for a PowerDistribution device. These faults are only active while + * the condition is active. + */ struct Faults { + /** Breaker fault on channel 0. */ uint32_t Channel0BreakerFault : 1; + /** Breaker fault on channel 1. */ uint32_t Channel1BreakerFault : 1; + /** Breaker fault on channel 2. */ uint32_t Channel2BreakerFault : 1; + /** Breaker fault on channel 3. */ uint32_t Channel3BreakerFault : 1; + /** Breaker fault on channel 4. */ uint32_t Channel4BreakerFault : 1; + /** Breaker fault on channel 5. */ uint32_t Channel5BreakerFault : 1; + /** Breaker fault on channel 6. */ uint32_t Channel6BreakerFault : 1; + /** Breaker fault on channel 7. */ uint32_t Channel7BreakerFault : 1; + /** Breaker fault on channel 8. */ uint32_t Channel8BreakerFault : 1; + /** Breaker fault on channel 9. */ uint32_t Channel9BreakerFault : 1; + /** Breaker fault on channel 10. */ uint32_t Channel10BreakerFault : 1; + /** Breaker fault on channel 12. */ uint32_t Channel11BreakerFault : 1; + /** Breaker fault on channel 13. */ uint32_t Channel12BreakerFault : 1; + /** Breaker fault on channel 14. */ uint32_t Channel13BreakerFault : 1; + /** Breaker fault on channel 15. */ uint32_t Channel14BreakerFault : 1; + /** Breaker fault on channel 16. */ uint32_t Channel15BreakerFault : 1; + /** Breaker fault on channel 17. */ uint32_t Channel16BreakerFault : 1; + /** Breaker fault on channel 18. */ uint32_t Channel17BreakerFault : 1; + /** Breaker fault on channel 19. */ uint32_t Channel18BreakerFault : 1; + /** Breaker fault on channel 20. */ uint32_t Channel19BreakerFault : 1; + /** Breaker fault on channel 21. */ uint32_t Channel20BreakerFault : 1; + /** Breaker fault on channel 22. */ uint32_t Channel21BreakerFault : 1; + /** Breaker fault on channel 23. */ uint32_t Channel22BreakerFault : 1; + /** Breaker fault on channel 24. */ uint32_t Channel23BreakerFault : 1; + /** The input voltage is below the minimum voltage. */ uint32_t Brownout : 1; + /** A warning was raised by the device's CAN controller. */ uint32_t CanWarning : 1; + /** The hardware on the device has malfunctioned. */ uint32_t HardwareFault : 1; /** @@ -208,38 +246,72 @@ class PowerDistribution : public wpi::Sendable, /** * Returns the power distribution faults. * + * On a CTRE PDP, this will return an object with no faults active. + * * @return The power distribution faults. */ Faults GetFaults() const; + /** + * Sticky faults for a PowerDistribution device. These faults will remain + * active until they are reset by the user. + */ struct StickyFaults { + /** Breaker fault on channel 0. */ uint32_t Channel0BreakerFault : 1; + /** Breaker fault on channel 1. */ uint32_t Channel1BreakerFault : 1; + /** Breaker fault on channel 2. */ uint32_t Channel2BreakerFault : 1; + /** Breaker fault on channel 3. */ uint32_t Channel3BreakerFault : 1; + /** Breaker fault on channel 4. */ uint32_t Channel4BreakerFault : 1; + /** Breaker fault on channel 5. */ uint32_t Channel5BreakerFault : 1; + /** Breaker fault on channel 6. */ uint32_t Channel6BreakerFault : 1; + /** Breaker fault on channel 7. */ uint32_t Channel7BreakerFault : 1; + /** Breaker fault on channel 8. */ uint32_t Channel8BreakerFault : 1; + /** Breaker fault on channel 9. */ uint32_t Channel9BreakerFault : 1; + /** Breaker fault on channel 10. */ uint32_t Channel10BreakerFault : 1; + /** Breaker fault on channel 12. */ uint32_t Channel11BreakerFault : 1; + /** Breaker fault on channel 13. */ uint32_t Channel12BreakerFault : 1; + /** Breaker fault on channel 14. */ uint32_t Channel13BreakerFault : 1; + /** Breaker fault on channel 15. */ uint32_t Channel14BreakerFault : 1; + /** Breaker fault on channel 16. */ uint32_t Channel15BreakerFault : 1; + /** Breaker fault on channel 17. */ uint32_t Channel16BreakerFault : 1; + /** Breaker fault on channel 18. */ uint32_t Channel17BreakerFault : 1; + /** Breaker fault on channel 19. */ uint32_t Channel18BreakerFault : 1; + /** Breaker fault on channel 20. */ uint32_t Channel19BreakerFault : 1; + /** Breaker fault on channel 21. */ uint32_t Channel20BreakerFault : 1; + /** Breaker fault on channel 22. */ uint32_t Channel21BreakerFault : 1; + /** Breaker fault on channel 23. */ uint32_t Channel22BreakerFault : 1; + /** Breaker fault on channel 24. */ uint32_t Channel23BreakerFault : 1; + /** The input voltage is below the minimum voltage. */ uint32_t Brownout : 1; + /** A warning was raised by the device's CAN controller. */ uint32_t CanWarning : 1; + /** The device's CAN controller experienced a "Bus Off" event. */ uint32_t CanBusOff : 1; + /** The device has rebooted. */ uint32_t HasReset : 1; /** @@ -256,6 +328,8 @@ class PowerDistribution : public wpi::Sendable, /** * Returns the power distribution sticky faults. * + * On a CTRE PDP, this will return an object with no faults active. + * * @return The power distribution sticky faults. */ StickyFaults GetStickyFaults() const; diff --git a/wpilibj/src/main/java/edu/wpi/first/wpilibj/PowerDistribution.java b/wpilibj/src/main/java/edu/wpi/first/wpilibj/PowerDistribution.java index ee4cbdc086..2325fe4342 100644 --- a/wpilibj/src/main/java/edu/wpi/first/wpilibj/PowerDistribution.java +++ b/wpilibj/src/main/java/edu/wpi/first/wpilibj/PowerDistribution.java @@ -27,7 +27,7 @@ public class PowerDistribution implements Sendable, AutoCloseable { /** Power distribution module type. */ public enum ModuleType { - /** CTRE (Cross The Road Electronics) CTRE Power Distribution Panel (PDP). */ + /** CTRE (Cross The Road Electronics) Power Distribution Panel (PDP). */ kCTRE(PowerDistributionJNI.CTRE_TYPE), /** REV Power Distribution Hub (PDH). */ kRev(PowerDistributionJNI.REV_TYPE); @@ -222,6 +222,8 @@ public class PowerDistribution implements Sendable, AutoCloseable { /** * Returns the power distribution faults. * + *

On a CTRE PDP, this will return an object with no faults active. + * * @return The power distribution faults. */ public PowerDistributionFaults getFaults() { @@ -231,6 +233,8 @@ public class PowerDistribution implements Sendable, AutoCloseable { /** * Returns the power distribution sticky faults. * + *

On a CTRE PDP, this will return an object with no faults active. + * * @return The power distribution sticky faults. */ public PowerDistributionStickyFaults getStickyFaults() {