2014-11-10 13:15:33 -05:00
|
|
|
/*----------------------------------------------------------------------------*/
|
2018-01-02 09:20:21 -08:00
|
|
|
/* Copyright (c) 2011-2018 FIRST. All Rights Reserved. */
|
2014-11-10 13:15:33 -05:00
|
|
|
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
2016-01-02 03:02:34 -08:00
|
|
|
/* must be accompanied by the FIRST BSD license file in the root directory of */
|
|
|
|
|
/* the project. */
|
2014-11-10 13:15:33 -05:00
|
|
|
/*----------------------------------------------------------------------------*/
|
|
|
|
|
|
2018-07-20 00:03:45 -07:00
|
|
|
#include "frc/ControllerPower.h"
|
2014-11-10 13:15:33 -05:00
|
|
|
|
|
|
|
|
#include <stdint.h>
|
2016-05-25 22:38:11 -07:00
|
|
|
|
2018-07-20 00:03:45 -07:00
|
|
|
#include <hal/HAL.h>
|
|
|
|
|
#include <hal/Power.h>
|
2017-08-27 00:11:52 -07:00
|
|
|
|
2018-07-20 00:03:45 -07:00
|
|
|
#include "frc/ErrorBase.h"
|
2014-11-10 13:15:33 -05:00
|
|
|
|
2016-11-01 22:33:12 -07:00
|
|
|
using namespace frc;
|
|
|
|
|
|
2016-11-20 07:25:03 -08:00
|
|
|
double ControllerPower::GetInputVoltage() {
|
2015-06-25 15:07:55 -04:00
|
|
|
int32_t status = 0;
|
2016-11-20 07:25:03 -08:00
|
|
|
double retVal = HAL_GetVinVoltage(&status);
|
2016-07-09 00:24:26 -07:00
|
|
|
wpi_setGlobalErrorWithContext(status, HAL_GetErrorMessage(status));
|
2015-06-25 15:07:55 -04:00
|
|
|
return retVal;
|
2014-11-10 13:15:33 -05:00
|
|
|
}
|
|
|
|
|
|
2016-11-20 07:25:03 -08:00
|
|
|
double ControllerPower::GetInputCurrent() {
|
2015-06-25 15:07:55 -04:00
|
|
|
int32_t status = 0;
|
2016-11-20 07:25:03 -08:00
|
|
|
double retVal = HAL_GetVinCurrent(&status);
|
2016-07-09 00:24:26 -07:00
|
|
|
wpi_setGlobalErrorWithContext(status, HAL_GetErrorMessage(status));
|
2015-06-25 15:07:55 -04:00
|
|
|
return retVal;
|
2014-11-10 13:15:33 -05:00
|
|
|
}
|
|
|
|
|
|
2018-05-31 20:47:15 -07:00
|
|
|
double ControllerPower::GetVoltage3V3() {
|
2015-06-25 15:07:55 -04:00
|
|
|
int32_t status = 0;
|
2018-05-31 20:47:15 -07:00
|
|
|
double retVal = HAL_GetUserVoltage3V3(&status);
|
2016-07-09 00:24:26 -07:00
|
|
|
wpi_setGlobalErrorWithContext(status, HAL_GetErrorMessage(status));
|
2015-06-25 15:07:55 -04:00
|
|
|
return retVal;
|
2014-11-10 13:15:33 -05:00
|
|
|
}
|
|
|
|
|
|
2018-05-31 20:47:15 -07:00
|
|
|
double ControllerPower::GetCurrent3V3() {
|
2015-06-25 15:07:55 -04:00
|
|
|
int32_t status = 0;
|
2018-05-31 20:47:15 -07:00
|
|
|
double retVal = HAL_GetUserCurrent3V3(&status);
|
2016-07-09 00:24:26 -07:00
|
|
|
wpi_setGlobalErrorWithContext(status, HAL_GetErrorMessage(status));
|
2015-06-25 15:07:55 -04:00
|
|
|
return retVal;
|
2014-11-10 13:15:33 -05:00
|
|
|
}
|
|
|
|
|
|
2018-05-31 20:47:15 -07:00
|
|
|
bool ControllerPower::GetEnabled3V3() {
|
2015-06-25 15:07:55 -04:00
|
|
|
int32_t status = 0;
|
2018-05-31 20:47:15 -07:00
|
|
|
bool retVal = HAL_GetUserActive3V3(&status);
|
2016-07-09 00:24:26 -07:00
|
|
|
wpi_setGlobalErrorWithContext(status, HAL_GetErrorMessage(status));
|
2015-06-25 15:07:55 -04:00
|
|
|
return retVal;
|
2014-11-10 13:15:33 -05:00
|
|
|
}
|
|
|
|
|
|
2018-05-31 20:47:15 -07:00
|
|
|
int ControllerPower::GetFaultCount3V3() {
|
2015-06-25 15:07:55 -04:00
|
|
|
int32_t status = 0;
|
2018-05-31 20:47:15 -07:00
|
|
|
int retVal = HAL_GetUserCurrentFaults3V3(&status);
|
2016-07-09 00:24:26 -07:00
|
|
|
wpi_setGlobalErrorWithContext(status, HAL_GetErrorMessage(status));
|
2015-06-25 15:07:55 -04:00
|
|
|
return retVal;
|
2014-11-10 13:15:33 -05:00
|
|
|
}
|
|
|
|
|
|
2016-11-20 07:25:03 -08:00
|
|
|
double ControllerPower::GetVoltage5V() {
|
2015-06-25 15:07:55 -04:00
|
|
|
int32_t status = 0;
|
2016-11-20 07:25:03 -08:00
|
|
|
double retVal = HAL_GetUserVoltage5V(&status);
|
2016-07-09 00:24:26 -07:00
|
|
|
wpi_setGlobalErrorWithContext(status, HAL_GetErrorMessage(status));
|
2015-06-25 15:07:55 -04:00
|
|
|
return retVal;
|
2014-11-10 13:15:33 -05:00
|
|
|
}
|
|
|
|
|
|
2016-11-20 07:25:03 -08:00
|
|
|
double ControllerPower::GetCurrent5V() {
|
2015-06-25 15:07:55 -04:00
|
|
|
int32_t status = 0;
|
2016-11-20 07:25:03 -08:00
|
|
|
double retVal = HAL_GetUserCurrent5V(&status);
|
2016-07-09 00:24:26 -07:00
|
|
|
wpi_setGlobalErrorWithContext(status, HAL_GetErrorMessage(status));
|
2015-06-25 15:07:55 -04:00
|
|
|
return retVal;
|
2014-11-10 13:15:33 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool ControllerPower::GetEnabled5V() {
|
2015-06-25 15:07:55 -04:00
|
|
|
int32_t status = 0;
|
2016-07-09 00:24:26 -07:00
|
|
|
bool retVal = HAL_GetUserActive5V(&status);
|
|
|
|
|
wpi_setGlobalErrorWithContext(status, HAL_GetErrorMessage(status));
|
2015-06-25 15:07:55 -04:00
|
|
|
return retVal;
|
2014-11-10 13:15:33 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int ControllerPower::GetFaultCount5V() {
|
2015-06-25 15:07:55 -04:00
|
|
|
int32_t status = 0;
|
2016-07-09 00:24:26 -07:00
|
|
|
int retVal = HAL_GetUserCurrentFaults5V(&status);
|
|
|
|
|
wpi_setGlobalErrorWithContext(status, HAL_GetErrorMessage(status));
|
2015-06-25 15:07:55 -04:00
|
|
|
return retVal;
|
2014-11-10 13:15:33 -05:00
|
|
|
}
|
|
|
|
|
|
2018-05-31 20:47:15 -07:00
|
|
|
double ControllerPower::GetVoltage6V() {
|
2015-06-25 15:07:55 -04:00
|
|
|
int32_t status = 0;
|
2018-05-31 20:47:15 -07:00
|
|
|
double retVal = HAL_GetUserVoltage6V(&status);
|
2016-07-09 00:24:26 -07:00
|
|
|
wpi_setGlobalErrorWithContext(status, HAL_GetErrorMessage(status));
|
2015-06-25 15:07:55 -04:00
|
|
|
return retVal;
|
2014-11-10 13:15:33 -05:00
|
|
|
}
|
|
|
|
|
|
2018-05-31 20:47:15 -07:00
|
|
|
double ControllerPower::GetCurrent6V() {
|
2015-06-25 15:07:55 -04:00
|
|
|
int32_t status = 0;
|
2018-05-31 20:47:15 -07:00
|
|
|
double retVal = HAL_GetUserCurrent6V(&status);
|
2016-07-09 00:24:26 -07:00
|
|
|
wpi_setGlobalErrorWithContext(status, HAL_GetErrorMessage(status));
|
2015-06-25 15:07:55 -04:00
|
|
|
return retVal;
|
2014-11-10 13:15:33 -05:00
|
|
|
}
|
|
|
|
|
|
2018-05-31 20:47:15 -07:00
|
|
|
bool ControllerPower::GetEnabled6V() {
|
2015-06-25 15:07:55 -04:00
|
|
|
int32_t status = 0;
|
2018-05-31 20:47:15 -07:00
|
|
|
bool retVal = HAL_GetUserActive6V(&status);
|
2016-07-09 00:24:26 -07:00
|
|
|
wpi_setGlobalErrorWithContext(status, HAL_GetErrorMessage(status));
|
2015-06-25 15:07:55 -04:00
|
|
|
return retVal;
|
2014-11-10 13:15:33 -05:00
|
|
|
}
|
|
|
|
|
|
2018-05-31 20:47:15 -07:00
|
|
|
int ControllerPower::GetFaultCount6V() {
|
2015-06-25 15:07:55 -04:00
|
|
|
int32_t status = 0;
|
2018-05-31 20:47:15 -07:00
|
|
|
int retVal = HAL_GetUserCurrentFaults6V(&status);
|
2016-07-09 00:24:26 -07:00
|
|
|
wpi_setGlobalErrorWithContext(status, HAL_GetErrorMessage(status));
|
2015-06-25 15:07:55 -04:00
|
|
|
return retVal;
|
2016-05-20 17:30:37 -07:00
|
|
|
}
|