mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-07-02 02:51:42 +00:00
[hal, wpilib] Add brownout voltage configuration (#3632)
This commit is contained in:
@@ -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"
|
||||
|
||||
@@ -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) {}
|
||||
|
||||
Reference in New Issue
Block a user