Linduino  1.3.0
Linear Technology Arduino-Compatible Demonstration Board
LT_PMBusDevice.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 //! @ingroup PMBus_SMBus
46 //! @{
47 //! @defgroup LT_PMBusDevice LT_PMBusDevice: Implementation of Device Detection and Capability
48 //! @}
49 
50 /*! @file
51  @ingroup LT_PMBusDevice
52  Library Header File for LT_PMBusDevice
53 */
54 
55 #ifndef LT_PMBusDevice_H_
56 #define LT_PMBusDevice_H_
57 
58 #define HAS_VOUT 1 << 0
59 #define HAS_VIN 1 << 1
60 #define HAS_IOUT 1 << 2
61 #define HAS_IIN 1 << 3
62 #define HAS_POUT 1 << 4
63 #define HAS_PIN 1 << 5
64 #define HAS_TEMP 1 << 6
65 #define HAS_DC 1 << 7
66 #define HAS_STATUS_WORD 1 << 14
67 #define HAS_STATUS_EXT 1 << 15
68 
69 
70 #include <stdint.h>
71 #include "LT_PMBus.h"
72 #include "LT_PMBusRail.h"
73 #include "LT_PMBusSpeedTest.h"
74 
76 {
77  protected:
79  uint8_t address_;
80  uint32_t maxSpeed_;
81  uint8_t model_[9];
82 
83  LT_PMBusDevice(LT_PMBus *pmbus, uint8_t address):pmbus_(pmbus), address_(address)
84  {
85  }
86 
87  protected:
88 
89  void probeSpeed();
90 
91 
92  public:
93  virtual ~LT_PMBusDevice() {}
94 
95  LT_PMBus *pmbus();
96 
97  LT_SMBus *smbus();
98 
99  //! Change the pmbus
100  void changePMBus(LT_PMBus *pmbus);
101 
102  //! Get the address
103  //! @return address
104  uint8_t getAddress ();
105 
106  virtual char *getType(void);
107 
108  virtual uint8_t getNumPages(void) = 0;
109 
110  void setPage(uint8_t page);
111 
112  //! Get the maximum speed the device can communicate with
113  //! @return speed
114  uint32_t getMaxSpeed(void);
115 
116  //! Set the speed. If > 100000, enable clock stretching
117  virtual void setSpeed(uint32_t speed); //!< Speed
118 
119  //! Get the supported capabilities
120  //! @return or'd list of capabilities
121  virtual uint32_t getCapabilities () = 0;
122 
123  //! Is/are these capability(s) supported?
124  //! @return true if yes
125  virtual bool hasCapability(
126  uint32_t capability //!< List of capabilities
127  ) = 0;
128 
129 
130  //! Return a list of rails if any page is part of a rail.
131  //! @return A rail, but partially built, and may need merging with other devices. Caller must free memory.
132  virtual LT_PMBusRail **getRails() = 0;
133 
134  //! Enable the Fault Log
135  virtual void enableFaultLog() {}
136 
137  //! Disable the Fault Log
138  virtual void disableFaultLog() {}
139 
140  //! Is there a fault log?
141  //! @return true/false
142  virtual bool hasFaultLog();
143 
144  //! Get the fault log text (call must free)
145  //! @return text
146  virtual char *getFaultLog();
147 
148  //! Clear the Fault Log
149  virtual void clearFaultLog() { }
150 
151  /*
152  * Set the output voltage of a polyphase rail
153  *
154  * voltage: the target voltage
155  */
156  void setVout(float voltage);
157 
158  /*
159  * Read the input voltage of a polyphase rail
160  *
161  * polling: poll if true
162  * return: the input voltage
163  */
164  float readVin(bool polling);
165 
166  /*
167  * Read the output voltage of a polyphase rail
168  *
169  * polling: poll if true
170  * return: the output voltage
171  */
172  float readVout(bool polling);
173 
174  /*
175  * Read the input current of a polyphase rail
176  *
177  * polling: poll if true
178  * return: the input current
179  */
180  float readIin(bool polling);
181 
182  /*
183  * Read the output current of a polyphase rail
184  *
185  * polling: poll if true
186  * return: the output current
187  */
188  float readIout(bool polling);
189 
190  /*
191  * Read the input power of a polyphase rail
192  *
193  * polling: poll if true
194  * return: the output current
195  */
196  float readPin(bool polling);
197 
198  /*
199  * Read the output power of a polyphase rail
200  *
201  * polling: poll if true
202  * return: the output power
203  */
204  float readPout(bool polling);
205 
206  /*
207  * Read the external temperature of a polyphase rail
208  *
209  * polling: poll if true
210  * return: the temperature
211  */
212  float readExternalTemperature(bool polling);
213 
214  /*
215  * Read the internal temperature of a polyphase rail
216  *
217  * polling: poll if true
218  * return: the temperature
219  */
220  float readInternalTemperature(bool polling);
221 
222  /*
223  * Read the average duty cycle of a polyphase rail
224  *
225  * polling: poll if true
226  * return: the duty cycle
227  */
228  float readDutyCycle(bool polling);
229 
230  /*
231  * Read the status word of a polyphase rail
232  *
233  * return: status word
234  */
235  uint16_t readStatusWord();
236 
237  /*
238  * Read the special id of a polyphase rail
239  *
240  * return: special id
241  */
242  uint16_t readMfrSpecialId();
243 
244  /*
245  * Clear faults of polyphase rail
246  */
247  void clearFaults();
248 
249  /*
250  * Margin high polyphase rail
251  */
252  void marginHigh();
253 
254  /*
255  * Margin low polyphase rail
256  *
257  */
258  void marginLow();
259 
260  /*
261  * Margin off polyphase rail
262  *
263  */
264  void marginOff();
265 };
266 
267 #endif /* LT_PMBusDevice_H_ */
virtual LT_PMBusRail ** getRails()=0
Return a list of rails if any page is part of a rail.
uint32_t getMaxSpeed(void)
Get the maximum speed the device can communicate with.
float readPout(bool polling)
uint32_t maxSpeed_
uint8_t getAddress()
Get the address.
virtual void setSpeed(uint32_t speed)
Set the speed. If > 100000, enable clock stretching.
float readVout(bool polling)
uint16_t readStatusWord()
virtual char * getFaultLog()
Get the fault log text (call must free)
virtual void enableFaultLog()
Enable the Fault Log.
LT_PMBus * pmbus_
float readIout(bool polling)
LTC PMBus Support.
void changePMBus(LT_PMBus *pmbus)
Change the pmbus.
virtual char * getType(void)
static uint8_t address
Definition: DC2091A.ino:83
virtual ~LT_PMBusDevice()
float readExternalTemperature(bool polling)
virtual void disableFaultLog()
Disable the Fault Log.
LT_PMBus * pmbus()
uint16_t readMfrSpecialId()
LT_PMBusDevice(LT_PMBus *pmbus, uint8_t address)
virtual uint32_t getCapabilities()=0
Get the supported capabilities.
float readIin(bool polling)
float readInternalTemperature(bool polling)
void setVout(float voltage)
float readVin(bool polling)
virtual uint8_t getNumPages(void)=0
virtual bool hasCapability(uint32_t capability)=0
Is/are these capability(s) supported?
float readDutyCycle(bool polling)
LTC PMBus Support.
uint8_t model_[9]
LTC PSM SpeedTest.
virtual bool hasFaultLog()
Is there a fault log?
static float voltage
Definition: DC2289AA.ino:71
float readPin(bool polling)
void setPage(uint8_t page)
LT_SMBus * smbus()
PMBusRail communication. For Multiphase Rails.
Definition: LT_PMBusRail.h:72
virtual void clearFaultLog()
Clear the Fault Log.
PMBus communication.
Definition: LT_PMBus.h:370