| Linduino 1.3.0 Linear Technology Arduino-Compatible Demonstration Board

DC1989A.ino
Go to the documentation of this file.
1 /*!
2 Linear Technology DC1989A Demonstration Board
3 LTM4676: Dual Output PolyPhase Step-Down DC/DC Module with Digital Power System Management
4
5 @verbatim
6
7 NOTES
8 Setup:
9 Set the terminal baud rate to 115200 and select the newline terminator.
10
11 @endverbatim
12
13 http://www.linear.com/product/LTM4676
14 http://www.linear.com/demo/DC1989A
15
16
17 Copyright 2018(c) Analog Devices, Inc.
18
19 All rights reserved.
20
21 Redistribution and use in source and binary forms, with or without
22 modification, are permitted provided that the following conditions are met:
23 - Redistributions of source code must retain the above copyright
24 notice, this list of conditions and the following disclaimer.
25 - Redistributions in binary form must reproduce the above copyright
26 notice, this list of conditions and the following disclaimer in
27 the documentation and/or other materials provided with the
28 distribution.
29 - Neither the name of Analog Devices, Inc. nor the names of its
30 contributors may be used to endorse or promote products derived
31 from this software without specific prior written permission.
32 - The use of this software may or may not infringe the patent rights
33 of one or more patent holders. This license does not release you
34 from the requirement that you obtain separate licenses from these
35 patent holders to use this software.
36 - Use of the software either in source or binary form, must be run
37 on or directly connected to an Analog Devices Inc. component.
38
39 THIS SOFTWARE IS PROVIDED BY ANALOG DEVICES "AS IS" AND ANY EXPRESS OR
40 IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, NON-INFRINGEMENT,
41 MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
42 IN NO EVENT SHALL ANALOG DEVICES BE LIABLE FOR ANY DIRECT, INDIRECT,
43 INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
44 LIMITED TO, INTELLECTUAL PROPERTY RIGHTS, PROCUREMENT OF SUBSTITUTE GOODS OR
45 SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
46 CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
47 OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
48 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
49 */
50
51 #include <Arduino.h>
52 #include <Linduino.h>
53 #include <UserInterface.h>
54 #include <stdint.h>
55
56 #include <LT_Wire.h>
57 //#include <LT_twi.h>
58 #include <LT_SMBusPec.h>
59 #include <LT_PMBusMath.h>
60 #include <LT_SMBus.h>
61 #include <LT_PMBusRail.h>
62 #include <LT_I2CBus.h>
63 #include <LT_SMBusGroup.h>
64 #include <LT_PMBusDetect.h>
65 #include <LT_PMBus.h>
66 #include <LT_FaultLog.h>
67 #include <LT_PMBusDevice.h>
68 #include <LT_SMBusNoPec.h>
69 #include <LT_SMBusBase.h>
70 #include <LT_PMBusDetect.h>
71 #include <LT_PMBusSpeedTest.h>
72 #include <LT_PMBusDeviceLTC3880.h>
73 #include <LT_3880FaultLog.h> // For compilation of library
74
75 #define LTM4676_I2C_ADDRESS_0 0x45
76 #define LTM4676_I2C_ADDRESS_1 0x46
77 #define LTM4676_I2C_ADDRESS_2 0x47
78 #define LTM4676_I2C_ADDRESS_3 0x48
79 #define LTM4676_I2C_ADDRESS_R 0x31
80
81 // Global variables
82 static uint8_t ltm4676_i2c_address_0;
83 static uint8_t ltm4676_i2c_address_1;
84 static uint8_t ltm4676_i2c_address_2;
85 static uint8_t ltm4676_i2c_address_3;
86 static uint8_t ltm4676_i2c_address_r;
87 static uint8_t pages[2];
88
89 static LT_SMBus *smbus = new LT_SMBusPec();
90 static LT_PMBus *pmbus = new LT_PMBus(smbus);
91 static LT_PMBusDetect *detector = new LT_PMBusDetect(pmbus);
92 static LT_PMBusRail *rail;
93
94 //! Initialize Linduino
95 void setup()
96 {
97 Serial.begin(115200); //! Initialize the serial port to the PC
98 print_title();
99 ltm4676_i2c_address_0 = LTM4676_I2C_ADDRESS_0;
100 ltm4676_i2c_address_1 = LTM4676_I2C_ADDRESS_1;
101 ltm4676_i2c_address_2 = LTM4676_I2C_ADDRESS_2;
102 ltm4676_i2c_address_3 = LTM4676_I2C_ADDRESS_3;
103 ltm4676_i2c_address_r = LTM4676_I2C_ADDRESS_R;
104
105 detector->detect();
106 rail = detector->getRails()[0];
107
108 print_prompt();
109 }
110
111 //! Repeats Linduino loop
112 void loop()
113 {
114 uint8_t user_command;
115 uint8_t res;
116 uint8_t model[7];
117 uint8_t *addresses = NULL;
118
119 if (Serial.available()) //! Checks for user input
120 {
121 user_command = read_int(); //! Reads the user command
122 if (user_command != 'm')
123 Serial.println(user_command);
124
125 switch (user_command) //! Prints the appropriate submenu
126 {
127 case 1:
128 menu_1_basic_commands(); // Print single-ended voltage menu
129 break;
130 case 2:
131 pmbus->readModel(ltm4676_i2c_address_0, model);
132 Serial.print(F("MODEL "));
133 Serial.print((char *)model);
134 Serial.println();
135 break;
136 case 3:
137 res = pmbus->readPmbusRevision(ltm4676_i2c_address_0);
138 Serial.println(res, HEX);
139 break;
140 case 4:
141 pmbus->enablePec(ltm4676_i2c_address_0);
142 delete rail;
143 delete smbus;
144 delete pmbus;
145 delete detector;
146 smbus = new LT_SMBusPec();
147 pmbus = new LT_PMBus(smbus);
148 detector = new LT_PMBusDetect(pmbus);
149 detector->detect();
150 rail =detector->getRails()[0];
151 break;
152 case 5:
153 pmbus->disablePec(ltm4676_i2c_address_0);
154 delete rail;
155 delete smbus;
156 delete pmbus;
157 delete detector;
158 smbus = new LT_SMBusNoPec();
159 pmbus = new LT_PMBus(smbus);
160 detector = new LT_PMBusDetect(pmbus);
161 detector->detect();
162 rail = detector->getRails()[0];
163 break;
164 case 6:
165 addresses = smbus->probe(0);
166 while (*addresses != 0)
167 {
168 Serial.print(F("ADDR 0x"));
169 Serial.println(*addresses++, HEX);
170 }
171 break;
172 case 7 :
173 pmbus->resetGlobal();
174 break;
175 default:
176 Serial.println(F("Incorrect Option"));
177 break;
178 }
179 print_prompt();
180 }
181
182 }
183
184 // Function Definitions
185
186 //! Prints the title block when program first starts.
187 void print_title()
188 {
189 Serial.print(F("\n*****************************************************************\n"));
190 Serial.print(F("* DC1590B Demonstration Program *\n"));
191 Serial.print(F("* *\n"));
192 Serial.print(F("* This program demonstrates how to send and receive data from *\n"));
193 Serial.print(F("* the DC1590B demo board. *\n"));
194 Serial.print(F("* *\n"));
195 Serial.print(F("* Set the baud rate to 115200 and select the newline terminator.*\n"));
196 Serial.print(F("* *\n"));
197 Serial.print(F("*****************************************************************\n"));
198 }
199
200 //! Prints main menu.
201 void print_prompt()
202 {
203 Serial.print(F("\n 1-Basic Commands\n"));
204 Serial.print(F(" 2-Model Number\n"));
205 Serial.print(F(" 3-Revision Number\n"));
206 Serial.print(F(" 4-PEC On\n"));
207 Serial.print(F(" 5-PEC Off\n"));
208 Serial.print(F(" 6-Bus Probe\n"));
209 Serial.print(F(" 7-Reset\n"));
210 Serial.print(F("\nEnter a command:"));
211 }
212
213 //! Prints a warning if the demo board is not detected.
214 void print_warning_prompt()
215 {
216 Serial.println(F("\nWarning: Demo board not detected. Linduino will attempt to proceed."));
217 }
218
219 void menu_1_basic_commands()
220 {
221 uint8_t user_command;
222 float result;
223 uint16_t status;
224
225 do
226 {
227 //! Displays the Read/Write menu
228 Serial.print(F("\nRead/Write\n\n"));
229 Serial.print(F(" 1-Read Voltages\n"));
230 Serial.print(F(" 2-Read Currents\n"));
231 Serial.print(F(" 3-Read Power\n"));
232 Serial.print(F(" 4-Read Status\n"));
233 Serial.print(F(" 5-Sequence Off/On\n"));
234 Serial.print(F(" 6-Margin High\n"));
235 Serial.print(F(" 7-Margin Low\n"));
236 Serial.print(F(" 8-Margin Off\n"));
237 Serial.print(F(" 9-Clear Faults\n"));
238 Serial.print(F(" m-Main Menu\n"));
239 Serial.print(F("\nEnter a command: "));
240
241 user_command = read_int(); //! Reads the user command
242 if (user_command == 'm') // Print m if it is entered
243 {
244 Serial.print(F("m\n"));
245 }
246 else
247 Serial.println(user_command); // Print user command
248
249 switch (user_command)
250 {
251 case 1:
252 result = rail->readVin(false);
253 Serial.print(F("LTM4676 VIN "));
254 Serial.println(result, DEC);
255 result = rail->readVout(false);
256 Serial.print(F("LTM4676 VOUT "));
257 Serial.println(result, DEC);
258 break;
259 case 2:
260 result = rail->readIin(false);
261 Serial.print(F("LTM4676 IIN "));
262 Serial.println(result, DEC);
263 result = rail->readIout(false);
264 Serial.print(F("LTM4676 IOUT "));
265 Serial.println(result, DEC);
266 break;
267 case 3:
268 result = rail->readPout(false);
269 Serial.print(F("LTM4676 POUT "));
270 Serial.println(result, DEC);
271 break;
272 case 4:
273 status = rail->readStatusWord();
274 Serial.print(F("LTM4676 STATUS WORD 0x"));
275 Serial.println(status, HEX);
276 break;
277 case 5:
278 rail->sequenceOff();
279 delay (2000);
280 rail->sequenceOn();
281 break;
282 case 6:
283 rail->marginHigh();
284 break;
285 case 7:
286 rail->marginLow();
287 break;
288 case 8:
289 rail->marginOff();
290 break;
291 case 9:
292 rail->clearFaults();
293 break;
294 default:
295 if (user_command != 'm')
296 Serial.println(F("Invalid Selection"));
297 break;
298 }
299 }
300 while (user_command != 'm');
301 }
302
303
ltm4676_i2c_address_1
static uint8_t ltm4676_i2c_address_1
Definition: DC1989A.ino:83
LT_PMBusDetect::getRails
LT_PMBusRail ** getRails()
Definition: LT_PMBusDetect.cpp:78
LT_PMBusDeviceLTC3880.h
LTC PSM Device.
user_command
unsigned char user_command
Definition: Serial_EEPROM_Test.ino:75
LT_SMBus.h
LTC SMBus Support: API for a shared SMBus layer.
LT_PMBusRail::sequenceOn
void sequenceOn()
Sequence on a polyphase rail.
Definition: LT_PMBusRail.cpp:616
LT_SMBusGroup.h
LTC SMBus Support: Implementation for a shared SMBus layer.
LT_SMBusPec.h
LTC SMBus Support: Implementation for a shared SMBus layer.
status
String status(void)
Returns a descriptive string based on status of pins.
Definition: DC2364A.ino:217
LT_PMBusRail::readIin
float readIin(bool polling)
Read the input current of a polyphase rail.
Definition: LT_PMBusRail.cpp:181
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
LT_PMBus::readModel
void readModel(uint8_t address, uint8_t *model)
Get the model.
Definition: LT_PMBus.cpp:2409
LT_PMBus::disablePec
void disablePec(uint8_t address)
Disable pec for all transactions.
Definition: LT_PMBus.cpp:3210
LT_PMBusRail.h
LTC PMBus Support.
pages
static uint8_t pages[2]
Definition: DC1989A.ino:87
LT_PMBus::readPmbusRevision
uint8_t readPmbusRevision(uint8_t address)
Get the pmbus revision.
Definition: LT_PMBus.cpp:2380
LT_SMBusPec
Definition: LT_SMBusPec.h:61
smbus
static LT_SMBus * smbus
Definition: DC1989A.ino:89
LT_Wire.h
TwoWire.h - TWI/I2C library for Arduino & Wiring Copyright (c) 2006 Nicholas Zambetti.
LTM4676_I2C_ADDRESS_2
#define LTM4676_I2C_ADDRESS_2
Definition: DC1989A.ino:77
LT_SMBus
Definition: LT_SMBus.h:61
rail
static LT_PMBusRail * rail
Definition: DC1989A.ino:92
LT_3880FaultLog.h
LTC SMBus Support: Implementation for a LTC3880 Fault Log.
ltm4676_i2c_address_2
static uint8_t ltm4676_i2c_address_2
Definition: DC1989A.ino:84
print_warning_prompt
static void print_warning_prompt()
Prints a warning if the demo board is not detected.
Definition: DC1989A.ino:214
LTM4676_I2C_ADDRESS_3
#define LTM4676_I2C_ADDRESS_3
Definition: DC1989A.ino:78
LT_PMBusRail::marginHigh
void marginHigh()
Margin high polyphase rail.
Definition: LT_PMBusRail.cpp:641
LT_I2CBus.h
LT_I2CBus: Routines to communicate to I2C by Wire Library.
LT_FaultLog.h
LTC PMBus Support: Implementation for a LTC Fault Log.
LT_PMBusRail::clearFaults
void clearFaults()
Clear faults of polyphase rail.
Definition: LT_PMBusRail.cpp:598
LT_PMBus::resetGlobal
void resetGlobal(void)
Issue reset to all devices.
Definition: LT_PMBus.cpp:2906
LT_PMBusRail::sequenceOff
void sequenceOff()
Sequence off a polyphase rail.
Definition: LT_PMBusRail.cpp:633
LT_PMBusRail::readStatusWord
uint16_t readStatusWord()
Read the status word of a polyphase rail.
Definition: LT_PMBusRail.cpp:550
ltm4676_i2c_address_3
static uint8_t ltm4676_i2c_address_3
Definition: DC1989A.ino:85
pmbus
static LT_PMBus * pmbus
Definition: DC1989A.ino:90
LT_SMBus::probe
virtual uint8_t * probe(uint8_t command)=0
SMBus bus probe.
ltm4676_i2c_address_r
static uint8_t ltm4676_i2c_address_r
Definition: DC1989A.ino:86
LT_PMBusDetect.h
LTC PSM Device Dector.
LT_SMBusNoPec.h
LTC SMBus Support: Implementation for a shared SMBus layer.
LT_PMBusRail::marginOff
void marginOff()
Margin off polyphase rail.
Definition: LT_PMBusRail.cpp:659
LT_PMBusRail::readVin
float readVin(bool polling)
Read the input voltage of a polyphase rail.
Definition: LT_PMBusRail.cpp:154
UserInterface.h
read_int
int32_t read_int()
Definition: UserInterface.cpp:93
LT_PMBusDetect
Definition: LT_PMBusDetect.h:56
LT_PMBusDevice.h
Library Header File for LT_PMBusDevice.
detector
static LT_PMBusDetect * detector
Definition: DC1989A.ino:91
LTM4676_I2C_ADDRESS_0
#define LTM4676_I2C_ADDRESS_0
Linear Technology DC1989A Demonstration Board LTM4676: Dual Output PolyPhase Step-Down DC/DC Module w...
Definition: DC1989A.ino:75
LT_PMBus.h
LTC PMBus Support.
LT_PMBusRail::readPout
float readPout(bool polling)
Read the output power of a polyphase rail.
Definition: LT_PMBusRail.cpp:254
LT_PMBusSpeedTest.h
LTC PSM SpeedTest.
print_title
static void print_title()
Prints the title block when program first starts.
Definition: DC1989A.ino:187
LT_PMBusDetect::detect
void detect()
Detect devices on bus.
Definition: LT_PMBusDetect.cpp:85
menu_1_basic_commands
static void menu_1_basic_commands()
Definition: DC1989A.ino:219
loop
static void loop()
Repeats Linduino loop.
Definition: DC1989A.ino:112
setup
static void setup()
Initialize Linduino.
Definition: DC1989A.ino:95
LTM4676_I2C_ADDRESS_1
#define LTM4676_I2C_ADDRESS_1
Definition: DC1989A.ino:76
ltm4676_i2c_address_0
static uint8_t ltm4676_i2c_address_0
Definition: DC1989A.ino:82
LT_PMBusRail::marginLow
void marginLow()
Margin low polyphase rail.
Definition: LT_PMBusRail.cpp:650
LT_PMBusRail::readIout
float readIout(bool polling)
Read the output current of a polyphase rail.
Definition: LT_PMBusRail.cpp:207
LT_PMBusMath.h
LTC PMBus Support: Math conversion routines.
LT_PMBusRail
PMBusRail communication. For Multiphase Rails.
Definition: LT_PMBusRail.h:72
LT_PMBusRail::readVout
float readVout(bool polling)
Read the output voltage of a polyphase rail.
Definition: LT_PMBusRail.cpp:167
print_prompt
static void print_prompt()
Prints main menu.
Definition: DC1989A.ino:201
LT_SMBusBase.h
LTC SMBus Support: Implementation for a shared SMBus layer.
LTM4676_I2C_ADDRESS_R
#define LTM4676_I2C_ADDRESS_R
Definition: DC1989A.ino:79
LT_PMBus
PMBus communication.
Definition: LT_PMBus.h:370