WPILibC++ 2027.0.0-alpha-2
Loading...
Searching...
No Matches
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 3V3 rail voltage.
31 *
32 * @param[out] status the error code, or 0 for success
33 * @return the 3V3 rail voltage (volts)
34 */
35double HAL_GetUserVoltage3V3(int32_t* status);
36
37/**
38 * Gets the 3V3 rail current.
39 *
40 * @param[out] status the error code, or 0 for success
41 * @return the 3V3 rail current (amps)
42 */
43double HAL_GetUserCurrent3V3(int32_t* status);
44
45/**
46 * Gets the active state of the 3V3 rail.
47 *
48 * @param[out] status the error code, or 0 for success
49 * @return true if the rail is active, otherwise false
50 */
52
53/**
54 * Gets the fault count for the 3V3 rail. Capped at 255.
55 *
56 * @param[out] status the error code, or 0 for success
57 * @return the number of 3V3 fault counts
58 */
59int32_t HAL_GetUserCurrentFaults3V3(int32_t* status);
60
61/**
62 * Enables or disables the 3V3 rail.
63 *
64 * @param enabled whether the rail should be enabled
65 * @param[out] status the error code, or 0 for success
66 */
67void HAL_SetUserRailEnabled3V3(HAL_Bool enabled, int32_t* status);
68
69/**
70 * Resets the overcurrent fault counters for all user rails to 0.
71 * @param[out] status the error code, or 0 for success
72 */
73void HAL_ResetUserCurrentFaults(int32_t* status);
74
75/**
76 * Get the current brownout voltage setting.
77 *
78 * @param[out] status the error code, or 0 for success
79 * @return The brownout voltage
80 */
81double HAL_GetBrownoutVoltage(int32_t* status);
82
83/**
84 * Set the voltage the roboRIO will brownout and disable all outputs.
85 *
86 * Note that this only does anything on the roboRIO 2.
87 * On the roboRIO it is a no-op.
88 *
89 * @param[in] voltage The brownout voltage
90 * @param[out] status the error code, or 0 for success
91 */
92void HAL_SetBrownoutVoltage(double voltage, int32_t* status);
93
94/**
95 * Get the current CPU temperature in degrees Celsius
96 *
97 * @param[out] status the error code, or 0 for success
98 * @return current CPU temperature in degrees Celsius
99 */
100double HAL_GetCPUTemp(int32_t* status);
101
102#ifdef __cplusplus
103} // extern "C"
104#endif
105/** @} */
void HAL_SetUserRailEnabled3V3(HAL_Bool enabled, int32_t *status)
Enables or disables the 3V3 rail.
double HAL_GetUserVoltage3V3(int32_t *status)
Gets the 3V3 rail voltage.
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.
double HAL_GetBrownoutVoltage(int32_t *status)
Get the current brownout voltage setting.
HAL_Bool HAL_GetUserActive3V3(int32_t *status)
Gets the active state of the 3V3 rail.
void HAL_ResetUserCurrentFaults(int32_t *status)
Resets the overcurrent fault counters for all user rails to 0.
double HAL_GetUserCurrent3V3(int32_t *status)
Gets the 3V3 rail current.
double HAL_GetVinVoltage(int32_t *status)
Gets the roboRIO input 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