| Linduino 1.3.0 Linear Technology Arduino-Compatible Demonstration Board

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