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();
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:
111  Serial.println(res, HEX);
112  break;
113  case 4:
115  delete smbus;
116  delete pmbus;
117  smbus = new LT_SMBusPec();
118  pmbus = new LT_PMBus(smbus);
119  break;
120  case 5:
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.
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.
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.
178 {
179  Serial.println(F("\nWarning: Demo board not detected. Linduino will attempt to proceed."));
180 }
181 
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 
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 
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);
222  Serial.print(F("LTC3880 STATUS BYTE 0x"));
223  Serial.println(b, HEX);
225  Serial.print(F("LTC3880 STATUS WORD 0x"));
226  Serial.println(w, HEX);
227  }
228 }
229 
231 {
232  pmbus->sequenceOffGlobal();
233  delay (2000);
234  pmbus->sequenceOnGlobal();
235 }
236 
238 {
239  pmbus->marginHighGlobal();
240 }
241 
243 {
244  pmbus->marginLowGlobal();
245 }
246 
248 {
249  pmbus->sequenceOnGlobal();
250 }
251 
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:
283  break;
284  case 2:
286  break;
287  case 3:
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:
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 
static void margin_low()
Definition: DC1590B.ino:242
unsigned char user_command
LTC SMBus Support: Implementation for a shared SMBus layer.
uint8_t readStatusByte(uint8_t address)
Get the status byte.
Definition: LT_PMBus.cpp:2423
static void menu_1_basic_commands()
Definition: DC1590B.ino:252
Header File for Linduino Libraries and Demo Code.
void enablePec(uint8_t address)
Enable pec for all transactions.
Definition: LT_PMBus.cpp:3173
static void margin_high()
Definition: DC1590B.ino:237
uint16_t readStatusWord(uint8_t address)
Get the status word.
Definition: LT_PMBus.cpp:2470
float readIout(uint8_t address, bool polling)
Get the measured output current.
Definition: LT_PMBus.cpp:1898
void readModel(uint8_t address, uint8_t *model)
Get the model.
Definition: LT_PMBus.cpp:2409
static uint8_t ltc3880_i2c_address
Definition: DC1590B.ino:68
void disablePec(uint8_t address)
Disable pec for all transactions.
Definition: LT_PMBus.cpp:3210
static void loop()
Repeats Linduino loop.
Definition: DC1590B.ino:85
static void print_prompt()
Prints main menu.
Definition: DC1590B.ino:164
uint8_t readPmbusRevision(uint8_t address)
Get the pmbus revision.
Definition: LT_PMBus.cpp:2380
static void print_warning_prompt()
Prints a warning if the demo board is not detected.
Definition: DC1590B.ino:177
static void margin_off()
Definition: DC1590B.ino:247
float readVout(uint8_t address, bool polling)
Get the measured output voltage.
Definition: LT_PMBus.cpp:1598
#define LTC3880_I2C_ADDRESS
Definition: DC1590B.ino:65
LT_I2CBus: Routines to communicate to I2C by Wire Library.
static LT_PMBus * pmbus
Definition: DC1590B.ino:70
void resetGlobal(void)
Issue reset to all devices.
Definition: LT_PMBus.cpp:2906
static LT_SMBus * smbus
Definition: DC1590B.ino:69
static void setup()
Initialize Linduino.
Definition: DC1590B.ino:74
void setPage(uint8_t address, uint8_t page)
Set the page.
Definition: LT_PMBus.cpp:3156
void marginLowGlobal(void)
Margin all rails low.
Definition: LT_PMBus.cpp:3078
void sequenceOnGlobal(void)
Sequence on all rails.
Definition: LT_PMBus.cpp:2896
void clearAllFaults(uint8_t address)
Clear all the faults for all pages.
Definition: LT_PMBus.cpp:2576
virtual uint8_t * probe(uint8_t command)=0
SMBus bus probe.
static void print_title()
Prints the title block when program first starts.
Definition: DC1590B.ino:150
LTC SMBus Support: Implementation for a shared SMBus layer.
int32_t read_int()
static void sequence_off_on()
Definition: DC1590B.ino:230
void sequenceOffGlobal(void)
Sequence off all rails.
Definition: LT_PMBus.cpp:2876
LTC PMBus Support.
static float voltage
Definition: DC2289AA.ino:71
static void print_all_status()
Definition: DC1590B.ino:210
static uint16_t current
the current measurement from the LTC3335&#39;s counter test mode.
Definition: DC2343A.ino:114
void marginHighGlobal(void)
Margin all rails high.
Definition: LT_PMBus.cpp:3068
static void print_all_voltages()
Definition: DC1590B.ino:182
static void print_all_currents()
Definition: DC1590B.ino:196
PMBus communication.
Definition: LT_PMBus.h:370