| Linduino 1.3.0 Linear Technology Arduino-Compatible Demonstration Board

DC2263A.ino
Go to the documentation of this file.
1 /*!
2 Linear Technology DC2263A Demonstration Board
3 LTC3887: 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/LTC3887
14
15 http://www.linear.com/demo/DC2263A
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 LTC3887_I2C_ADDRESS 0x4F
66
67 // Global variables
68 static uint8_t ltc3887_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 ltc3887_i2c_address = LTC3887_I2C_ADDRESS;
79 pmbus->disablePec(ltc3887_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(ltc3887_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(ltc3887_i2c_address);
111 Serial.println(res, HEX);
112 break;
113 case 4:
114 pmbus->enablePec(ltc3887_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(ltc3887_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->reset(ltc3887_i2c_address);
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 //! @return void
151 void print_title()
152 {
153 Serial.print(F("\n*****************************************************************\n"));
154 Serial.print(F("* DC1590B Demonstration Program *\n"));
155 Serial.print(F("* *\n"));
156 Serial.print(F("* This program demonstrates how to send and receive data from *\n"));
157 Serial.print(F("* the DC1590B demo board. *\n"));
158 Serial.print(F("* *\n"));
159 Serial.print(F("* Set the baud rate to 115200 and select the newline terminator.*\n"));
160 Serial.print(F("* *\n"));
161 Serial.print(F("*****************************************************************\n"));
162 }
163
164 //! Prints main menu.
165 //! @return void
166 void print_prompt()
167 {
168 Serial.print(F("\n 1-Basic Commands\n"));
169 Serial.print(F(" 2-Model Number\n"));
170 Serial.print(F(" 3-Revision Number\n"));
171 Serial.print(F(" 4-PEC On\n"));
172 Serial.print(F(" 5-PEC Off\n"));
173 Serial.print(F(" 6-Bus Probe\n"));
174 Serial.print(F(" 7-Reset\n"));
175 Serial.print(F("\nEnter a command:"));
176 }
177
178 //! Prints a warning if the demo board is not detected.
179 //! @return void
180 void print_warning_prompt()
181 {
182 Serial.println(F("\nWarning: Demo board not detected. Linduino will attempt to proceed."));
183 }
184
185 //! Print all voltages
186 //! @return void
187 void print_all_voltages()
188 {
189 float voltage;
190 uint8_t page;
191
192 for (page = 0; page < 2; page++)
193 {
194 pmbus->setPage(ltc3887_i2c_address, page);
195 voltage = pmbus->readVout(ltc3887_i2c_address, false);
196 Serial.print(F("LTC3887 VOUT "));
197 Serial.println(voltage, DEC);
198 }
199 }
200
201 //! Print all currents
202 //! @return void
203 void print_all_currents()
204 {
205 float current;
206 uint8_t page;
207
208 for (page = 0; page < 2; page++)
209 {
210 pmbus->setPage(ltc3887_i2c_address, page);
211 current = pmbus->readIout(ltc3887_i2c_address, false);
212 Serial.print(F("LTC3887 IOUT "));
213 Serial.println(current, DEC);
214 }
215 }
216
217 //! Print all status bytes and words
218 //! @return void
219 void print_all_status()
220 {
221 uint8_t b;
222 uint16_t w;
223 uint8_t page;
224
225 for (page = 0; page < 2; page++)
226 {
227 Serial.print(F("PAGE "));
228 Serial.println(page, DEC);
229 pmbus->setPage(ltc3887_i2c_address, page);
230 // pmbus->waitForNotBusy(ltc3887_i2c_address);
231 b = pmbus->readStatusByte(ltc3887_i2c_address);
232 // pmbus->waitForNotBusy(ltc3887_i2c_address);
233 Serial.print(F("LTC3887 STATUS BYTE 0x"));
234 Serial.println(b, HEX);
235 w = pmbus->readStatusWord(ltc3887_i2c_address);
236 // pmbus->waitForNotBusy(ltc3887_i2c_address);
237 Serial.print(F("LTC3887 STATUS WORD 0x"));
238 Serial.println(w, HEX);
239 }
240 }
241
242 //! Sequenc off and then on
243 //! @return void
244 void sequence_off_on()
245 {
246 pmbus->sequenceOffGlobal();
247 delay (2000);
248 pmbus->sequenceOnGlobal();
249 }
250
251 //! Margin high
252 //! @return void
253 void margin_high()
254 {
255 pmbus->marginHighGlobal();
256 }
257
258 //! Margin low
259 //! @return void
260 void margin_low()
261 {
262 pmbus->marginLowGlobal();
263 }
264
265 //! Go to nominal
266 //! @return void
267 void margin_off()
268 {
269 pmbus->sequenceOnGlobal();
270 }
271
272 //! Display menu 1
273 //! @return void
274 void menu_1_basic_commands()
275 {
276 uint8_t user_command;
277
278 do
279 {
280 //! Displays the Read/Write menu
281 Serial.print(F("\nRead/Write\n\n"));
282 Serial.print(F(" 1-Read All Voltages\n"));
283 Serial.print(F(" 2-Read All Currents\n"));
284 Serial.print(F(" 3-Read All Status\n"));
285 Serial.print(F(" 4-Sequence Off/On\n"));
286 Serial.print(F(" 5-Margin High\n"));
287 Serial.print(F(" 6-Margin Low\n"));
288 Serial.print(F(" 7-Margin Off\n"));
289 Serial.print(F(" 8-ClearFaults\n"));
290 Serial.print(F(" m-Main Menu\n"));
291 Serial.print(F("\nEnter a command: "));
292
293 user_command = read_int(); //! Reads the user command
294 if (user_command == 'm') // Print m if it is entered
295 {
296 Serial.print(F("m\n"));
297 }
298 else
299 Serial.println(user_command); // Print user command
300
301 switch (user_command)
302 {
303 case 1:
304 print_all_voltages();
305 break;
306 case 2:
307 print_all_currents();
308 break;
309 case 3:
310 print_all_status();
311 break;
312 case 4:
313 sequence_off_on();
314 break;
315 case 5:
316 margin_high();
317 break;
318 case 6:
319 margin_low();
320 break;
321 case 7:
322 margin_off();
323 break;
324 case 8:
325 pmbus->clearAllFaults(ltc3887_i2c_address);
326 default:
327 if (user_command != 'm')
328 Serial.println(F("Invalid Selection"));
329 break;
330 }
331 }
332 while (user_command != 'm');
333 }
334
335
menu_1_basic_commands
static void menu_1_basic_commands()
Display menu 1.
Definition: DC2263A.ino:274
print_prompt
static void print_prompt()
Prints main menu.
Definition: DC2263A.ino:166
user_command
unsigned char user_command
Definition: Serial_EEPROM_Test.ino:75
print_all_status
static void print_all_status()
Print all status bytes and words.
Definition: DC2263A.ino:219
margin_off
static void margin_off()
Go to nominal.
Definition: DC2263A.ino:267
LT_SMBusPec.h
LTC SMBus Support: Implementation for a shared SMBus layer.
LT_PMBus::reset
void reset(uint8_t address)
Issue reset to one device.
Definition: LT_PMBus.cpp:2912
LT_PMBus::readStatusByte
uint8_t readStatusByte(uint8_t address)
Get the status byte.
Definition: LT_PMBus.cpp:2423
Linduino.h
Header File for Linduino Libraries and Demo Code.
ltc3887_i2c_address
static uint8_t ltc3887_i2c_address
Definition: DC2263A.ino:68
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::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
loop
static void loop()
Repeats Linduino loop.
Definition: DC2263A.ino:85
LT_PMBus::disablePec
void disablePec(uint8_t address)
Disable pec for all transactions.
Definition: LT_PMBus.cpp:3210
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
setup
static void setup()
Initialize Linduino.
Definition: DC2263A.ino:74
LT_SMBus
Definition: LT_SMBus.h:61
LT_PMBus::readVout
float readVout(uint8_t address, bool polling)
Get the measured output voltage.
Definition: LT_PMBus.cpp:1598
pmbus
static LT_PMBus * pmbus
Definition: DC2263A.ino:70
LT_I2CBus.h
LT_I2CBus: Routines to communicate to I2C by Wire Library.
print_warning_prompt
static void print_warning_prompt()
Prints a warning if the demo board is not detected.
Definition: DC2263A.ino:180
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.
LTC3887_I2C_ADDRESS
#define LTC3887_I2C_ADDRESS
Definition: DC2263A.ino:65
LT_SMBusNoPec.h
LTC SMBus Support: Implementation for a shared SMBus layer.
margin_high
static void margin_high()
Margin high.
Definition: DC2263A.ino:253
UserInterface.h
read_int
int32_t read_int()
Definition: UserInterface.cpp:93
smbus
static LT_SMBus * smbus
Definition: DC2263A.ino:69
print_all_currents
static void print_all_currents()
Print all currents.
Definition: DC2263A.ino:203
LT_PMBus::sequenceOffGlobal
void sequenceOffGlobal(void)
Sequence off all rails.
Definition: LT_PMBus.cpp:2876
print_all_voltages
static void print_all_voltages()
Print all voltages.
Definition: DC2263A.ino:187
LT_PMBus.h
LTC PMBus Support.
margin_low
static void margin_low()
Margin low.
Definition: DC2263A.ino:260
voltage
static float voltage
Definition: DC2289AA.ino:71
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
sequence_off_on
static void sequence_off_on()
Sequenc off and then on.
Definition: DC2263A.ino:244
print_title
static void print_title()
Prints the title block when program first starts.
Definition: DC2263A.ino:151
LT_PMBus
PMBus communication.
Definition: LT_PMBus.h:370