Linduino  1.3.0
Linear Technology Arduino-Compatible Demonstration Board
LT_FaultLog.h
Go to the documentation of this file.
1 /*!
2 LTC PMBus Support: Implementation for a LTC 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_FaultLog
48  Library Header File for LT_FaultLog
49 */
50 
51 #ifndef LT_FaultLog_H_
52 #define LT_FaultLog_H_
53 
54 #include <stdint.h>
55 #include <stdio.h>
56 #include <string.h>
57 #include "LT_SMBus.h"
58 #include "LT_PMBus.h"
59 
60 #define FILE_TEXT_LINE_MAX 256
61 
63 {
64  public:
65 #pragma pack(push, 1)
66 
67  struct Lin16Word
68  {
69  public:
70  uint8_t lo_byte;
71  uint8_t hi_byte;
72  };
73 
75  {
76  public:
77  uint8_t hi_byte;
78  uint8_t lo_byte;
79  };
80 
81  struct Lin5_11Word
82  {
83  public:
84  uint8_t lo_byte;
85  uint8_t hi_byte;
86  };
87 
89  {
90  public:
91  uint8_t hi_byte;
92  uint8_t lo_byte;
93  };
94 
95  struct RawByte
96  {
97  public:
98  uint8_t uint8_tValue;
99  };
100 
101  struct RawWord
102  {
103  public:
104  uint8_t lo_byte;
105  uint8_t hi_byte;
106  };
107 
109  {
110  public:
111  uint8_t hi_byte;
112  uint8_t lo_byte;
113  };
114 
116  {
117  public:
124  };
125 
126 #pragma pack(pop)
127 
128  protected:
130  uint8_t readMfrStatusByte(uint8_t address);
131  uint8_t readMfrFaultLogStatusByte(uint8_t address);
132  public:
134  virtual ~LT_FaultLog() {}
135 
136  bool hasFaultLog(uint8_t address);
137  void enableFaultLog(uint8_t address);
138  void disableFaultLog(uint8_t address);
139  void clearFaultLog(uint8_t address);
140  virtual void read(uint8_t address) = 0;
141  virtual void print(Print *printer) = 0;
142  virtual uint8_t *getBinary() = 0;
143  virtual uint16_t getBinarySize() = 0;
144  virtual void dumpBinary(Print *printer = 0) = 0;
145  virtual void release() = 0;
146 
147  void dumpBin(Print *printer, uint8_t *log, uint8_t size);
148 
149  uint64_t getSharedTime200us(FaultLogTimeStamp time_stamp);
150  float getTimeInMs(FaultLogTimeStamp time_stamp);
151  uint8_t getRawByteVal(RawByte value);
152  uint16_t getRawWordVal(RawWord value);
153  uint16_t getRawWordReverseVal(RawWordReverse value);
154  uint16_t getLin5_11WordVal(Lin5_11Word value);
156  uint16_t getLin16WordVal(Lin16Word value);
158  virtual void getNvmBlock(uint8_t address, uint16_t offset, uint16_t numWords, uint8_t command, uint8_t *data) = 0;
159 };
160 
161 #endif /* LT_FaultLog_H_ */
uint16_t getLin5_11WordReverseVal(Lin5_11WordReverse value)
void dumpBin(Print *printer, uint8_t *log, uint8_t size)
LTC SMBus Support: API for a shared SMBus layer.
virtual void dumpBinary(Print *printer=0)=0
uint16_t getRawWordReverseVal(RawWordReverse value)
uint16_t getLin5_11WordVal(Lin5_11Word value)
LT_FaultLog(LT_PMBus *pmbus)
Definition: LT_FaultLog.cpp:61
static LT_PMBus * pmbus
Definition: DC2875A.ino:82
virtual void read(uint8_t address)=0
LT_PMBus * pmbus_
Definition: LT_FaultLog.h:129
static uint8_t address
Definition: DC2091A.ino:83
union LT_union_int32_4bytes data
Definition: DC2094A.ino:138
uint16_t getLin16WordVal(Lin16Word value)
uint16_t getRawWordVal(RawWord value)
bool hasFaultLog(uint8_t address)
virtual void release()=0
void enableFaultLog(uint8_t address)
uint8_t readMfrFaultLogStatusByte(uint8_t address)
Definition: LT_FaultLog.cpp:86
virtual uint8_t * getBinary()=0
uint64_t getSharedTime200us(FaultLogTimeStamp time_stamp)
virtual void getNvmBlock(uint8_t address, uint16_t offset, uint16_t numWords, uint8_t command, uint8_t *data)=0
uint8_t readMfrStatusByte(uint8_t address)
Definition: LT_FaultLog.cpp:72
virtual ~LT_FaultLog()
Definition: LT_FaultLog.h:134
void disableFaultLog(uint8_t address)
LTC PMBus Support.
uint8_t getRawByteVal(RawByte value)
void clearFaultLog(uint8_t address)
uint16_t getLin16WordReverseVal(Lin16WordReverse value)
float getTimeInMs(FaultLogTimeStamp time_stamp)
virtual uint16_t getBinarySize()=0
virtual void print(Print *printer)=0
PMBus communication.
Definition: LT_PMBus.h:370