| Linduino 1.3.0 Linear Technology Arduino-Compatible Demonstration Board

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