2014-11-10 13:15:33 -05:00
|
|
|
/*----------------------------------------------------------------------------*/
|
2015-06-25 15:07:55 -04:00
|
|
|
/* Copyright (c) FIRST 2011. All Rights Reserved.
|
|
|
|
|
*/
|
2014-11-10 13:15:33 -05:00
|
|
|
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
|
|
|
|
/* must be accompanied by the FIRST BSD license file in $(WIND_BASE)/WPILib. */
|
|
|
|
|
/*----------------------------------------------------------------------------*/
|
|
|
|
|
|
|
|
|
|
#include "ControllerPower.h"
|
|
|
|
|
|
|
|
|
|
#include <stdint.h>
|
|
|
|
|
#include <HAL/Power.hpp>
|
|
|
|
|
#include <HAL/HAL.hpp>
|
|
|
|
|
#include "ErrorBase.h"
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Get the input voltage to the robot controller
|
2014-12-29 14:09:37 -05:00
|
|
|
* @return The controller input voltage value in Volts
|
2014-11-10 13:15:33 -05:00
|
|
|
*/
|
|
|
|
|
double ControllerPower::GetInputVoltage() {
|
2015-06-25 15:07:55 -04:00
|
|
|
int32_t status = 0;
|
|
|
|
|
double retVal = getVinVoltage(&status);
|
|
|
|
|
wpi_setGlobalErrorWithContext(status, getHALErrorMessage(status));
|
|
|
|
|
return retVal;
|
2014-11-10 13:15:33 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Get the input current to the robot controller
|
2014-12-29 14:09:37 -05:00
|
|
|
* @return The controller input current value in Amps
|
2014-11-10 13:15:33 -05:00
|
|
|
*/
|
|
|
|
|
double ControllerPower::GetInputCurrent() {
|
2015-06-25 15:07:55 -04:00
|
|
|
int32_t status = 0;
|
|
|
|
|
double retVal = getVinCurrent(&status);
|
|
|
|
|
wpi_setGlobalErrorWithContext(status, getHALErrorMessage(status));
|
|
|
|
|
return retVal;
|
2014-11-10 13:15:33 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Get the voltage of the 6V rail
|
2014-12-29 14:09:37 -05:00
|
|
|
* @return The controller 6V rail voltage value in Volts
|
2014-11-10 13:15:33 -05:00
|
|
|
*/
|
|
|
|
|
double ControllerPower::GetVoltage6V() {
|
2015-06-25 15:07:55 -04:00
|
|
|
int32_t status = 0;
|
|
|
|
|
double retVal = getUserVoltage6V(&status);
|
|
|
|
|
wpi_setGlobalErrorWithContext(status, getHALErrorMessage(status));
|
|
|
|
|
return retVal;
|
2014-11-10 13:15:33 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Get the current output of the 6V rail
|
2014-12-29 14:09:37 -05:00
|
|
|
* @return The controller 6V rail output current value in Amps
|
2014-11-10 13:15:33 -05:00
|
|
|
*/
|
|
|
|
|
double ControllerPower::GetCurrent6V() {
|
2015-06-25 15:07:55 -04:00
|
|
|
int32_t status = 0;
|
|
|
|
|
double retVal = getUserCurrent6V(&status);
|
|
|
|
|
wpi_setGlobalErrorWithContext(status, getHALErrorMessage(status));
|
|
|
|
|
return retVal;
|
2014-11-10 13:15:33 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2015-06-25 15:07:55 -04:00
|
|
|
* Get the enabled state of the 6V rail. The rail may be disabled due to a
|
|
|
|
|
* controller
|
2014-11-10 13:15:33 -05:00
|
|
|
* brownout, a short circuit on the rail, or controller over-voltage
|
2014-12-29 14:09:37 -05:00
|
|
|
* @return The controller 6V rail enabled value. True for enabled.
|
2014-11-10 13:15:33 -05:00
|
|
|
*/
|
|
|
|
|
bool ControllerPower::GetEnabled6V() {
|
2015-06-25 15:07:55 -04:00
|
|
|
int32_t status = 0;
|
|
|
|
|
bool retVal = getUserActive6V(&status);
|
|
|
|
|
wpi_setGlobalErrorWithContext(status, getHALErrorMessage(status));
|
|
|
|
|
return retVal;
|
2014-11-10 13:15:33 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2015-06-25 15:07:55 -04:00
|
|
|
* Get the count of the total current faults on the 6V rail since the controller
|
|
|
|
|
* has booted
|
2014-12-29 14:09:37 -05:00
|
|
|
* @return The number of faults.
|
2014-11-10 13:15:33 -05:00
|
|
|
*/
|
|
|
|
|
int ControllerPower::GetFaultCount6V() {
|
2015-06-25 15:07:55 -04:00
|
|
|
int32_t status = 0;
|
|
|
|
|
int retVal = getUserCurrentFaults6V(&status);
|
|
|
|
|
wpi_setGlobalErrorWithContext(status, getHALErrorMessage(status));
|
|
|
|
|
return retVal;
|
2014-11-10 13:15:33 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Get the voltage of the 5V rail
|
2014-12-29 14:09:37 -05:00
|
|
|
* @return The controller 5V rail voltage value in Volts
|
2014-11-10 13:15:33 -05:00
|
|
|
*/
|
|
|
|
|
double ControllerPower::GetVoltage5V() {
|
2015-06-25 15:07:55 -04:00
|
|
|
int32_t status = 0;
|
|
|
|
|
double retVal = getUserVoltage5V(&status);
|
|
|
|
|
wpi_setGlobalErrorWithContext(status, getHALErrorMessage(status));
|
|
|
|
|
return retVal;
|
2014-11-10 13:15:33 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Get the current output of the 5V rail
|
2014-12-29 14:09:37 -05:00
|
|
|
* @return The controller 5V rail output current value in Amps
|
2014-11-10 13:15:33 -05:00
|
|
|
*/
|
|
|
|
|
double ControllerPower::GetCurrent5V() {
|
2015-06-25 15:07:55 -04:00
|
|
|
int32_t status = 0;
|
|
|
|
|
double retVal = getUserCurrent5V(&status);
|
|
|
|
|
wpi_setGlobalErrorWithContext(status, getHALErrorMessage(status));
|
|
|
|
|
return retVal;
|
2014-11-10 13:15:33 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2015-06-25 15:07:55 -04:00
|
|
|
* Get the enabled state of the 5V rail. The rail may be disabled due to a
|
|
|
|
|
* controller
|
2014-11-10 13:15:33 -05:00
|
|
|
* brownout, a short circuit on the rail, or controller over-voltage
|
2014-12-29 14:09:37 -05:00
|
|
|
* @return The controller 5V rail enabled value. True for enabled.
|
2014-11-10 13:15:33 -05:00
|
|
|
*/
|
|
|
|
|
bool ControllerPower::GetEnabled5V() {
|
2015-06-25 15:07:55 -04:00
|
|
|
int32_t status = 0;
|
|
|
|
|
bool retVal = getUserActive5V(&status);
|
|
|
|
|
wpi_setGlobalErrorWithContext(status, getHALErrorMessage(status));
|
|
|
|
|
return retVal;
|
2014-11-10 13:15:33 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2015-06-25 15:07:55 -04:00
|
|
|
* Get the count of the total current faults on the 5V rail since the controller
|
|
|
|
|
* has booted
|
2014-11-10 13:15:33 -05:00
|
|
|
* @return The number of faults
|
|
|
|
|
*/
|
|
|
|
|
int ControllerPower::GetFaultCount5V() {
|
2015-06-25 15:07:55 -04:00
|
|
|
int32_t status = 0;
|
|
|
|
|
int retVal = getUserCurrentFaults5V(&status);
|
|
|
|
|
wpi_setGlobalErrorWithContext(status, getHALErrorMessage(status));
|
|
|
|
|
return retVal;
|
2014-11-10 13:15:33 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Get the voltage of the 3.3V rail
|
2014-12-29 14:09:37 -05:00
|
|
|
* @return The controller 3.3V rail voltage value in Volts
|
2014-11-10 13:15:33 -05:00
|
|
|
*/
|
|
|
|
|
double ControllerPower::GetVoltage3V3() {
|
2015-06-25 15:07:55 -04:00
|
|
|
int32_t status = 0;
|
|
|
|
|
double retVal = getUserVoltage3V3(&status);
|
|
|
|
|
wpi_setGlobalErrorWithContext(status, getHALErrorMessage(status));
|
|
|
|
|
return retVal;
|
2014-11-10 13:15:33 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Get the current output of the 3.3V rail
|
2014-12-29 14:09:37 -05:00
|
|
|
* @return The controller 3.3V rail output current value in Amps
|
2014-11-10 13:15:33 -05:00
|
|
|
*/
|
|
|
|
|
double ControllerPower::GetCurrent3V3() {
|
2015-06-25 15:07:55 -04:00
|
|
|
int32_t status = 0;
|
|
|
|
|
double retVal = getUserCurrent3V3(&status);
|
|
|
|
|
wpi_setGlobalErrorWithContext(status, getHALErrorMessage(status));
|
|
|
|
|
return retVal;
|
2014-11-10 13:15:33 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2015-06-25 15:07:55 -04:00
|
|
|
* Get the enabled state of the 3.3V rail. The rail may be disabled due to a
|
|
|
|
|
* controller
|
2014-11-10 13:15:33 -05:00
|
|
|
* brownout, a short circuit on the rail, or controller over-voltage
|
2014-12-29 14:09:37 -05:00
|
|
|
* @return The controller 3.3V rail enabled value. True for enabled.
|
2014-11-10 13:15:33 -05:00
|
|
|
*/
|
|
|
|
|
bool ControllerPower::GetEnabled3V3() {
|
2015-06-25 15:07:55 -04:00
|
|
|
int32_t status = 0;
|
|
|
|
|
bool retVal = getUserActive3V3(&status);
|
|
|
|
|
wpi_setGlobalErrorWithContext(status, getHALErrorMessage(status));
|
|
|
|
|
return retVal;
|
2014-11-10 13:15:33 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2015-06-25 15:07:55 -04:00
|
|
|
* Get the count of the total current faults on the 3.3V rail since the
|
|
|
|
|
* controller has booted
|
2014-11-10 13:15:33 -05:00
|
|
|
* @return The number of faults
|
|
|
|
|
*/
|
|
|
|
|
int ControllerPower::GetFaultCount3V3() {
|
2015-06-25 15:07:55 -04:00
|
|
|
int32_t status = 0;
|
|
|
|
|
int retVal = getUserCurrentFaults3V3(&status);
|
|
|
|
|
wpi_setGlobalErrorWithContext(status, getHALErrorMessage(status));
|
|
|
|
|
return retVal;
|
2014-11-10 13:15:33 -05:00
|
|
|
}
|