CTRE Phoenix C++ 5.36.0-beta-1
Loading...
Searching...
No Matches
CANdleFaults.h
Go to the documentation of this file.
1/* Copyright (C) Cross The Road Electronics 2024 */
2#pragma once
3
4#include <cstdint>
5
6namespace ctre {
7namespace phoenix {
8namespace led{
9
10/**
11 * Faults available to CANdle
12 *
13 * @deprecated This device's Phoenix 5 API is deprecated for removal in the
14 * 2027 season. Users should update to Phoenix 6 firmware and migrate to the
15 * Phoenix 6 API. A migration guide is available at
16 * https://v6.docs.ctr-electronics.com/en/stable/docs/migration/migration-guide/index.html.
17 *
18 * If the Phoenix 5 API must be used for this device, the device must have 22.X
19 * firmware. This firmware is available in Tuner X after selecting Phoenix 5 in
20 * the firmware year dropdown.
21 */
22struct [[deprecated("This device's Phoenix 5 API is deprecated for removal in the 2027 season."
23 "Users should update to Phoenix 6 firmware and migrate to the Phoenix 6 API."
24 "A migration guide is available at https://v6.docs.ctr-electronics.com/en/stable/docs/migration/migration-guide/index.html")]]
26 /**
27 * Device detects hardware failure
28 */
30 /**
31 * API error detected. Make sure API and firmware versions are compatible.
32 */
34 /**
35 * Boot while receiving an enable frame
36 */
38 /**
39 * VBat is under 5V
40 */
42 /**
43 * VBat is over 30V
44 */
46 /**
47 * 5V Line is under 4 V
48 */
50 /**
51 * 5V Line is over 6V
52 */
54 /**
55 * Exceeded output current of 6 amps
56 */
58 /**
59 * Device is over temperature
60 */
62 /**
63 * Output pin is shorted to something
64 */
66
67 /**
68 * @return true if any faults are tripped
69 */
70 bool HasAnyFault() const {
71 return HardwareFault |
72 APIError |
73 BootDuringEnable |
74 VBatTooLow |
75 VBatTooHigh |
76 V5TooLow |
77 V5TooHigh |
78 SoftwareFuse |
79 ThermalFault |
80 ShortCircuit;
81 }
82 /**
83 * @return Current fault list as a bit field
84 */
85 int ToBitfield() const {
86 uint64_t commonFaults = 0;
87 commonFaults |= ShortCircuit ? 1 : 0; commonFaults <<= 1;
88 commonFaults |= ThermalFault ? 1 : 0; commonFaults <<= 1;
89 commonFaults |= SoftwareFuse ? 1 : 0; commonFaults <<= 1;
90 commonFaults |= V5TooLow ? 1 : 0; commonFaults <<= 1;
91 commonFaults |= V5TooHigh ? 1 : 0; commonFaults <<= 1;
92 commonFaults |= VBatTooLow ? 1 : 0; commonFaults <<= 1;
93 commonFaults |= VBatTooHigh ? 1 : 0; commonFaults <<= 1;
94 commonFaults |= BootDuringEnable ? 1 : 0; commonFaults <<= 1;
95 commonFaults |= APIError ? 1 : 0; commonFaults <<= 1;
96 commonFaults |= HardwareFault ? 1 : 0;
97
98 return commonFaults;
99 }
100 void Update(uint64_t bits) {
101 uint64_t mask = 1;
102 HardwareFault = (bits & mask) ? true : false; mask <<= 1;
103 APIError = (bits & mask) ? true : false; mask <<= 1;
104 BootDuringEnable = (bits & mask) ? true : false; mask <<= 1;
105 VBatTooHigh = (bits & mask) ? true : false; mask <<= 1;
106 VBatTooLow = (bits & mask) ? true : false; mask <<= 1;
107 V5TooHigh = (bits & mask) ? true : false; mask <<= 1;
108 V5TooLow = (bits & mask) ? true : false; mask <<= 1;
109 SoftwareFuse = (bits & mask) ? true : false; mask <<= 1;
110 ThermalFault = (bits & mask) ? true : false; mask <<= 1;
111 ShortCircuit = (bits & mask) ? true : false; mask <<= 1;
112 }
113 /**
114 * Updates current fault list with specified bit field of faults
115 *
116 * @param bits bit field of faults to update with
117 */
118 CANdleFaults(int bits) {
119 Update(bits);
120 }
122 Update(0);
123 }
124};
125/**
126 * Faults available to CANdle
127 *
128 * @deprecated This device's Phoenix 5 API is deprecated for removal in the
129 * 2027 season. Users should update to Phoenix 6 firmware and migrate to the
130 * Phoenix 6 API. A migration guide is available at
131 * https://v6.docs.ctr-electronics.com/en/stable/docs/migration/migration-guide/index.html.
132 */
133struct [[deprecated("This device's Phoenix 5 API is deprecated for removal in the 2027 season."
134 "Users should update to Phoenix 6 firmware and migrate to the Phoenix 6 API."
135 "A migration guide is available at https://v6.docs.ctr-electronics.com/en/stable/docs/migration/migration-guide/index.html")]]
137 /**
138 * Device detects hardware failure
139 */
141 /**
142 * API error detected. Make sure API and firmware versions are compatible.
143 */
145 /**
146 * Boot while receiving an enable frame
147 */
149 /**
150 * VBat is under 5V
151 */
153 /**
154 * VBat is over 30V
155 */
157 /**
158 * 5V Line is under 4 V
159 */
161 /**
162 * 5V Line is over 6V
163 */
165 /**
166 * Exceeded output current of 6 amps
167 */
169 /**
170 * Device is over temperature
171 */
173 /**
174 * Output pin is shorted to something
175 */
177
178 /**
179 * @return true if any faults are tripped
180 */
181 bool HasAnyFault() const {
182 return HardwareFault |
183 APIError |
184 BootDuringEnable |
185 VBatTooLow |
186 VBatTooHigh |
187 V5TooLow |
188 V5TooHigh |
189 SoftwareFuse |
190 ThermalFault |
191 ShortCircuit;
192 }
193 /**
194 * @return Current fault list as a bit field
195 */
196 int ToBitfield() const {
197 uint64_t commonFaults = 0;
198 commonFaults |= ShortCircuit ? 1 : 0; commonFaults <<= 1;
199 commonFaults |= ThermalFault ? 1 : 0; commonFaults <<= 1;
200 commonFaults |= SoftwareFuse ? 1 : 0; commonFaults <<= 1;
201 commonFaults |= V5TooLow ? 1 : 0; commonFaults <<= 1;
202 commonFaults |= V5TooHigh ? 1 : 0; commonFaults <<= 1;
203 commonFaults |= VBatTooLow ? 1 : 0; commonFaults <<= 1;
204 commonFaults |= VBatTooHigh ? 1 : 0; commonFaults <<= 1;
205 commonFaults |= BootDuringEnable ? 1 : 0; commonFaults <<= 1;
206 commonFaults |= APIError ? 1 : 0; commonFaults <<= 1;
207 commonFaults |= HardwareFault ? 1 : 0;
208
209 return commonFaults;
210 }
211 void Update(uint64_t bits) {
212 uint64_t mask = 1;
213 HardwareFault = (bits & mask) ? true : false; mask <<= 1;
214 APIError = (bits & mask) ? true : false; mask <<= 1;
215 BootDuringEnable = (bits & mask) ? true : false; mask <<= 1;
216 VBatTooHigh = (bits & mask) ? true : false; mask <<= 1;
217 VBatTooLow = (bits & mask) ? true : false; mask <<= 1;
218 V5TooHigh = (bits & mask) ? true : false; mask <<= 1;
219 V5TooLow = (bits & mask) ? true : false; mask <<= 1;
220 SoftwareFuse = (bits & mask) ? true : false; mask <<= 1;
221 ThermalFault = (bits & mask) ? true : false; mask <<= 1;
222 ShortCircuit = (bits & mask) ? true : false; mask <<= 1;
223 }
224 /**
225 * Updates current fault list with specified bit field of faults
226 *
227 * @param bits bit field of faults to update with
228 */
230 Update(bits);
231 }
233 Update(0);
234 }
235};
236
237} // led
238} // phoenix
239} // ctre
240
WPI Compliant Pigeon class.
Definition PigeonIMU_StickyFaults.h:6
Faults available to CANdle.
Definition CANdleFaults.h:25
bool VBatTooLow
VBat is under 5V.
Definition CANdleFaults.h:41
bool V5TooHigh
5V Line is over 6V
Definition CANdleFaults.h:53
bool V5TooLow
5V Line is under 4 V
Definition CANdleFaults.h:49
bool VBatTooHigh
VBat is over 30V.
Definition CANdleFaults.h:45
int ToBitfield() const
Definition CANdleFaults.h:85
bool BootDuringEnable
Boot while receiving an enable frame.
Definition CANdleFaults.h:37
bool ThermalFault
Device is over temperature.
Definition CANdleFaults.h:61
bool ShortCircuit
Output pin is shorted to something.
Definition CANdleFaults.h:65
bool HasAnyFault() const
Definition CANdleFaults.h:70
bool HardwareFault
Device detects hardware failure.
Definition CANdleFaults.h:29
bool SoftwareFuse
Exceeded output current of 6 amps.
Definition CANdleFaults.h:57
CANdleFaults(int bits)
Updates current fault list with specified bit field of faults.
Definition CANdleFaults.h:118
CANdleFaults()
Definition CANdleFaults.h:121
bool APIError
API error detected.
Definition CANdleFaults.h:33
void Update(uint64_t bits)
Definition CANdleFaults.h:100
Faults available to CANdle.
Definition CANdleFaults.h:136
CANdleStickyFaults(int bits)
Updates current fault list with specified bit field of faults.
Definition CANdleFaults.h:229
bool HasAnyFault() const
Definition CANdleFaults.h:181
int ToBitfield() const
Definition CANdleFaults.h:196
bool HardwareFault
Device detects hardware failure.
Definition CANdleFaults.h:140
bool ThermalFault
Device is over temperature.
Definition CANdleFaults.h:172
bool ShortCircuit
Output pin is shorted to something.
Definition CANdleFaults.h:176
CANdleStickyFaults()
Definition CANdleFaults.h:232
bool VBatTooLow
VBat is under 5V.
Definition CANdleFaults.h:152
void Update(uint64_t bits)
Definition CANdleFaults.h:211
bool APIError
API error detected.
Definition CANdleFaults.h:144
bool SoftwareFuse
Exceeded output current of 6 amps.
Definition CANdleFaults.h:168
bool BootDuringEnable
Boot while receiving an enable frame.
Definition CANdleFaults.h:148
bool V5TooLow
5V Line is under 4 V
Definition CANdleFaults.h:160
bool V5TooHigh
5V Line is over 6V
Definition CANdleFaults.h:164
bool VBatTooHigh
VBat is over 30V.
Definition CANdleFaults.h:156