mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-07-03 03:01:44 +00:00
[hal] Expose power rail disable and cpu temp functionality (#5477)
This commit is contained in:
@@ -61,6 +61,11 @@ int32_t HAL_GetUserCurrentFaults6V(int32_t* status) {
|
||||
power->readFaultCounts_OverCurrentFaultCount6V(status));
|
||||
}
|
||||
|
||||
void HAL_SetUserRailEnabled6V(HAL_Bool enabled, int32_t* status) {
|
||||
initializePower(status);
|
||||
power->writeDisable_User6V(!enabled, status);
|
||||
}
|
||||
|
||||
double HAL_GetUserVoltage5V(int32_t* status) {
|
||||
initializePower(status);
|
||||
return power->readUserVoltage5V(status) / 4.096 * 0.005962 - 0.013;
|
||||
@@ -82,6 +87,11 @@ int32_t HAL_GetUserCurrentFaults5V(int32_t* status) {
|
||||
power->readFaultCounts_OverCurrentFaultCount5V(status));
|
||||
}
|
||||
|
||||
void HAL_SetUserRailEnabled5V(HAL_Bool enabled, int32_t* status) {
|
||||
initializePower(status);
|
||||
power->writeDisable_User5V(!enabled, status);
|
||||
}
|
||||
|
||||
double HAL_GetUserVoltage3V3(int32_t* status) {
|
||||
initializePower(status);
|
||||
return power->readUserVoltage3V3(status) / 4.096 * 0.004902 - 0.01;
|
||||
@@ -103,6 +113,11 @@ int32_t HAL_GetUserCurrentFaults3V3(int32_t* status) {
|
||||
power->readFaultCounts_OverCurrentFaultCount3V3(status));
|
||||
}
|
||||
|
||||
void HAL_SetUserRailEnabled3V3(HAL_Bool enabled, int32_t* status) {
|
||||
initializePower(status);
|
||||
power->writeDisable_User3V3(!enabled, status);
|
||||
}
|
||||
|
||||
void HAL_SetBrownoutVoltage(double voltage, int32_t* status) {
|
||||
initializePower(status);
|
||||
if (voltage < 0) {
|
||||
@@ -121,4 +136,9 @@ double HAL_GetBrownoutVoltage(int32_t* status) {
|
||||
return brownout / 4.0;
|
||||
}
|
||||
|
||||
double HAL_GetCPUTemp(int32_t* status) {
|
||||
initializePower(status);
|
||||
return power->readOnChipTemperature(status) / 4096.0 * 503.975 - 273.15;
|
||||
}
|
||||
|
||||
} // extern "C"
|
||||
|
||||
@@ -28,6 +28,7 @@ DEFINE_CAPI(int32_t, UserFaults6V, 0)
|
||||
DEFINE_CAPI(int32_t, UserFaults5V, 0)
|
||||
DEFINE_CAPI(int32_t, UserFaults3V3, 0)
|
||||
DEFINE_CAPI(double, BrownoutVoltage, 6.75)
|
||||
DEFINE_CAPI(int32_t, CPUTemp, 16)
|
||||
|
||||
int32_t HALSIM_RegisterRoboRioSerialNumberCallback(
|
||||
HAL_RoboRioStringCallback callback, void* param, HAL_Bool initialNotify) {
|
||||
|
||||
Reference in New Issue
Block a user