[hal, wpilib] Add brownout voltage configuration (#3632)

This commit is contained in:
Thad House
2021-10-13 19:14:27 -07:00
committed by GitHub
parent 9cd4bc407a
commit 689e9ccfb5
21 changed files with 319 additions and 0 deletions

View File

@@ -103,4 +103,22 @@ int32_t HAL_GetUserCurrentFaults3V3(int32_t* status) {
power->readFaultCounts_OverCurrentFaultCount3V3(status));
}
void HAL_SetBrownoutVoltage(double voltage, int32_t* status) {
initializePower(status);
if (voltage < 0) {
voltage = 0;
}
if (voltage > 50) {
voltage = 50;
}
power->writeBrownoutVoltage250mV(static_cast<unsigned char>(voltage * 4),
status);
}
double HAL_GetBrownoutVoltage(int32_t* status) {
initializePower(status);
auto brownout = power->readBrownoutVoltage250mV(status);
return brownout / 4.0;
}
} // extern "C"

View File

@@ -27,6 +27,7 @@ DEFINE_CAPI(HAL_Bool, UserActive3V3, false)
DEFINE_CAPI(int32_t, UserFaults6V, 0)
DEFINE_CAPI(int32_t, UserFaults5V, 0)
DEFINE_CAPI(int32_t, UserFaults3V3, 0)
DEFINE_CAPI(double, BrownoutVoltage, 6.75)
void HALSIM_RegisterRoboRioAllCallbacks(HAL_NotifyCallback callback,
void* param, HAL_Bool initialNotify) {}