| Linduino 1.3.0 Linear Technology Arduino-Compatible Demonstration Board

LT_2975FaultLog.h
Go to the documentation of this file.
1 /*!
2 LTC SMBus Support: Implementation for a LTC2975 Fault Log
3
4 @verbatim
5
6 This API is shared with Linduino and RTOS code. End users should code to this
7 API to enable use of the PMBus code without modifications.
8
9 @endverbatim
10
11
12 Copyright 2018(c) Analog Devices, Inc.
13
14 All rights reserved.
15
16 Redistribution and use in source and binary forms, with or without
17 modification, are permitted provided that the following conditions are met:
18 - Redistributions of source code must retain the above copyright
19 notice, this list of conditions and the following disclaimer.
20 - Redistributions in binary form must reproduce the above copyright
21 notice, this list of conditions and the following disclaimer in
22 the documentation and/or other materials provided with the
23 distribution.
24 - Neither the name of Analog Devices, Inc. nor the names of its
25 contributors may be used to endorse or promote products derived
26 from this software without specific prior written permission.
27 - The use of this software may or may not infringe the patent rights
28 of one or more patent holders. This license does not release you
29 from the requirement that you obtain separate licenses from these
30 patent holders to use this software.
31 - Use of the software either in source or binary form, must be run
32 on or directly connected to an Analog Devices Inc. component.
33
34 THIS SOFTWARE IS PROVIDED BY ANALOG DEVICES "AS IS" AND ANY EXPRESS OR
35 IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, NON-INFRINGEMENT,
36 MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
37 IN NO EVENT SHALL ANALOG DEVICES BE LIABLE FOR ANY DIRECT, INDIRECT,
38 INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
39 LIMITED TO, INTELLECTUAL PROPERTY RIGHTS, PROCUREMENT OF SUBSTITUTE GOODS OR
40 SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
41 CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
42 OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
43 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
44 */
45
46 /*! @file
47 @ingroup LT_2975FaultLog
48 Library Header File for LT_2975FaultLog
49 */
50
51 #ifndef LT_2975FaultLog_H_
52 #define LT_2975FaultLog_H_
53
54 #include "../LT_PMBUS/LT_PMBus.h"
55 #include "../LT_PMBUS/LT_PMBusMath.h"
56 #include "LT_CommandPlusFaultLog.h"
57
58
59 //! class that handles LTC2975 fault logs.
60 //! contains structs for interpreting the data read from the part.
61 class LT_2975FaultLog : public LT_CommandPlusFaultLog
62 {
63
64 public:
65 #pragma pack(push, 1)
66
67
68 /********************************************************************
69 * LTC2975 types
70 ********************************************************************/
71
72 struct ChanStatus
73 {
74 public:
75 struct RawByte status_vout;
76 struct RawByte status_iout;
77 struct RawByte status_mfr_specific;
78 };
79
80 struct VoutData
81 {
82 public:
83 struct RawByte status_mfr;
84 struct RawByte status_vout;
85 struct Lin16WordReverse read_vout;
86 };
87
88 struct IoutData
89 {
90 public:
91 struct Lin5_11WordReverse read_iout;
92 struct RawByte status_iout;
93 };
94
95 struct PoutData
96 {
97 public:
98 struct Lin5_11WordReverse read_pout;
99 };
100
101 struct TempData
102 {
103 public:
104 struct RawByte status_temp;
105 struct Lin5_11WordReverse read_temp1;
106 };
107
108 struct VinStatus
109 {
110 public:
111 struct RawByte status_vin;
112 };
113
114 struct VinData
115 {
116 public:
117 struct RawByte status_vin;
118 struct Lin5_11WordReverse vin;
119 };
120
121 struct IinData
122 {
123 public:
124 struct Lin5_11WordReverse read_iin;
125 };
126
127 struct PinData
128 {
129 public:
130 struct Lin5_11WordReverse read_pin;
131 };
132
133 struct Peak16Words
134 {
135 public:
136 struct Lin16Word peak;
137 struct Lin16Word min;
138 };
139
140 struct Peak5_11Words
141 {
142 public:
143 struct Lin5_11Word peak;
144 struct Lin5_11Word min;
145 };
146
147 struct FaultLogPeaksLtc2975
148 {
149 public:
150 struct Peak16Words vout0_peaks;
151 struct Peak5_11Words temp0_peaks;
152 struct Peak5_11Words iout0_peaks;
153
154 struct Peak5_11Words vin_peaks;
155 struct Peak5_11Words iin_peaks;
156 struct Peak5_11Words pin_peaks;
157
158 struct Peak16Words vout1_peaks;
159 struct Peak5_11Words temp1_peaks;
160 struct Peak5_11Words iout1_peaks;
161
162 struct Peak16Words vout2_peaks;
163 struct Peak5_11Words temp2_peaks;
164 struct Peak5_11Words iout2_peaks;
165
166 struct Peak16Words vout3_peaks;
167 struct Peak5_11Words temp3_peaks;
168 struct Peak5_11Words iout3_peaks;
169 };
170
171 struct FaultLogReadStatusLtc2975
172 {
173 public:
174 struct ChanStatus chan_status0;
175 struct ChanStatus chan_status1;
176 struct ChanStatus chan_status2;
177 struct ChanStatus chan_status3;
178 };
179
180 struct FaultLogPreambleLtc2975
181 {
182 public:
183 uint8_t position_last;
184 struct FaultLogTimeStamp shared_time;
185 struct FaultLogPeaksLtc2975 peaks;
186 struct FaultLogReadStatusLtc2975 fault_log_status;
187 };
188
189 struct FaultLogReadLoopLtc2975
190 {
191 public:
192 struct PoutData pout_data3;
193 struct IoutData iout_data3;
194 struct TempData temp_data3;
195 struct VoutData vout_data3;
196 struct PoutData pout_data2;
197 struct IoutData iout_data2;
198 struct TempData temp_data2;
199 struct VoutData vout_data2;
200 struct PoutData pout_data1;
201 struct IoutData iout_data1;
202 struct TempData temp_data1;
203 struct VoutData vout_data1;
204
205 struct PinData pin_data;
206 struct IinData iin_data;
207
208 struct RawByte reserved;
209
210 struct VinData vin_data;
211
212 struct PoutData pout_data0;
213 struct IoutData iout_data0;
214 struct TempData temp_data0;
215 struct VoutData vout_data0;
216
217 struct Lin5_11WordReverse read_temp2;
218 };
219
220 struct FaultLogLtc2975
221 {
222 public:
223 struct FaultLogPreambleLtc2975 preamble;
224 uint8_t telemetryData[176]; // 176 = 255 - 79
225 struct FaultLogReadLoopLtc2975 *loops; //loops[0] - loops[4]; lays over telemetry data based on Fault-Log Pointer; 0, 3 have potential for invalid/phantom data; 4 necessarily contains some or all invalid/phantom data; based on following valid byte pointers
226 uint8_t firstValidByte; //relative to struct. firstValidByte should reference start of telemetryData (71). See datasheet.
227 uint8_t lastValidByte; //lastValidByte should reference end of telemetryData (237). See datasheet.
228
229 bool isValidData(void *pos, uint8_t size = 2); //helper function to identify loop data in valid locations. Pass in the pointer to the data, and size of the data (length in bytes).
230 };
231
232 #pragma pack(pop)
233
234 protected:
235 FaultLogLtc2975 *faultLog2975;
236
237 public:
238 //! Constructor
239 LT_2975FaultLog(LT_PMBus *pmbus //!< pmbus object reference for this fault log handler to use.
240 );
241
242 //! Pretty prints this part's fault log to a Print inheriting object, or Serial if none specified.
243 void print(Print *printer = 0 //!< Print inheriting object to print the fault log to.
244 );
245
246 //! Get binary of the fault log or NULL if no log
247 uint8_t *getBinary();
248
249 //! Get size of binary data
250 uint16_t getBinarySize();
251
252 //! Dumps binary of the fault log to a Print inheriting object, or Serial if none specified.
253 void dumpBinary(Print *printer = 0 //!< Print inheriting object to print the binary to.
254 );
255
256 //! Reads the fault log from the specified address, reserves memory to hold the data.
257 //! @return a reference to the data read from the part.
258 void read(uint8_t address //!< the address to read the fault log from.
259 );
260
261 // ! Get the fault log data
262 struct FaultLogLtc2975 *get()
263 {
264 return faultLog2975;
265 }
266
267 //! Frees the memory reserved for the fault log.
268 void release();
269
270 private:
271 char *buffer;
272 Peak16Words **voutPeaks;
273 Peak5_11Words **ioutPeaks;
274 Peak5_11Words **tempPeaks;
275 ChanStatus **chanStatuses;
276 VoutData **voutDatas;
277 IoutData **ioutDatas;
278 PoutData **poutDatas;
279 TempData **tempDatas;
280
281 void printTitle(Print *);
282 void printTime(Print *);
283 void printPeaks(Print *);
284 void printFastChannel(uint8_t index, Print *);
285 void printAllLoops(Print *);
286 void printLoop(uint8_t index, Print *);
287 void printLoopChannel(uint8_t index, Print *);
288
289 };
290
291 #endif /* LT_FaultLog_H_ */
LT_2975FaultLog::TempData
Definition: LT_2975FaultLog.h:101
LT_FaultLog::Lin16Word
Definition: LT_FaultLog.h:67
LT_2975FaultLog::FaultLogPreambleLtc2975::position_last
uint8_t position_last
Definition: LT_2975FaultLog.h:183
LT_2975FaultLog::FaultLogPeaksLtc2975
Definition: LT_2975FaultLog.h:147
LT_2975FaultLog::FaultLogPreambleLtc2975
Definition: LT_2975FaultLog.h:180
LT_FaultLog::RawByte
Definition: LT_FaultLog.h:95
LT_FaultLog::Lin5_11WordReverse
Definition: LT_FaultLog.h:88
LT_2975FaultLog
class that handles LTC2975 fault logs.
Definition: LT_2975FaultLog.h:61
LT_2975FaultLog::FaultLogLtc2975::firstValidByte
uint8_t firstValidByte
Definition: LT_2975FaultLog.h:226
LT_2975FaultLog::IoutData
Definition: LT_2975FaultLog.h:88
LT_2975FaultLog::FaultLogReadLoopLtc2975
Definition: LT_2975FaultLog.h:189
LT_2975FaultLog::getBinarySize
uint16_t getBinarySize()
Get size of binary data.
Definition: LT_2975FaultLog.cpp:132
LT_2975FaultLog::faultLog2975
FaultLogLtc2975 * faultLog2975
Definition: LT_2975FaultLog.h:235
LT_2975FaultLog::release
void release()
Frees the memory reserved for the fault log.
Definition: LT_2975FaultLog.cpp:121
LT_2975FaultLog::FaultLogLtc2975
Definition: LT_2975FaultLog.h:220
LT_2975FaultLog::getBinary
uint8_t * getBinary()
Get binary of the fault log or NULL if no log.
Definition: LT_2975FaultLog.cpp:127
LT_2975FaultLog::LT_2975FaultLog
LT_2975FaultLog(LT_PMBus *pmbus)
Constructor.
Definition: LT_2975FaultLog.cpp:61
pmbus
static LT_PMBus * pmbus
Definition: DC2875A.ino:82
LT_2975FaultLog::dumpBinary
void dumpBinary(Print *printer=0)
Dumps binary of the fault log to a Print inheriting object, or Serial if none specified.
Definition: LT_2975FaultLog.cpp:137
min
#define min(a, b)
Definition: Adafruit_GFX.cpp:66
address
static uint8_t address
Definition: DC2091A.ino:83
pos
static int16_t pos
Definition: Precision_Voltage_Source.ino:73
LT_2975FaultLog::VinData
Definition: LT_2975FaultLog.h:114
LT_FaultLog::Lin16WordReverse
Definition: LT_FaultLog.h:74
LT_2975FaultLog::ChanStatus::status_mfr_specific
struct RawByte status_mfr_specific
Definition: LT_2975FaultLog.h:77
LT_2975FaultLog::read
void read(uint8_t address)
Reads the fault log from the specified address, reserves memory to hold the data. ...
Definition: LT_2975FaultLog.cpp:88
LT_2975FaultLog::VinStatus
Definition: LT_2975FaultLog.h:108
LT_FaultLog::Lin5_11Word
Definition: LT_FaultLog.h:81
LT_2975FaultLog::FaultLogLtc2975::lastValidByte
uint8_t lastValidByte
Definition: LT_2975FaultLog.h:227
LT_2975FaultLog::print
void print(Print *printer=0)
Pretty prints this part&#39;s fault log to a Print inheriting object, or Serial if none specified...
Definition: LT_2975FaultLog.cpp:142
LT_2975FaultLog::Peak5_11Words
Definition: LT_2975FaultLog.h:140
LT_2975FaultLog::ChanStatus::status_vout
struct RawByte status_vout
Definition: LT_2975FaultLog.h:75
index
static int index
Definition: device_logger.ino:91
LT_2975FaultLog::VoutData
Definition: LT_2975FaultLog.h:80
LT_2975FaultLog::FaultLogLtc2975::loops
struct FaultLogReadLoopLtc2975 * loops
Definition: LT_2975FaultLog.h:225
LT_2975FaultLog::Peak16Words
Definition: LT_2975FaultLog.h:133
LT_2975FaultLog::ChanStatus
Definition: LT_2975FaultLog.h:72
LT_2975FaultLog::PinData
Definition: LT_2975FaultLog.h:127
LT_2975FaultLog::PoutData
Definition: LT_2975FaultLog.h:95
LT_CommandPlusFaultLog.h
LTC PMBus Support: Implementation for a LTC Controller Fault Log.
LT_2975FaultLog::IinData
Definition: LT_2975FaultLog.h:121
LT_2975FaultLog::ChanStatus::status_iout
struct RawByte status_iout
Definition: LT_2975FaultLog.h:76
LT_CommandPlusFaultLog
Definition: LT_CommandPlusFaultLog.h:57
LT_2975FaultLog::FaultLogReadStatusLtc2975
Definition: LT_2975FaultLog.h:171
LT_PMBus
PMBus communication.
Definition: LT_PMBus.h:370