Linduino  1.3.0
Linear Technology Arduino-Compatible Demonstration Board
LT_PMBusDeviceLTC3880.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_PMBusDeviceLTC3880
48 */
49 
50 #ifndef LT_PMBusDeviceLTC3880_H_
51 #define LT_PMBusDeviceLTC3880_H_
52 
54 #include "LT_PMBusRail.h"
55 #include "../LTPSM_PartFaultLogs/LT_3880FaultLog.h"
56 
58 {
59  public:
60 
61  static uint32_t cap_;
62 
64  {
65  }
66 
68  {
69  uint16_t id;
70 
72 
73  id = pmbus->readMfrSpecialId(address);
74  if ( (id & 0xFFF0) == 0x4020)
75  {
76  if (pmbus->getRailAddress(address) != address)
77  {
78  device = new LT_PMBusDeviceLTC3880(pmbus, address);
79 
80  device->probeSpeed();
81  return device;
82  }
83  else
84  return NULL;
85  }
86  else
87  return NULL;
88  }
89 
90  uint32_t getCapabilities (
91  )
92  {
93  return cap_;
94  }
95 
96  //! Is/are these capability(s) supported?
97  //! @return true if yes
99  uint32_t capability //!< List of capabilities
100  )
101  {
102  return (cap_ & capability) == capability;
103  }
104 
105 
106  uint8_t getNumPages(void)
107  {
108  return 2;
109  }
110 
112  {
113  LT_3880FaultLog *faultLog = new LT_3880FaultLog(pmbus_);
114  faultLog->enableFaultLog(address_);
115  delete faultLog;
116  }
117 
119  {
120  LT_3880FaultLog *faultLog = new LT_3880FaultLog(pmbus_);
121  faultLog->disableFaultLog(address_);
122  delete faultLog;
123  }
124 
125  bool hasFaultLog()
126  {
127  LT_3880FaultLog *faultLog = new LT_3880FaultLog(pmbus_);
128  if (faultLog->hasFaultLog(address_))
129  {
130  delete faultLog;
131  return true;
132  }
133  else
134  {
135  delete faultLog;
136  return false;
137  }
138  }
139 
140  char *getFaultLog()
141  {
142  LT_3880FaultLog *faultLog = new LT_3880FaultLog(pmbus_);
143  if (faultLog->hasFaultLog(address_))
144  {
145  faultLog->read(address_);
146 // faultLog->print(&Serial);
147  faultLog->dumpBinary(&Serial);
148  faultLog->release();
149  delete faultLog;
150  return NULL;
151  }
152  else
153  {
154  delete faultLog;
155  return NULL;
156  }
157  }
158 
160  {
161  LT_3880FaultLog *faultLog = new LT_3880FaultLog(pmbus_);
162  if (faultLog->hasFaultLog(address_))
163  {
164  faultLog->clearFaultLog(address_);
165  pmbus_->smbus()->waitForAck(address_, 0x00);
167  delete faultLog;
168  }
169  else
170  {
171  delete faultLog;
172  }
173  }
174 };
175 
176 #endif /* LT_PMBusDeviceLTC3880_H_ */
static int id
Definition: rail_logger.ino:99
void disableFaultLog()
Disable the Fault Log.
uint32_t getCapabilities()
Get the supported capabilities.
class that handles LTC3880 fault logs.
LT_PMBus * pmbus_
LTC PMBus Support.
static uint8_t address
Definition: DC2091A.ino:83
char * getFaultLog()
Get the fault log text (call must free)
uint8_t waitForNotBusy(uint8_t address)
Read MFR_COMMON until not Busy.
Definition: LT_PMBus.cpp:3254
bool hasFaultLog(uint8_t address)
LTC PSM Controller Device.
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_PMBus * pmbus()
void enableFaultLog(uint8_t address)
void dumpBinary(Print *printer=0)
Dumps binary of the fault log to a Print inheriting object, or Serial if none specified.
bool hasFaultLog()
Is there a fault log?
LT_PMBusDeviceLTC3880(LT_PMBus *pmbus, uint8_t address)
void release()
Frees the memory reserved for the fault log.
LT_SMBus * smbus()
Definition: LT_PMBus.h:401
void clearFaultLog()
Clear the Fault Log.
static LT_PMBusDevice * detect(LT_PMBus *pmbus, uint8_t address)
bool hasCapability(uint32_t capability)
Is/are these capability(s) supported?
void disableFaultLog(uint8_t address)
void read(uint8_t address)
Reads the fault log from the specified address, reserves memory to hold the data. ...
uint16_t readMfrSpecialId(uint8_t address)
Get speical ID.
Definition: LT_PMBus.cpp:3361
void clearFaultLog(uint8_t address)
ad5933_dev * device
Definition: CN-0413.ino:67
uint8_t getRailAddress(uint8_t address)
Get the rail address of a Controller.
Definition: LT_PMBus.cpp:3131
PMBus communication.
Definition: LT_PMBus.h:370
void enableFaultLog()
Enable the Fault Log.