| Linduino 1.3.0 Linear Technology Arduino-Compatible Demonstration Board

svid.ino
Go to the documentation of this file.
1 /*!
2 Linear Technology DC1962C Demonstration Board
3 LTC3880, LTC2974, LTC2977: Power Management Solution for Application Processors
4
5 @verbatim
6
7 Demonstrates SVID using PMBus and LTC3880 for QorIQ. The SVID values
8 are 0, 1, 2, 3. 3 is treated as VBOOT. When run, the script sets VBOOT
9 and then the voltage can be lowered in 12.5mV steps by selecting a number.
10
11 NOTES
12 Setup:
13 Set the terminal baud rate to 115200 and select the newline terminator.
14
15 @endverbatim
16
17 http://www.linear.com/product/LTC3880
18
19 http://www.linear.com/demo/DC1962C
20
21
22 Copyright 2018(c) Analog Devices, Inc.
23
24 All rights reserved.
25
26 Redistribution and use in source and binary forms, with or without
27 modification, are permitted provided that the following conditions are met:
28 - Redistributions of source code must retain the above copyright
29 notice, this list of conditions and the following disclaimer.
30 - Redistributions in binary form must reproduce the above copyright
31 notice, this list of conditions and the following disclaimer in
32 the documentation and/or other materials provided with the
33 distribution.
34 - Neither the name of Analog Devices, Inc. nor the names of its
35 contributors may be used to endorse or promote products derived
36 from this software without specific prior written permission.
37 - The use of this software may or may not infringe the patent rights
38 of one or more patent holders. This license does not release you
39 from the requirement that you obtain separate licenses from these
40 patent holders to use this software.
41 - Use of the software either in source or binary form, must be run
42 on or directly connected to an Analog Devices Inc. component.
43
44 THIS SOFTWARE IS PROVIDED BY ANALOG DEVICES "AS IS" AND ANY EXPRESS OR
45 IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, NON-INFRINGEMENT,
46 MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
47 IN NO EVENT SHALL ANALOG DEVICES BE LIABLE FOR ANY DIRECT, INDIRECT,
48 INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
49 LIMITED TO, INTELLECTUAL PROPERTY RIGHTS, PROCUREMENT OF SUBSTITUTE GOODS OR
50 SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
51 CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
52 OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
53 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
54 */
55
56 /*! @file
57 @ingroup DC1962
58 */
59
60 #include <Arduino.h>
61 #include <stdint.h>
62 #include "Linduino.h"
63 #include "UserInterface.h"
64 #include "LT_I2CBus.h"
65 #include "LT_SMBusNoPec.h"
66 #include "LT_SMBusPec.h"
67 #include "LT_PMBus.h"
68
69 #define LTC3880_I2C_ADDRESS 0x30
70 #define LTC2974_I2C_ADDRESS 0x32
71 #define LTC2977_I2C_ADDRESS 0x33
72
73 // Global variables
74 static uint8_t ltc3880_i2c_address;
75 static uint8_t ltc2974_i2c_address;
76 static uint8_t ltc2977_i2c_address;
77 static LT_SMBus *smbusNoPec = new LT_SMBusNoPec();
78 static LT_SMBus *smbusPec = new LT_SMBusPec();
79 static LT_PMBus *pmbusNoPec = new LT_PMBus(smbusNoPec);
80 static LT_PMBus *pmbusPec = new LT_PMBus(smbusPec);
81 static LT_SMBus *smbus = smbusNoPec;
82 static LT_PMBus *pmbus = pmbusNoPec;
83
84 //! Initialize Linduino
85 //! @return void
86 void setup()
87 {
88 Serial.begin(115200); //! Initialize the serial port to the PC
89 print_title();
90 ltc3880_i2c_address = LTC3880_I2C_ADDRESS;
91 ltc2974_i2c_address = LTC2974_I2C_ADDRESS;
92 ltc2977_i2c_address = LTC2977_I2C_ADDRESS;
93 print_prompt();
94
95 pmbus->setPage(ltc3880_i2c_address, 0);
96 pmbus->setVout(ltc3880_i2c_address, 0.85);
97 }
98
99 //! Repeats Linduino loop
100 //! @return void
101 void loop()
102 {
103 uint8_t user_command;
104 uint8_t model[7];
105 uint8_t *addresses = NULL;
106 float voltage;
107
108 if (Serial.available()) //! Checks for user input
109 {
110 user_command = read_int(); //! Reads the user command
111 if (user_command != 'm')
112 Serial.println(user_command);
113 voltage = 0.85;
114 switch (user_command) //! Prints the appropriate submenu
115 {
116 case 0:
117 pmbus->setVout(ltc3880_i2c_address, voltage - 0.060);
118 break;
119 case 1:
120 pmbus->setVout(ltc3880_i2c_address, voltage - 0.045);
121 break;
122 case 2:
123 pmbus->setVout(ltc3880_i2c_address, voltage - 0.030);
124 break;
125 case 3:
126 pmbus->setVout(ltc3880_i2c_address, voltage - 0.015);
127 break;
128 case 4:
129 pmbus->setVout(ltc3880_i2c_address, voltage);
130 break;
131 case 5:
132 pmbus->enablePec(ltc3880_i2c_address);
133 pmbus->enablePec(ltc2974_i2c_address);
134 pmbus->enablePec(ltc2977_i2c_address);
135 smbus = smbusPec;
136 pmbus = pmbusPec;
137 break;
138 case 6:
139 pmbus->disablePec(ltc3880_i2c_address);
140 pmbus->disablePec(ltc2974_i2c_address);
141 pmbus->disablePec(ltc2977_i2c_address);
142 smbus = smbusNoPec;
143 pmbus = pmbusNoPec;
144 break;
145 case 7:
146 addresses = smbus->probe(0);
147 while (*addresses != 0)
148 {
149 Serial.print("ADDR 0x");
150 Serial.println(*addresses++, HEX);
151 }
152 break;
153 case 8 :
154 pmbus->resetGlobal();
155 break;
156 default:
157 Serial.println("Incorrect Option");
158 break;
159 }
160 print_prompt();
161 }
162 }
163
164 // Function Definitions
165
166 //! Prints the title block when program first starts.
167 //! @return void
168 void print_title()
169 {
170 Serial.print(F("\n***************************************************************\n"));
171 Serial.print(F("* DC1962C SVID Demonstration Program *\n"));
172 Serial.print(F("* *\n"));
173 Serial.print(F("* This program demonstrates how program SVID for LTC3880 *\n"));
174 Serial.print(F("* *\n"));
175 Serial.print(F("* Set the baud rate to 115200 and select the newline terminator.*\n"));
176 Serial.print(F("* *\n"));
177 Serial.print(F("*****************************************************************\n"));
178 }
179
180 //! Prints main menu.
181 //! @return void
182 void print_prompt()
183 {
184 Serial.print(F("\n 0-SVID 0 - VBOOT - 60mV\n"));
185 Serial.print(F(" 1-SVID 1 - VBOOT - 45mV\n"));
186 Serial.print(F(" 2-SVID 2 - VBOOT - 30mV\n"));
187 Serial.print(F(" 3-SVID 3 - VBOOT - 15mV \n"));
188 Serial.print(F(" 4-SVID 4 - VBOOT\n"));
189 Serial.print(F(" 5-PEC On\n"));
190 Serial.print(F(" 6-PEC Off\n"));
191 Serial.print(F(" 7-Bus Probe\n"));
192 Serial.print(F(" 8-Reset\n"));
193 Serial.print(F("\nEnter a command:"));
194 }
195
196 //! Prints a warning if the demo board is not detected.
197 //! @return void
198 void print_warning_prompt()
199 {
200 Serial.println(F("\nWarning: Demo board not detected. Linduino will attempt to proceed."));
201 }
202
smbusNoPec
static LT_SMBus * smbusNoPec
Definition: svid.ino:77
print_prompt
static void print_prompt()
Prints main menu.
Definition: svid.ino:182
user_command
unsigned char user_command
Definition: Serial_EEPROM_Test.ino:75
LTC2974_I2C_ADDRESS
#define LTC2974_I2C_ADDRESS
Definition: svid.ino:70
LT_SMBusPec.h
LTC SMBus Support: Implementation for a shared SMBus layer.
Linduino.h
Header File for Linduino Libraries and Demo Code.
LT_PMBus::enablePec
void enablePec(uint8_t address)
Enable pec for all transactions.
Definition: LT_PMBus.cpp:3173
LT_SMBusNoPec
Definition: LT_SMBusNoPec.h:60
pmbus
static LT_PMBus * pmbus
Definition: svid.ino:82
loop
static void loop()
Repeats Linduino loop.
Definition: svid.ino:101
print_warning_prompt
static void print_warning_prompt()
Prints a warning if the demo board is not detected.
Definition: svid.ino:198
LT_PMBus::disablePec
void disablePec(uint8_t address)
Disable pec for all transactions.
Definition: LT_PMBus.cpp:3210
print_title
static void print_title()
Prints the title block when program first starts.
Definition: svid.ino:168
LT_SMBusPec
Definition: LT_SMBusPec.h:61
LT_SMBus
Definition: LT_SMBus.h:61
pmbusPec
static LT_PMBus * pmbusPec
Definition: svid.ino:80
LT_I2CBus.h
LT_I2CBus: Routines to communicate to I2C by Wire Library.
LT_PMBus::resetGlobal
void resetGlobal(void)
Issue reset to all devices.
Definition: LT_PMBus.cpp:2906
ltc2974_i2c_address
static uint8_t ltc2974_i2c_address
Definition: svid.ino:75
ltc3880_i2c_address
static uint8_t ltc3880_i2c_address
Definition: svid.ino:74
LT_PMBus::setPage
void setPage(uint8_t address, uint8_t page)
Set the page.
Definition: LT_PMBus.cpp:3156
LTC2977_I2C_ADDRESS
#define LTC2977_I2C_ADDRESS
Definition: svid.ino:71
LT_SMBus::probe
virtual uint8_t * probe(uint8_t command)=0
SMBus bus probe.
smbusPec
static LT_SMBus * smbusPec
Definition: svid.ino:78
LT_SMBusNoPec.h
LTC SMBus Support: Implementation for a shared SMBus layer.
smbus
static LT_SMBus * smbus
Definition: svid.ino:81
UserInterface.h
read_int
int32_t read_int()
Definition: UserInterface.cpp:93
ltc2977_i2c_address
static uint8_t ltc2977_i2c_address
Definition: svid.ino:76
LT_PMBus::setVout
void setVout(uint8_t address, float voltage)
Set output voltage.
Definition: LT_PMBus.cpp:239
LT_PMBus.h
LTC PMBus Support.
voltage
static float voltage
Definition: DC2289AA.ino:71
LTC3880_I2C_ADDRESS
#define LTC3880_I2C_ADDRESS
Definition: svid.ino:69
setup
static void setup()
Initialize Linduino.
Definition: svid.ino:86
pmbusNoPec
static LT_PMBus * pmbusNoPec
Definition: svid.ino:79
LT_PMBus
PMBus communication.
Definition: LT_PMBus.h:370