| Linduino 1.3.0 Linear Technology Arduino-Compatible Demonstration Board

LT_2977FaultLog.h
Go to the documentation of this file.
1 /*!
2 LTC SMBus Support: Implementation for a LTC2977 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_2977FaultLog
48 Library Header File for LT_2977FaultLog
49 */
50
51 #ifndef LT_2977FaultLog_H_
52 #define LT_2977FaultLog_H_
53
54 #include "../LT_PMBUS/LT_PMBus.h"
55 #include "../LT_PMBUS/LT_PMBusMath.h"
56 #include "LT_CommandPlusFaultLog.h"
57
58 //! class that handles LTC2977 fault logs.
59 //! contains structs for interpreting the data read from the part.
60 class LT_2977FaultLog : public LT_CommandPlusFaultLog
61 {
62
63 public:
64 #pragma pack(push, 1)
65
66
67 /********************************************************************
68 * LTC2977 types
69 ********************************************************************/
70
71 struct ChanStatus
72 {
73 public:
74 struct RawByte status_vout;
75 struct RawByte status_mfr;
76 struct RawByte mfr_status2;
77 };
78
79 struct VoutData
80 {
81 public:
82 struct RawByte mfr_status2;
83 struct RawByte status_mfr;
84 struct RawByte status_vout;
85 struct Lin16WordReverse read_vout;
86 };
87
88 struct TempStatus
89 {
90 public:
91 struct RawByte status_temp;
92 };
93
94 struct TempData
95 {
96 public:
97 struct RawByte status_temp;
98 struct Lin5_11WordReverse temp;
99 };
100
101 struct VinStatus
102 {
103 public:
104 struct RawByte status_vin;
105 };
106
107 struct VinData
108 {
109 public:
110 struct RawByte status_vin;
111 struct Lin5_11WordReverse vin;
112 };
113
114 struct Peak16Words
115 {
116 public:
117 struct Lin16Word peak;
118 struct Lin16Word min;
119 };
120
121 struct Peak5_11Words
122 {
123 public:
124 struct Lin5_11Word peak;
125 struct Lin5_11Word min;
126 };
127
128 struct FaultLogPeaksLtc2977
129 {
130 public:
131 struct Peak16Words vout0_peaks;
132 struct Peak16Words vout1_peaks;
133 struct Peak5_11Words vin_peaks;
134 struct Peak16Words vout2_peaks;
135 struct Peak16Words vout3_peaks;
136 struct Peak5_11Words temp_peaks;
137 struct Peak16Words vout4_peaks;
138 struct Peak16Words vout5_peaks;
139 struct Peak16Words vout6_peaks;
140 struct Peak16Words vout7_peaks;
141 };
142
143 struct FaultLogReadStatusLtc2977
144 {
145 public:
146 struct ChanStatus chan_status0;
147 struct ChanStatus chan_status1;
148 struct ChanStatus chan_status2;
149 struct ChanStatus chan_status3;
150 struct ChanStatus chan_status4;
151 struct ChanStatus chan_status5;
152 struct ChanStatus chan_status6;
153 struct ChanStatus chan_status7;
154 };
155
156 struct FaultLogPreambleLtc2977
157 {
158 public:
159 uint8_t position_last;
160 uint8_t cyclic_data_count;
161 struct LT_FaultLog::FaultLogTimeStamp shared_time;
162 struct FaultLogPeaksLtc2977 peaks;
163 struct FaultLogReadStatusLtc2977 fault_log_status;
164 };
165
166 struct FaultLogReadLoopLtc2977
167 {
168 public:
169 struct VoutData vout_data7;
170 struct VoutData vout_data6;
171 struct VoutData vout_data5;
172 struct VoutData vout_data4;
173 struct TempData temp_data;
174 struct VoutData vout_data3;
175 struct VoutData vout_data2;
176 struct VinData vin_data;
177 struct VoutData vout_data1;
178 struct VoutData vout_data0;
179 };
180
181 struct FaultLogLtc2977
182 {
183 public:
184 struct FaultLogPreambleLtc2977 preamble;
185 uint8_t telemetryData[208]; // 208 = 255 - 47
186 struct FaultLogReadLoopLtc2977 *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
187 uint8_t firstValidByte; //relative to struct. firstValidByte should reference start of telemetryData (72). See datasheet.
188 uint8_t lastValidByte; //lastValidByte based on cyclic_data_count. See datasheet.
189
190 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).
191 };
192
193 #pragma pack(pop)
194
195 protected:
196 FaultLogLtc2977 *faultLog2977;
197
198 public:
199 //! Constructor
200 LT_2977FaultLog(LT_PMBus *pmbus //!< pmbus object reference for this fault log handler to use.
201 );
202
203 //! Pretty prints this part's fault log to a Print inheriting object, or Serial if none specified.
204 void print(Print *printer = 0 //!< Print inheriting object to print the fault log to.
205 );
206
207 //! Get binary of the fault log or NULL if no log
208 uint8_t *getBinary();
209
210 //! Get size of binary data
211 uint16_t getBinarySize();
212
213 //! Dumps binary of the fault log to a Print inheriting object, or Serial if none specified.
214 void dumpBinary(Print *printer = 0 //!< Print inheriting object to print the binary to.
215 );
216
217 //! Reads the fault log from the specified address, reserves memory to hold the data.
218 //! @return a reference to the data read from the part.
219 void read(uint8_t address //!< the address to read the fault log from.
220 );
221
222 // ! Get the fault log data
223 struct FaultLogLtc2977 *get()
224 {
225 return faultLog2977;
226 }
227
228 //! Frees the memory reserved for the fault log.
229 void release();
230
231 private:
232 char *buffer;
233 Peak16Words **voutPeaks;
234 ChanStatus **chanStatuses;
235 VoutData **voutDatas;
236
237 void printTitle(Print *);
238 void printTime(Print *);
239 void printPeaks(Print *);
240 void printFastChannel(uint8_t index, Print *);
241 void printAllLoops(Print *);
242 void printLoop(uint8_t index, Print *);
243 void printLoopChannel(uint8_t index, Print *);
244
245 };
246
247 #endif /* LT_FaultLog_H_ */
LT_2977FaultLog::ChanStatus::status_mfr
struct RawByte status_mfr
Definition: LT_2977FaultLog.h:75
LT_2977FaultLog::TempData
Definition: LT_2977FaultLog.h:94
LT_FaultLog::Lin16Word
Definition: LT_FaultLog.h:67
LT_2977FaultLog::FaultLogLtc2977
Definition: LT_2977FaultLog.h:181
LT_FaultLog::RawByte
Definition: LT_FaultLog.h:95
LT_2977FaultLog
class that handles LTC2977 fault logs.
Definition: LT_2977FaultLog.h:60
LT_2977FaultLog::FaultLogLtc2977::firstValidByte
uint8_t firstValidByte
Definition: LT_2977FaultLog.h:187
LT_FaultLog::Lin5_11WordReverse
Definition: LT_FaultLog.h:88
LT_2977FaultLog::FaultLogLtc2977::lastValidByte
uint8_t lastValidByte
Definition: LT_2977FaultLog.h:188
LT_2977FaultLog::dumpBinary
void dumpBinary(Print *printer=0)
Dumps binary of the fault log to a Print inheriting object, or Serial if none specified.
Definition: LT_2977FaultLog.cpp:135
pmbus
static LT_PMBus * pmbus
Definition: DC2875A.ino:82
LT_FaultLog::FaultLogTimeStamp
Definition: LT_FaultLog.h:115
min
#define min(a, b)
Definition: Adafruit_GFX.cpp:66
LT_2977FaultLog::read
void read(uint8_t address)
Reads the fault log from the specified address, reserves memory to hold the data. ...
Definition: LT_2977FaultLog.cpp:83
address
static uint8_t address
Definition: DC2091A.ino:83
pos
static int16_t pos
Definition: Precision_Voltage_Source.ino:73
LT_2977FaultLog::TempStatus
Definition: LT_2977FaultLog.h:88
LT_2977FaultLog::FaultLogPreambleLtc2977
Definition: LT_2977FaultLog.h:156
LT_2977FaultLog::getBinary
uint8_t * getBinary()
Get binary of the fault log or NULL if no log.
Definition: LT_2977FaultLog.cpp:125
LT_2977FaultLog::FaultLogPreambleLtc2977::position_last
uint8_t position_last
Definition: LT_2977FaultLog.h:159
LT_2977FaultLog::ChanStatus::mfr_status2
struct RawByte mfr_status2
Definition: LT_2977FaultLog.h:76
LT_FaultLog::Lin16WordReverse
Definition: LT_FaultLog.h:74
LT_2977FaultLog::ChanStatus::status_vout
struct RawByte status_vout
Definition: LT_2977FaultLog.h:74
LT_2977FaultLog::FaultLogReadLoopLtc2977
Definition: LT_2977FaultLog.h:166
LT_2977FaultLog::FaultLogPreambleLtc2977::cyclic_data_count
uint8_t cyclic_data_count
Definition: LT_2977FaultLog.h:160
LT_2977FaultLog::FaultLogPeaksLtc2977
Definition: LT_2977FaultLog.h:128
LT_2977FaultLog::VinData
Definition: LT_2977FaultLog.h:107
LT_2977FaultLog::FaultLogReadStatusLtc2977
Definition: LT_2977FaultLog.h:143
LT_2977FaultLog::ChanStatus
Definition: LT_2977FaultLog.h:71
LT_2977FaultLog::FaultLogLtc2977::loops
struct FaultLogReadLoopLtc2977 * loops
Definition: LT_2977FaultLog.h:186
LT_FaultLog::Lin5_11Word
Definition: LT_FaultLog.h:81
LT_2977FaultLog::Peak5_11Words
Definition: LT_2977FaultLog.h:121
LT_2977FaultLog::VinStatus
Definition: LT_2977FaultLog.h:101
LT_2977FaultLog::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_2977FaultLog.cpp:140
index
static int index
Definition: device_logger.ino:91
LT_2977FaultLog::VoutData
Definition: LT_2977FaultLog.h:79
LT_2977FaultLog::LT_2977FaultLog
LT_2977FaultLog(LT_PMBus *pmbus)
Constructor.
Definition: LT_2977FaultLog.cpp:61
LT_CommandPlusFaultLog.h
LTC PMBus Support: Implementation for a LTC Controller Fault Log.
LT_2977FaultLog::release
void release()
Frees the memory reserved for the fault log.
Definition: LT_2977FaultLog.cpp:119
LT_2977FaultLog::getBinarySize
uint16_t getBinarySize()
Get size of binary data.
Definition: LT_2977FaultLog.cpp:130
LT_2977FaultLog::Peak16Words
Definition: LT_2977FaultLog.h:114
LT_CommandPlusFaultLog
Definition: LT_CommandPlusFaultLog.h:57
LT_2977FaultLog::faultLog2977
FaultLogLtc2977 * faultLog2977
Definition: LT_2977FaultLog.h:196
LT_PMBus
PMBus communication.
Definition: LT_PMBus.h:370