| 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
62 class LT_FaultLog
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
74 struct Lin16WordReverse
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
88 struct Lin5_11WordReverse
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
108 struct RawWordReverse
109 {
110 public:
111 uint8_t hi_byte;
112 uint8_t lo_byte;
113 };
114
115 struct FaultLogTimeStamp
116 {
117 public:
118 uint8_t shared_time_byte0;
119 uint8_t shared_time_byte1;
120 uint8_t shared_time_byte2;
121 uint8_t shared_time_byte3;
122 uint8_t shared_time_byte4;
123 uint8_t shared_time_byte5;
124 };
125
126 #pragma pack(pop)
127
128 protected:
129 LT_PMBus *pmbus_;
130 uint8_t readMfrStatusByte(uint8_t address);
131 uint8_t readMfrFaultLogStatusByte(uint8_t address);
132 public:
133 LT_FaultLog(LT_PMBus *pmbus);
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);
155 uint16_t getLin5_11WordReverseVal(Lin5_11WordReverse value);
156 uint16_t getLin16WordVal(Lin16Word value);
157 uint16_t getLin16WordReverseVal(Lin16WordReverse 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_ */
LT_FaultLog::RawWordReverse::lo_byte
uint8_t lo_byte
Definition: LT_FaultLog.h:112
LT_FaultLog::Lin16Word
Definition: LT_FaultLog.h:67
LT_FaultLog::FaultLogTimeStamp::shared_time_byte1
uint8_t shared_time_byte1
Definition: LT_FaultLog.h:119
LT_FaultLog::Lin16WordReverse::hi_byte
uint8_t hi_byte
Definition: LT_FaultLog.h:77
LT_FaultLog::RawByte
Definition: LT_FaultLog.h:95
LT_FaultLog::getLin5_11WordReverseVal
uint16_t getLin5_11WordReverseVal(Lin5_11WordReverse value)
Definition: LT_FaultLog.cpp:291
LT_FaultLog::Lin5_11Word::hi_byte
uint8_t hi_byte
Definition: LT_FaultLog.h:85
LT_FaultLog::Lin5_11WordReverse
Definition: LT_FaultLog.h:88
LT_FaultLog::dumpBin
void dumpBin(Print *printer, uint8_t *log, uint8_t size)
Definition: LT_FaultLog.cpp:217
LT_SMBus.h
LTC SMBus Support: API for a shared SMBus layer.
LT_FaultLog::dumpBinary
virtual void dumpBinary(Print *printer=0)=0
LT_FaultLog::Lin16Word::hi_byte
uint8_t hi_byte
Definition: LT_FaultLog.h:71
LT_FaultLog::getRawWordReverseVal
uint16_t getRawWordReverseVal(RawWordReverse value)
Definition: LT_FaultLog.cpp:279
LT_FaultLog::getLin5_11WordVal
uint16_t getLin5_11WordVal(Lin5_11Word value)
Definition: LT_FaultLog.cpp:285
LT_FaultLog::LT_FaultLog
LT_FaultLog(LT_PMBus *pmbus)
Definition: LT_FaultLog.cpp:61
pmbus
static LT_PMBus * pmbus
Definition: DC2875A.ino:82
LT_FaultLog::read
virtual void read(uint8_t address)=0
LT_FaultLog::RawWord
Definition: LT_FaultLog.h:101
LT_FaultLog::FaultLogTimeStamp
Definition: LT_FaultLog.h:115
LT_FaultLog::Lin16WordReverse::lo_byte
uint8_t lo_byte
Definition: LT_FaultLog.h:78
LT_FaultLog::pmbus_
LT_PMBus * pmbus_
Definition: LT_FaultLog.h:129
address
static uint8_t address
Definition: DC2091A.ino:83
data
union LT_union_int32_4bytes data
Definition: DC2094A.ino:138
LT_FaultLog
Definition: LT_FaultLog.h:62
LT_FaultLog::getLin16WordVal
uint16_t getLin16WordVal(Lin16Word value)
Definition: LT_FaultLog.cpp:297
LT_FaultLog::FaultLogTimeStamp::shared_time_byte2
uint8_t shared_time_byte2
Definition: LT_FaultLog.h:120
LT_FaultLog::getRawWordVal
uint16_t getRawWordVal(RawWord value)
Definition: LT_FaultLog.cpp:273
LT_FaultLog::hasFaultLog
bool hasFaultLog(uint8_t address)
Definition: LT_FaultLog.cpp:101
LT_FaultLog::RawByte::uint8_tValue
uint8_t uint8_tValue
Definition: LT_FaultLog.h:98
LT_FaultLog::release
virtual void release()=0
LT_FaultLog::FaultLogTimeStamp::shared_time_byte3
uint8_t shared_time_byte3
Definition: LT_FaultLog.h:121
LT_FaultLog::enableFaultLog
void enableFaultLog(uint8_t address)
Definition: LT_FaultLog.cpp:141
LT_FaultLog::RawWord::hi_byte
uint8_t hi_byte
Definition: LT_FaultLog.h:105
LT_FaultLog::readMfrFaultLogStatusByte
uint8_t readMfrFaultLogStatusByte(uint8_t address)
Definition: LT_FaultLog.cpp:86
LT_FaultLog::Lin16WordReverse
Definition: LT_FaultLog.h:74
LT_FaultLog::FaultLogTimeStamp::shared_time_byte0
uint8_t shared_time_byte0
Definition: LT_FaultLog.h:118
LT_FaultLog::getBinary
virtual uint8_t * getBinary()=0
LT_FaultLog::RawWord::lo_byte
uint8_t lo_byte
Definition: LT_FaultLog.h:104
LT_FaultLog::getSharedTime200us
uint64_t getSharedTime200us(FaultLogTimeStamp time_stamp)
Definition: LT_FaultLog.cpp:247
LT_FaultLog::Lin5_11Word
Definition: LT_FaultLog.h:81
LT_FaultLog::getNvmBlock
virtual void getNvmBlock(uint8_t address, uint16_t offset, uint16_t numWords, uint8_t command, uint8_t *data)=0
LT_FaultLog::Lin5_11WordReverse::lo_byte
uint8_t lo_byte
Definition: LT_FaultLog.h:92
LT_FaultLog::readMfrStatusByte
uint8_t readMfrStatusByte(uint8_t address)
Definition: LT_FaultLog.cpp:72
LT_FaultLog::RawWordReverse
Definition: LT_FaultLog.h:108
LT_FaultLog::~LT_FaultLog
virtual ~LT_FaultLog()
Definition: LT_FaultLog.h:134
LT_FaultLog::disableFaultLog
void disableFaultLog(uint8_t address)
Definition: LT_FaultLog.cpp:182
LT_FaultLog::Lin5_11Word::lo_byte
uint8_t lo_byte
Definition: LT_FaultLog.h:84
LT_PMBus.h
LTC PMBus Support.
LT_FaultLog::getRawByteVal
uint8_t getRawByteVal(RawByte value)
Definition: LT_FaultLog.cpp:267
LT_FaultLog::clearFaultLog
void clearFaultLog(uint8_t address)
Definition: LT_FaultLog.cpp:240
LT_FaultLog::getLin16WordReverseVal
uint16_t getLin16WordReverseVal(Lin16WordReverse value)
Definition: LT_FaultLog.cpp:303
LT_FaultLog::getTimeInMs
float getTimeInMs(FaultLogTimeStamp time_stamp)
Definition: LT_FaultLog.cpp:260
LT_FaultLog::FaultLogTimeStamp::shared_time_byte5
uint8_t shared_time_byte5
Definition: LT_FaultLog.h:123
LT_FaultLog::Lin16Word::lo_byte
uint8_t lo_byte
Definition: LT_FaultLog.h:70
LT_FaultLog::getBinarySize
virtual uint16_t getBinarySize()=0
LT_FaultLog::Lin5_11WordReverse::hi_byte
uint8_t hi_byte
Definition: LT_FaultLog.h:91
LT_FaultLog::print
virtual void print(Print *printer)=0
LT_FaultLog::RawWordReverse::hi_byte
uint8_t hi_byte
Definition: LT_FaultLog.h:111
LT_FaultLog::FaultLogTimeStamp::shared_time_byte4
uint8_t shared_time_byte4
Definition: LT_FaultLog.h:122
LT_PMBus
PMBus communication.
Definition: LT_PMBus.h:370