Linduino  1.3.0
Linear Technology Arduino-Compatible Demonstration Board
LT_PMBusDeviceManager.h
Go to the documentation of this file.
1 /*!
2 LTC PSM Manager 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_PMBusDeviceController
48 */
49 
50 #ifndef LT_PMBusDeviceManager_H_
51 #define LT_PMBusDeviceManager_H_
52 
53 #include "LT_PMBusDevice.h"
54 #include "LT_PMBusRail.h"
55 
57 {
58  private:
59  uint8_t no_pages_;
60 
61  public:
62 
63  LT_PMBusDeviceManager(LT_PMBus *pmbus, uint8_t address, uint8_t no_pages) : LT_PMBusDevice(pmbus, address), no_pages_(no_pages) {}
64 
65  void setSpeed(uint32_t speed)
66  {
67  pmbus_->smbus()->i2cbus()->changeSpeed(speed);
68  }
69 
71  {
72  LT_PMBusRail **rails = NULL;
73  tRailDef **railDef = NULL;
74  uint8_t i;
75  rails = (LT_PMBusRail **) malloc((no_pages_ + 1) * sizeof(LT_PMBusRail *));
76 
77  for (i = 0; i < no_pages_; i++)
78  {
79  railDef = (tRailDef **)malloc((no_pages_ + 1) * sizeof(tRailDef *));
80  railDef[0] = new tRailDef;
81  railDef[0]->address = address_;
82  railDef[0]->pages = (uint8_t *) malloc(sizeof(uint8_t));
83  railDef[0]->pages[0] = i;
84  railDef[0]->noOfPages = 1;
85  railDef[0]->controller = false;
86  railDef[0]->multiphase = false;
87  railDef[0]->capabilities = getCapabilities();
88  railDef[1] = NULL;
89  rails[i] = new LT_PMBusRail(pmbus_, railDef[0]->address, railDef);
90  }
91 
92  rails[no_pages_] = NULL;
93  return rails;
94  }
95 
96 };
97 
98 #endif /* LT_PMBusDeviceManager_H_ */
void setSpeed(uint32_t speed)
Set the speed. If > 100000, enable clock stretching.
uint8_t noOfPages
Definition: LT_PMBusRail.h:65
LT_PMBusDeviceManager(LT_PMBus *pmbus, uint8_t address, uint8_t no_pages)
bool controller
Definition: LT_PMBusRail.h:66
static LT_PMBusRail ** rails
Definition: rail_logger.ino:97
LT_PMBus * pmbus_
uint32_t capabilities
Definition: LT_PMBusRail.h:68
LTC PMBus Support.
bool multiphase
Definition: LT_PMBusRail.h:67
static uint8_t address
Definition: DC2091A.ino:83
LT_PMBus * pmbus()
void changeSpeed(uint32_t speed)
Change the speed of the bus.
Definition: LT_I2CBus.cpp:73
virtual uint32_t getCapabilities()=0
Get the supported capabilities.
LT_SMBus * smbus()
Definition: LT_PMBus.h:401
virtual LT_I2CBus * i2cbus(void)=0
Library Header File for LT_PMBusDevice.
uint8_t address
Definition: LT_PMBusRail.h:63
LT_PMBusRail ** getRails()
Return a list of rails if any page is part of a rail.
uint8_t * pages
Definition: LT_PMBusRail.h:64
static int i
Definition: DC2430A.ino:184
PMBusRail communication. For Multiphase Rails.
Definition: LT_PMBusRail.h:72
PMBus communication.
Definition: LT_PMBus.h:370