| Linduino 1.3.0 Linear Technology Arduino-Compatible Demonstration Board

LT_PMBusDeviceLTM4675.h
Go to the documentation of this file.
1 /*!
2 LTC PSM Device
3
4 @verbatim
5
6 Representation of a device and its capabilities.
7
8 @endverbatim
9
10
11 Copyright 2018(c) Analog Devices, Inc.
12
13 All rights reserved.
14
15 Redistribution and use in source and binary forms, with or without
16 modification, are permitted provided that the following conditions are met:
17 - Redistributions of source code must retain the above copyright
18 notice, this list of conditions and the following disclaimer.
19 - Redistributions in binary form must reproduce the above copyright
20 notice, this list of conditions and the following disclaimer in
21 the documentation and/or other materials provided with the
22 distribution.
23 - Neither the name of Analog Devices, Inc. nor the names of its
24 contributors may be used to endorse or promote products derived
25 from this software without specific prior written permission.
26 - The use of this software may or may not infringe the patent rights
27 of one or more patent holders. This license does not release you
28 from the requirement that you obtain separate licenses from these
29 patent holders to use this software.
30 - Use of the software either in source or binary form, must be run
31 on or directly connected to an Analog Devices Inc. component.
32
33 THIS SOFTWARE IS PROVIDED BY ANALOG DEVICES "AS IS" AND ANY EXPRESS OR
34 IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, NON-INFRINGEMENT,
35 MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
36 IN NO EVENT SHALL ANALOG DEVICES BE LIABLE FOR ANY DIRECT, INDIRECT,
37 INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
38 LIMITED TO, INTELLECTUAL PROPERTY RIGHTS, PROCUREMENT OF SUBSTITUTE GOODS OR
39 SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
40 CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
41 OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
42 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
43 */
44
45 /*! @file
46 @ingroup LT_PMBusDevice
47 Library Header File for LT_PMBusDeviceLTM4675
48 */
49
50 #ifndef LT_PMBusDeviceLTM4675_H_
51 #define LT_PMBusDeviceLTM4675_H_
52
53 #include "LT_PMBusDeviceController.h"
54 #include "../LTPSM_PartFaultLogs/LT_3880FaultLog.h"
55
56 class LT_PMBusDeviceLTM4675 : public LT_PMBusDeviceController
57 {
58 public:
59
60 static uint32_t cap_;
61 /*
62 static class _init
63 {
64 public:
65
66 _init() { cap_ = 0x5555; }
67 } _initializer;
68 */
69 LT_PMBusDeviceLTM4675(LT_PMBus *pmbus, uint8_t address) : LT_PMBusDeviceController(pmbus, address, 2)
70 {
71 }
72
73 uint32_t getCapabilities (
74 )
75 {
76 return cap_;
77 }
78
79 //! Is/are these capability(s) supported?
80 //! @return true if yes
81 bool hasCapability(
82 uint32_t capability //!< List of capabilities
83 )
84 {
85 return (cap_ & capability) == capability;
86 }
87
88 static LT_PMBusDevice *detect(LT_PMBus *pmbus, uint8_t address)
89 {
90 uint16_t id;
91 LT_PMBusDeviceLTM4675 *device;
92
93 id = pmbus->readMfrSpecialId(address);
94 if ( (id & 0xFFF0) == 0x47A0)
95 {
96 if (pmbus->getRailAddress(address) != address)
97 {
98 device = new LT_PMBusDeviceLTM4675(pmbus, address);
99 device->probeSpeed();
100 return device;
101 }
102 else
103 return NULL;
104 }
105 else
106 return NULL;
107 }
108
109 uint8_t getNumPages(void)
110 {
111 return 2;
112 }
113
114 void enableFaultLog()
115 {
116 LT_3880FaultLog *faultLog = new LT_3880FaultLog(pmbus_);
117 faultLog->enableFaultLog(address_);
118 delete faultLog;
119 }
120
121 void disableFaultLog()
122 {
123 LT_3880FaultLog *faultLog = new LT_3880FaultLog(pmbus_);
124 faultLog->disableFaultLog(address_);
125 delete faultLog;
126 }
127
128 bool hasFaultLog()
129 {
130 LT_3880FaultLog *faultLog = new LT_3880FaultLog(pmbus_);
131 if (faultLog->hasFaultLog(address_))
132 {
133 delete faultLog;
134 return true;
135 }
136 else
137 {
138 delete faultLog;
139 return false;
140 }
141 }
142
143 char *getFaultLog()
144 {
145 LT_3880FaultLog *faultLog = new LT_3880FaultLog(pmbus_);
146 if (faultLog->hasFaultLog(address_))
147 {
148 faultLog->read(address_);
149 // faultLog->print(&Serial);
150 faultLog->dumpBinary(&Serial);
151 faultLog->release();
152 delete faultLog;
153 return NULL;
154 }
155 else
156 {
157 delete faultLog;
158 return NULL;
159 }
160 }
161
162 void clearFaultLog()
163 {
164 LT_3880FaultLog *faultLog = new LT_3880FaultLog(pmbus_);
165 if (faultLog->hasFaultLog(address_))
166 {
167 faultLog->clearFaultLog(address_);
168 pmbus_->smbus()->waitForAck(address_, 0x00);
169 pmbus_->waitForNotBusy(address_);
170 delete faultLog;
171 }
172 else
173 {
174 delete faultLog;
175 }
176 }
177 };
178
179 #endif /* LT_PMBusDeviceLTM4675_H_ */
id
static int id
Definition: rail_logger.ino:99
LT_PMBusDeviceLTM4675::getCapabilities
uint32_t getCapabilities()
Get the supported capabilities.
Definition: LT_PMBusDeviceLTM4675.h:73
LT_PMBusDeviceLTM4675::cap_
static uint32_t cap_
Definition: LT_PMBusDeviceLTM4675.h:60
LT_PMBusDevice::address_
uint8_t address_
Definition: LT_PMBusDevice.h:79
LT_3880FaultLog
class that handles LTC3880 fault logs.
Definition: LT_3880FaultLog.h:61
LT_PMBusDevice
Definition: LT_PMBusDevice.h:75
LT_PMBusDeviceLTM4675::disableFaultLog
void disableFaultLog()
Disable the Fault Log.
Definition: LT_PMBusDeviceLTM4675.h:121
LT_PMBusDeviceLTM4675::LT_PMBusDeviceLTM4675
LT_PMBusDeviceLTM4675(LT_PMBus *pmbus, uint8_t address)
Definition: LT_PMBusDeviceLTM4675.h:69
LT_PMBusDevice::pmbus_
LT_PMBus * pmbus_
Definition: LT_PMBusDevice.h:78
LT_PMBusDeviceLTM4675
Definition: LT_PMBusDeviceLTM4675.h:56
address
static uint8_t address
Definition: DC2091A.ino:83
LT_PMBus::waitForNotBusy
uint8_t waitForNotBusy(uint8_t address)
Read MFR_COMMON until not Busy.
Definition: LT_PMBus.cpp:3254
LT_FaultLog::hasFaultLog
bool hasFaultLog(uint8_t address)
Definition: LT_FaultLog.cpp:101
LT_PMBusDeviceController.h
LTC PSM Controller Device.
LT_SMBus::waitForAck
virtual uint8_t waitForAck(uint8_t address, uint8_t command)=0
Read with the address and command in loop until ack, then issue stop.
LT_PMBusDevice::pmbus
LT_PMBus * pmbus()
Definition: LT_PMBusDevice.cpp:70
LT_FaultLog::enableFaultLog
void enableFaultLog(uint8_t address)
Definition: LT_FaultLog.cpp:141
LT_3880FaultLog::dumpBinary
void dumpBinary(Print *printer=0)
Dumps binary of the fault log to a Print inheriting object, or Serial if none specified.
Definition: LT_3880FaultLog.cpp:108
LT_PMBusDeviceLTM4675::getFaultLog
char * getFaultLog()
Get the fault log text (call must free)
Definition: LT_PMBusDeviceLTM4675.h:143
LT_PMBusDeviceLTM4675::getNumPages
uint8_t getNumPages(void)
Definition: LT_PMBusDeviceLTM4675.h:109
LT_3880FaultLog::release
void release()
Frees the memory reserved for the fault log.
Definition: LT_3880FaultLog.cpp:92
LT_PMBus::smbus
LT_SMBus * smbus()
Definition: LT_PMBus.h:401
LT_PMBusDeviceLTM4675::detect
static LT_PMBusDevice * detect(LT_PMBus *pmbus, uint8_t address)
Definition: LT_PMBusDeviceLTM4675.h:88
LT_PMBusDeviceController
Definition: LT_PMBusDeviceController.h:56
LT_PMBusDeviceLTM4675::hasCapability
bool hasCapability(uint32_t capability)
Is/are these capability(s) supported?
Definition: LT_PMBusDeviceLTM4675.h:81
LT_PMBusDevice::probeSpeed
void probeSpeed()
Definition: LT_PMBusDevice.cpp:57
LT_FaultLog::disableFaultLog
void disableFaultLog(uint8_t address)
Definition: LT_FaultLog.cpp:182
LT_3880FaultLog::read
void read(uint8_t address)
Reads the fault log from the specified address, reserves memory to hold the data. ...
Definition: LT_3880FaultLog.cpp:76
LT_PMBus::readMfrSpecialId
uint16_t readMfrSpecialId(uint8_t address)
Get speical ID.
Definition: LT_PMBus.cpp:3361
LT_PMBusDeviceLTM4675::enableFaultLog
void enableFaultLog()
Enable the Fault Log.
Definition: LT_PMBusDeviceLTM4675.h:114
LT_FaultLog::clearFaultLog
void clearFaultLog(uint8_t address)
Definition: LT_FaultLog.cpp:240
LT_PMBusDeviceLTM4675::clearFaultLog
void clearFaultLog()
Clear the Fault Log.
Definition: LT_PMBusDeviceLTM4675.h:162
device
ad5933_dev * device
Definition: CN-0413.ino:67
LT_PMBusDeviceLTM4675::hasFaultLog
bool hasFaultLog()
Is there a fault log?
Definition: LT_PMBusDeviceLTM4675.h:128
LT_PMBus::getRailAddress
uint8_t getRailAddress(uint8_t address)
Get the rail address of a Controller.
Definition: LT_PMBus.cpp:3131
LT_PMBus
PMBus communication.
Definition: LT_PMBus.h:370