WPILibC++ 2024.3.2
Power.h
Go to the documentation of this file.
1// Copyright (c) FIRST and other WPILib contributors.
2// Open Source Software; you can modify and/or share it under the terms of
3// the WPILib BSD license file in the root directory of this project.
4
5#pragma once
6
7#include <stdint.h>
8
9#include "hal/Types.h"
10
11/**
12 * @defgroup hal_power Power Functions
13 * @ingroup hal_capi
14 * @{
15 */
16
17#ifdef __cplusplus
18extern "C" {
19#endif
20
21/**
22 * Gets the roboRIO input voltage.
23 *
24 * @param[out] status the error code, or 0 for success
25 * @return the input voltage (volts)
26 */
27double HAL_GetVinVoltage(int32_t* status);
28
29/**
30 * Gets the roboRIO input current.
31 *
32 * @param[out] status the error code, or 0 for success
33 * @return the input current (amps)
34 */
35double HAL_GetVinCurrent(int32_t* status);
36
37/**
38 * Gets the 6V rail voltage.
39 *
40 * @param[out] status the error code, or 0 for success
41 * @return the 6V rail voltage (volts)
42 */
43double HAL_GetUserVoltage6V(int32_t* status);
44
45/**
46 * Gets the 6V rail current.
47 *
48 * @param[out] status the error code, or 0 for success
49 * @return the 6V rail current (amps)
50 */
51double HAL_GetUserCurrent6V(int32_t* status);
52
53/**
54 * Gets the active state of the 6V rail.
55 *
56 * @param[out] status the error code, or 0 for success
57 * @return true if the rail is active, otherwise false
58 */
60
61/**
62 * Gets the fault count for the 6V rail.
63 *
64 * @param[out] status the error code, or 0 for success
65 * @return the number of 6V fault counts
66 */
67int32_t HAL_GetUserCurrentFaults6V(int32_t* status);
68
69/**
70 * Enables or disables the 6V rail.
71 *
72 * @param enabled whether the rail should be enabled
73 * @param[out] status the error code, or 0 for success
74 */
75void HAL_SetUserRailEnabled6V(HAL_Bool enabled, int32_t* status);
76
77/**
78 * Gets the 5V rail voltage.
79 *
80 * @param[out] status the error code, or 0 for success
81 * @return the 5V rail voltage (volts)
82 */
83double HAL_GetUserVoltage5V(int32_t* status);
84
85/**
86 * Gets the 5V rail current.
87 *
88 * @param[out] status the error code, or 0 for success
89 * @return the 5V rail current (amps)
90 */
91double HAL_GetUserCurrent5V(int32_t* status);
92
93/**
94 * Gets the active state of the 5V rail.
95 *
96 * @param[out] status the error code, or 0 for success
97 * @return true if the rail is active, otherwise false
98 */
100
101/**
102 * Gets the fault count for the 5V rail.
103 *
104 * @param[out] status the error code, or 0 for success
105 * @return the number of 5V fault counts
106 */
107int32_t HAL_GetUserCurrentFaults5V(int32_t* status);
108
109/**
110 * Enables or disables the 5V rail.
111 *
112 * @param enabled whether the rail should be enabled
113 * @param[out] status the error code, or 0 for success
114 */
115void HAL_SetUserRailEnabled5V(HAL_Bool enabled, int32_t* status);
116
117/**
118 * Gets the 3V3 rail voltage.
119 *
120 * @param[out] status the error code, or 0 for success
121 * @return the 3V3 rail voltage (volts)
122 */
123double HAL_GetUserVoltage3V3(int32_t* status);
124
125/**
126 * Gets the 3V3 rail current.
127 *
128 * @param[out] status the error code, or 0 for success
129 * @return the 3V3 rail current (amps)
130 */
131double HAL_GetUserCurrent3V3(int32_t* status);
132
133/**
134 * Gets the active state of the 3V3 rail.
135 *
136 * @param[out] status the error code, or 0 for success
137 * @return true if the rail is active, otherwise false
138 */
140
141/**
142 * Gets the fault count for the 3V3 rail.
143 *
144 * @param[out] status the error code, or 0 for success
145 * @return the number of 3V3 fault counts
146 */
147int32_t HAL_GetUserCurrentFaults3V3(int32_t* status);
148
149/**
150 * Enables or disables the 3V3 rail.
151 *
152 * @param enabled whether the rail should be enabled
153 * @param[out] status the error code, or 0 for success
154 */
155void HAL_SetUserRailEnabled3V3(HAL_Bool enabled, int32_t* status);
156
157/**
158 * Get the current brownout voltage setting.
159 *
160 * @param[out] status the error code, or 0 for success
161 * @return The brownout voltage
162 */
163double HAL_GetBrownoutVoltage(int32_t* status);
164
165/**
166 * Set the voltage the roboRIO will brownout and disable all outputs.
167 *
168 * Note that this only does anything on the roboRIO 2.
169 * On the roboRIO it is a no-op.
170 *
171 * @param[in] voltage The brownout voltage
172 * @param[out] status the error code, or 0 for success
173 */
174void HAL_SetBrownoutVoltage(double voltage, int32_t* status);
175
176/**
177 * Get the current CPU temperature in degrees Celsius
178 *
179 * @param[out] status the error code, or 0 for success
180 * @return current CPU temperature in degrees Celsius
181 */
182double HAL_GetCPUTemp(int32_t* status);
183
184#ifdef __cplusplus
185} // extern "C"
186#endif
187/** @} */
int32_t HAL_GetUserCurrentFaults6V(int32_t *status)
Gets the fault count for the 6V rail.
void HAL_SetUserRailEnabled3V3(HAL_Bool enabled, int32_t *status)
Enables or disables the 3V3 rail.
double HAL_GetVinCurrent(int32_t *status)
Gets the roboRIO input current.
double HAL_GetUserVoltage3V3(int32_t *status)
Gets the 3V3 rail voltage.
double HAL_GetUserCurrent6V(int32_t *status)
Gets the 6V rail current.
int32_t HAL_GetUserCurrentFaults3V3(int32_t *status)
Gets the fault count for the 3V3 rail.
double HAL_GetCPUTemp(int32_t *status)
Get the current CPU temperature in degrees Celsius.
HAL_Bool HAL_GetUserActive5V(int32_t *status)
Gets the active state of the 5V rail.
double HAL_GetBrownoutVoltage(int32_t *status)
Get the current brownout voltage setting.
double HAL_GetUserCurrent5V(int32_t *status)
Gets the 5V rail current.
void HAL_SetUserRailEnabled5V(HAL_Bool enabled, int32_t *status)
Enables or disables the 5V rail.
HAL_Bool HAL_GetUserActive3V3(int32_t *status)
Gets the active state of the 3V3 rail.
double HAL_GetUserVoltage5V(int32_t *status)
Gets the 5V rail voltage.
double HAL_GetUserCurrent3V3(int32_t *status)
Gets the 3V3 rail current.
HAL_Bool HAL_GetUserActive6V(int32_t *status)
Gets the active state of the 6V rail.
double HAL_GetVinVoltage(int32_t *status)
Gets the roboRIO input voltage.
int32_t HAL_GetUserCurrentFaults5V(int32_t *status)
Gets the fault count for the 5V rail.
void HAL_SetUserRailEnabled6V(HAL_Bool enabled, int32_t *status)
Enables or disables the 6V rail.
double HAL_GetUserVoltage6V(int32_t *status)
Gets the 6V rail voltage.
void HAL_SetBrownoutVoltage(double voltage, int32_t *status)
Set the voltage the roboRIO will brownout and disable all outputs.
int32_t HAL_Bool
Definition: Types.h:73