mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-07-01 02:41:48 +00:00
[hal] Expose more FPGA functionality (#6942)
- function to reset user rail fault counters - function to get comms disable count - correct docs for user rail count functions
This commit is contained in:
@@ -452,6 +452,15 @@ HAL_Bool HAL_GetBrownedOut(int32_t* status) {
|
||||
return !(watchdog->readStatus_PowerAlive(status));
|
||||
}
|
||||
|
||||
int32_t HAL_GetCommsDisableCount(int32_t* status) {
|
||||
hal::init::CheckInit();
|
||||
if (!watchdog) {
|
||||
*status = NiFpga_Status_ResourceNotInitialized;
|
||||
return 0;
|
||||
}
|
||||
return watchdog->readStatus_SysDisableCount(status);
|
||||
}
|
||||
|
||||
HAL_Bool HAL_GetRSLState(int32_t* status) {
|
||||
hal::init::CheckInit();
|
||||
if (!global) {
|
||||
|
||||
@@ -118,6 +118,11 @@ void HAL_SetUserRailEnabled3V3(HAL_Bool enabled, int32_t* status) {
|
||||
power->writeDisable_User3V3(!enabled, status);
|
||||
}
|
||||
|
||||
void HAL_ResetUserCurrentFaults(int32_t* status) {
|
||||
initializePower(status);
|
||||
power->strobeResetFaultCounts(status);
|
||||
}
|
||||
|
||||
void HAL_SetBrownoutVoltage(double voltage, int32_t* status) {
|
||||
initializePower(status);
|
||||
if (voltage < 0) {
|
||||
|
||||
@@ -154,6 +154,21 @@ Java_edu_wpi_first_hal_HAL_getBrownedOut
|
||||
return val;
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_HAL
|
||||
* Method: getCommsDisableCount
|
||||
* Signature: ()I
|
||||
*/
|
||||
JNIEXPORT jint JNICALL
|
||||
Java_edu_wpi_first_hal_HAL_getCommsDisableCount
|
||||
(JNIEnv* env, jclass)
|
||||
{
|
||||
int32_t status = 0;
|
||||
int32_t val = HAL_GetCommsDisableCount(&status);
|
||||
CheckStatus(env, status);
|
||||
return val;
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_HAL
|
||||
* Method: getRSLState
|
||||
|
||||
@@ -264,6 +264,20 @@ Java_edu_wpi_first_hal_PowerJNI_getUserCurrentFaults3V3
|
||||
return val;
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_PowerJNI
|
||||
* Method: resetUserCurrentFaults
|
||||
* Signature: ()V
|
||||
*/
|
||||
JNIEXPORT void JNICALL
|
||||
Java_edu_wpi_first_hal_PowerJNI_resetUserCurrentFaults
|
||||
(JNIEnv* env, jclass)
|
||||
{
|
||||
int32_t status = 0;
|
||||
HAL_ResetUserCurrentFaults(&status);
|
||||
CheckStatus(env, status);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_PowerJNI
|
||||
* Method: setBrownoutVoltage
|
||||
|
||||
@@ -139,6 +139,13 @@ HAL_Bool HAL_GetSystemActive(int32_t* status);
|
||||
*/
|
||||
HAL_Bool HAL_GetBrownedOut(int32_t* status);
|
||||
|
||||
/**
|
||||
* Gets the number of times the system has been disabled due to communication
|
||||
* errors with the Driver Station.
|
||||
* @return number of disables due to communication errors.
|
||||
*/
|
||||
int32_t HAL_GetCommsDisableCount(int32_t* status);
|
||||
|
||||
/**
|
||||
* Gets a port handle for a specific channel.
|
||||
*
|
||||
|
||||
@@ -59,7 +59,7 @@ double HAL_GetUserCurrent6V(int32_t* status);
|
||||
HAL_Bool HAL_GetUserActive6V(int32_t* status);
|
||||
|
||||
/**
|
||||
* Gets the fault count for the 6V rail.
|
||||
* Gets the fault count for the 6V rail. Capped at 255.
|
||||
*
|
||||
* @param[out] status the error code, or 0 for success
|
||||
* @return the number of 6V fault counts
|
||||
@@ -99,7 +99,7 @@ double HAL_GetUserCurrent5V(int32_t* status);
|
||||
HAL_Bool HAL_GetUserActive5V(int32_t* status);
|
||||
|
||||
/**
|
||||
* Gets the fault count for the 5V rail.
|
||||
* Gets the fault count for the 5V rail. Capped at 255.
|
||||
*
|
||||
* @param[out] status the error code, or 0 for success
|
||||
* @return the number of 5V fault counts
|
||||
@@ -139,7 +139,7 @@ double HAL_GetUserCurrent3V3(int32_t* status);
|
||||
HAL_Bool HAL_GetUserActive3V3(int32_t* status);
|
||||
|
||||
/**
|
||||
* Gets the fault count for the 3V3 rail.
|
||||
* Gets the fault count for the 3V3 rail. Capped at 255.
|
||||
*
|
||||
* @param[out] status the error code, or 0 for success
|
||||
* @return the number of 3V3 fault counts
|
||||
@@ -154,6 +154,12 @@ int32_t HAL_GetUserCurrentFaults3V3(int32_t* status);
|
||||
*/
|
||||
void HAL_SetUserRailEnabled3V3(HAL_Bool enabled, int32_t* status);
|
||||
|
||||
/**
|
||||
* Resets the overcurrent fault counters for all user rails to 0.
|
||||
* @param[out] status the error code, or 0 for success
|
||||
*/
|
||||
void HAL_ResetUserCurrentFaults(int32_t* status);
|
||||
|
||||
/**
|
||||
* Get the current brownout voltage setting.
|
||||
*
|
||||
|
||||
@@ -339,6 +339,10 @@ HAL_Bool HAL_GetBrownedOut(int32_t* status) {
|
||||
return false; // Figure out if we need to detect a brownout condition
|
||||
}
|
||||
|
||||
int32_t HAL_GetCommsDisableCount(int32_t* status) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
HAL_Bool HAL_GetRSLState(int32_t* status) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -59,6 +59,11 @@ int32_t HAL_GetUserCurrentFaults3V3(int32_t* status) {
|
||||
return SimRoboRioData->userFaults3V3;
|
||||
}
|
||||
void HAL_SetUserRailEnabled3V3(HAL_Bool enabled, int32_t* status) {}
|
||||
void HAL_ResetUserCurrentFaults(int32_t* status) {
|
||||
SimRoboRioData->userFaults3V3 = 0;
|
||||
SimRoboRioData->userFaults5V = 0;
|
||||
SimRoboRioData->userFaults6V = 0;
|
||||
}
|
||||
void HAL_SetBrownoutVoltage(double voltage, int32_t* status) {
|
||||
SimRoboRioData->brownoutVoltage = voltage;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user