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.
62 {
63 
64  public:
65 #pragma pack(push, 1)
66 
67 
68  /********************************************************************
69  * LTC2978 types
70  ********************************************************************/
71 
72  struct VoutData
73  {
74  public:
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 
108  {
109  public:
110  struct Lin5_11Word peak;
111  struct Lin5_11Word min;
112  };
113 
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 
130  {
131  public:
132  uint8_t position_last;
133  struct FaultLogTimeStamp shared_time;
134  struct FaultLogPeaksLtc2978 peaks;
135  };
136 
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 
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:
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_ */
struct Lin16WordReverse read_vout
class that handles LTC2978 fault logs.
void read(uint8_t address)
Reads the fault log from the specified address, reserves memory to hold the data. ...
LTC PMBus Support: Implementation for a LTC Controller Fault Log.
void dumpBinary(Print *printer=0)
Dumps binary of the fault log to a Print inheriting object, or Serial if none specified.
void print(Print *printer=0)
Pretty prints this part&#39;s fault log to a Print inheriting object, or Serial if none specified...
void release()
Frees the memory reserved for the fault log.
static LT_PMBus * pmbus
Definition: DC2875A.ino:82
#define min(a, b)
uint8_t * getBinary()
Get binary of the fault log or NULL if no log.
static uint8_t address
Definition: DC2091A.ino:83
static int16_t pos
LT_2978FaultLog(LT_PMBus *pmbus)
Constructor.
static int index
struct FaultLogReadLoopLtc2978 * loops
FaultLogLtc2978 * faultLog2978
uint16_t getBinarySize()
Get size of binary data.
PMBus communication.
Definition: LT_PMBus.h:370