Linduino  1.3.0
Linear Technology Arduino-Compatible Demonstration Board
LT_2974FaultLog.h
Go to the documentation of this file.
1 /*!
2 LTC SMBus Support: Implementation for a LTC2974 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_2974FaultLog
48  Library Header File for LT_2974FaultLog
49 */
50 
51 #ifndef LT_2974FaultLog_H_
52 #define LT_2974FaultLog_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 LTC2974 fault logs.
60 //! contains structs for interpreting the data read from the part.
62 {
63 
64  public:
65 #pragma pack(push, 1)
66 
67 
68  /********************************************************************
69  * LTC2974 types
70  ********************************************************************/
71 
72  struct ChanStatus
73  {
74  public:
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 Peak16Words
122  {
123  public:
124  struct Lin16Word peak;
125  struct Lin16Word min;
126  };
127 
129  {
130  public:
131  struct Lin5_11Word peak;
132  struct Lin5_11Word min;
133  };
134 
136  {
137  public:
138  struct Peak16Words vout0_peaks;
139  struct Peak5_11Words temp0_peaks;
140  struct Peak5_11Words iout0_peaks;
141 
142  struct Peak5_11Words vin_peaks;
143 
144  struct Peak16Words vout1_peaks;
145  struct Peak5_11Words temp1_peaks;
146  struct Peak5_11Words iout1_peaks;
147 
148  struct Peak16Words vout2_peaks;
149  struct Peak5_11Words temp2_peaks;
150  struct Peak5_11Words iout2_peaks;
151 
152  struct Peak16Words vout3_peaks;
153  struct Peak5_11Words temp3_peaks;
154  struct Peak5_11Words iout3_peaks;
155  };
156 
158  {
159  public:
160  struct ChanStatus chan_status0;
161  struct ChanStatus chan_status1;
162  struct ChanStatus chan_status2;
163  struct ChanStatus chan_status3;
164  };
165 
167  {
168  public:
169  uint8_t position_last;
170  struct FaultLogTimeStamp shared_time;
171  struct FaultLogPeaksLtc2974 peaks;
172  struct FaultLogReadStatusLtc2974 fault_log_status;
173  };
174 
176  {
177  public:
178  struct PoutData pout_data3;
179  struct IoutData iout_data3;
180  struct TempData temp_data3;
181  struct VoutData vout_data3;
182  struct PoutData pout_data2;
183  struct IoutData iout_data2;
184  struct TempData temp_data2;
185  struct VoutData vout_data2;
186  struct PoutData pout_data1;
187  struct IoutData iout_data1;
188  struct TempData temp_data1;
189  struct VoutData vout_data1;
190 
191  struct RawByte reserved;
192 
193  struct VinData vin_data;
194 
195  struct PoutData pout_data0;
196  struct IoutData iout_data0;
197  struct TempData temp_data0;
198  struct VoutData vout_data0;
199 
200  struct Lin5_11WordReverse read_temp2;
201  };
202 
204  {
205  public:
206  struct FaultLogPreambleLtc2974 preamble;
207  uint8_t telemetryData[184];
208  struct FaultLogReadLoopLtc2974 *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
209  uint8_t firstValidByte; //relative to struct. firstValidByte should reference start of telemetryData (71). See datasheet.
210  uint8_t lastValidByte; //lastValidByte should reference end of telemetryData (237). See datasheet.
211 
212  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).
213  };
214 
215 #pragma pack(pop)
216 
217  protected:
219 
220  public:
221  //! Constructor
222  LT_2974FaultLog(LT_PMBus *pmbus //!< pmbus object reference for this fault log handler to use.
223  );
224 
225  //! Pretty prints this part's fault log to a Print inheriting object, or Serial if none specified.
226  void print(Print *printer = 0 //!< Print inheriting object to print the fault log to.
227  );
228 
229  //! Get binary of the fault log or NULL if no log
230  uint8_t *getBinary();
231 
232  //! Get size of binary data
233  uint16_t getBinarySize();
234 
235  //! Dumps binary of the fault log to a Print inheriting object, or Serial if none specified.
236  void dumpBinary(Print *printer = 0 //!< Print inheriting object to print the binary to.
237  );
238 
239  //! Reads the fault log from the specified address, reserves memory to hold the data.
240  //! @return a reference to the data read from the part.
241  void read(uint8_t address //!< the address to read the fault log from.
242  );
243 
244  // ! Get the fault log data
245  struct FaultLogLtc2974 *get()
246  {
247  return faultLog2974;
248  }
249 
250  //! Frees the memory reserved for the fault log.
251  void release();
252 
253  private:
254  char *buffer;
255  Peak16Words **voutPeaks;
256  Peak5_11Words **ioutPeaks;
257  Peak5_11Words **tempPeaks;
258  ChanStatus **chanStatuses;
259  VoutData **voutDatas;
260  IoutData **ioutDatas;
261  PoutData **poutDatas;
262  TempData **tempDatas;
263 
264  void printTitle(Print *);
265  void printTime(Print *);
266  void printPeaks(Print *);
267  void printFastChannel(uint8_t index, Print *);
268  void printAllLoops(Print *);
269  void printLoop(uint8_t index, Print *);
270  void printLoopChannel(uint8_t index, Print *);
271 
272 };
273 
274 #endif /* LT_FaultLog_H_ */
uint16_t getBinarySize()
Get size of binary data.
class that handles LTC2974 fault logs.
FaultLogLtc2974 * faultLog2974
void dumpBinary(Print *printer=0)
Dumps binary of the fault log to a Print inheriting object, or Serial if none specified.
LTC PMBus Support: Implementation for a LTC Controller Fault Log.
static LT_PMBus * pmbus
Definition: DC2875A.ino:82
uint8_t * getBinary()
Get binary of the fault log or NULL if no log.
#define min(a, b)
static uint8_t address
Definition: DC2091A.ino:83
static int16_t pos
struct RawByte status_mfr_specific
void release()
Frees the memory reserved for the fault log.
void read(uint8_t address)
Reads the fault log from the specified address, reserves memory to hold the data. ...
void print(Print *printer=0)
Pretty prints this part&#39;s fault log to a Print inheriting object, or Serial if none specified...
static int index
struct FaultLogReadLoopLtc2974 * loops
LT_2974FaultLog(LT_PMBus *pmbus)
Constructor.
PMBus communication.
Definition: LT_PMBus.h:370