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.
62 {
63 
64  public:
65 #pragma pack(push, 1)
66 
67 
68  /********************************************************************
69  * LTC2975 types
70  ********************************************************************/
71 
72  struct ChanStatus
73  {
74  public:
78  };
79 
80  struct VoutData
81  {
82  public:
83  struct RawByte status_mfr;
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 
141  {
142  public:
143  struct Lin5_11Word peak;
144  struct Lin5_11Word min;
145  };
146 
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 
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 
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 
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 
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:
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_ */
class that handles LTC2975 fault logs.
uint16_t getBinarySize()
Get size of binary data.
FaultLogLtc2975 * faultLog2975
void release()
Frees the memory reserved for the fault log.
uint8_t * getBinary()
Get binary of the fault log or NULL if no log.
LT_2975FaultLog(LT_PMBus *pmbus)
Constructor.
static LT_PMBus * pmbus
Definition: DC2875A.ino:82
void dumpBinary(Print *printer=0)
Dumps binary of the fault log to a Print inheriting object, or Serial if none specified.
#define min(a, b)
static uint8_t address
Definition: DC2091A.ino:83
static int16_t pos
struct RawByte status_mfr_specific
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 FaultLogReadLoopLtc2975 * loops
LTC PMBus Support: Implementation for a LTC Controller Fault Log.
PMBus communication.
Definition: LT_PMBus.h:370