Linduino  1.3.0
Linear Technology Arduino-Compatible Demonstration Board
DC1778A.ino
Go to the documentation of this file.
1 /*!
2 Linear Technology DC1778A Demonstration Board
3 LTC3883: Single Phase 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/LTC3883
14 
15 http://www.linear.com/demo/DC177A
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 LTC3883
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 LTC3883_I2C_ADDRESS 0x4F
66 
67 // Global variables
68 static uint8_t ltc3883_i2c_address;
69 static LT_SMBus *smbus = new LT_SMBusPec();
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();
79  print_prompt();
80 }
81 
82 //! Repeats Linduino loop
83 //! @return void
84 void loop()
85 {
86  uint8_t user_command;
87  uint8_t res;
88  uint8_t model[7];
89  uint8_t *addresses = NULL;
90 
91  if (Serial.available()) //! Checks for user input
92  {
93  user_command = read_int(); //! Reads the user command
94  if (user_command != 'm')
95  Serial.println(user_command);
96 
97  switch (user_command) //! Prints the appropriate submenu
98  {
99  case 1:
100  menu_1_basic_commands(); // Print single-ended voltage menu
101  break;
102  case 2:
103  pmbus->readModel(ltc3883_i2c_address, model);
104  Serial.print(F("MODEL "));
105  Serial.print((char *)model);
106  Serial.println();
107  break;
108  case 3:
110  Serial.println(res, HEX);
111  break;
112  case 4:
114  delete smbus;
115  delete pmbus;
116  smbus = new LT_SMBusPec();
117  pmbus = new LT_PMBus(smbus);
118  break;
119  case 5:
121  delete smbus;
122  delete pmbus;
123  smbus = new LT_SMBusNoPec();
124  pmbus = new LT_PMBus(smbus);
125  break;
126  case 6:
127  addresses = smbus->probe(0);
128  while (*addresses != 0)
129  {
130  Serial.print(F("ADDR 0x"));
131  Serial.println(*addresses++, HEX);
132  }
133  break;
134  case 7 :
135  pmbus->resetGlobal();
136  break;
137  default:
138  Serial.println(F("Incorrect Option"));
139  break;
140  }
141  print_prompt();
142  }
143 
144 }
145 
146 // Function Definitions
147 
148 //! Prints the title block when program first starts.
149 //! @return void
151 {
152  Serial.print(F("\n*****************************************************************\n"));
153  Serial.print(F("* DC1778A 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 DC1778A 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 //! @return void
166 {
167  Serial.print(F("\n 1-Basic Commands\n"));
168  Serial.print(F(" 2-Model Number\n"));
169  Serial.print(F(" 3-Revision Number\n"));
170  Serial.print(F(" 4-PEC On\n"));
171  Serial.print(F(" 5-PEC Off\n"));
172  Serial.print(F(" 6-Bus Probe\n"));
173  Serial.print(F(" 7-Reset\n"));
174  Serial.print(F("\nEnter a command:"));
175 }
176 
177 //! Prints a warning if the demo board is not detected.
178 //! @return void
180 {
181  Serial.println(F("\nWarning: Demo board not detected. Linduino will attempt to proceed."));
182 }
183 
184 //! Print all voltages
185 //! @return void
187 {
188  float voltage;
189 
190  voltage = pmbus->readVout(ltc3883_i2c_address, false);
191  Serial.print(F("LTC3883 VOUT "));
192  Serial.println(voltage, DEC);
193 }
194 
195 //! Print all curents
196 //! @return void
198 {
199  float current;
200 
201  current = pmbus->readIout(ltc3883_i2c_address, false);
202  Serial.print(F("LTC3883 IOUT "));
203  Serial.println(current, DEC);
204 }
205 
206 //! Print all status bytes and words
207 //! @return void
209 {
210  uint8_t b;
211  uint16_t w;
212 
214  Serial.print(F("LTC3883 STATUS BYTE 0x"));
215  Serial.println(b, HEX);
217  Serial.print(F("LTC3883 STATUS WORD 0x"));
218  Serial.println(w, HEX);
219 }
220 
221 //! Sequence off then on
222 //! @return void
224 {
225  pmbus->sequenceOffGlobal();
226  delay (2000);
227  pmbus->sequenceOnGlobal();
228 }
229 
230 //! Margin high
231 //! @return void
233 {
234  pmbus->marginHighGlobal();
235 }
236 
237 //! Margin low
238 //! @return void
240 {
241  pmbus->marginLowGlobal();
242 }
243 
244 //! Go to nominal
245 //! @return void
247 {
248  pmbus->sequenceOnGlobal();
249 }
250 
251 //! Display menu 1
252 //! @return void
254 {
255  uint8_t user_command;
256 
257  do
258  {
259  //! Displays the Read/Write menu
260  Serial.print(F("\nRead/Write\n\n"));
261  Serial.print(F(" 1-Read All Voltages\n"));
262  Serial.print(F(" 2-Read All Currents\n"));
263  Serial.print(F(" 3-Read All Status\n"));
264  Serial.print(F(" 4-Sequence Off/On\n"));
265  Serial.print(F(" 5-Margin High\n"));
266  Serial.print(F(" 6-Margin Low\n"));
267  Serial.print(F(" 7-Margin Off\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  default:
303  if (user_command != 'm')
304  Serial.println(F("Invalid Selection"));
305  break;
306  }
307  }
308  while (user_command != 'm');
309 }
310 
311 
unsigned char user_command
static void print_title()
Prints the title block when program first starts.
Definition: DC1778A.ino:150
LTC SMBus Support: Implementation for a shared SMBus layer.
static void print_all_currents()
Print all curents.
Definition: DC1778A.ino:197
uint8_t readStatusByte(uint8_t address)
Get the status byte.
Definition: LT_PMBus.cpp:2423
static uint8_t ltc3883_i2c_address
Definition: DC1778A.ino:68
static LT_PMBus * pmbus
Definition: DC1778A.ino:70
Header File for Linduino Libraries and Demo Code.
void enablePec(uint8_t address)
Enable pec for all transactions.
Definition: LT_PMBus.cpp:3173
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
void disablePec(uint8_t address)
Disable pec for all transactions.
Definition: LT_PMBus.cpp:3210
uint8_t readPmbusRevision(uint8_t address)
Get the pmbus revision.
Definition: LT_PMBus.cpp:2380
float readVout(uint8_t address, bool polling)
Get the measured output voltage.
Definition: LT_PMBus.cpp:1598
LT_I2CBus: Routines to communicate to I2C by Wire Library.
void resetGlobal(void)
Issue reset to all devices.
Definition: LT_PMBus.cpp:2906
static void print_all_voltages()
Print all voltages.
Definition: DC1778A.ino:186
static void margin_off()
Go to nominal.
Definition: DC1778A.ino:246
static void setup()
Initialize Linduino.
Definition: DC1778A.ino:74
static void print_all_status()
Print all status bytes and words.
Definition: DC1778A.ino:208
void marginLowGlobal(void)
Margin all rails low.
Definition: LT_PMBus.cpp:3078
static void menu_1_basic_commands()
Display menu 1.
Definition: DC1778A.ino:253
static void print_prompt()
Prints main menu.
Definition: DC1778A.ino:165
void sequenceOnGlobal(void)
Sequence on all rails.
Definition: LT_PMBus.cpp:2896
virtual uint8_t * probe(uint8_t command)=0
SMBus bus probe.
static LT_SMBus * smbus
Definition: DC1778A.ino:69
#define LTC3883_I2C_ADDRESS
Definition: DC1778A.ino:65
LTC SMBus Support: Implementation for a shared SMBus layer.
static void loop()
Repeats Linduino loop.
Definition: DC1778A.ino:84
int32_t read_int()
static void print_warning_prompt()
Prints a warning if the demo board is not detected.
Definition: DC1778A.ino:179
static void margin_high()
Margin high.
Definition: DC1778A.ino:232
void sequenceOffGlobal(void)
Sequence off all rails.
Definition: LT_PMBus.cpp:2876
LTC PMBus Support.
static void sequence_off_on()
Sequence off then on.
Definition: DC1778A.ino:223
static void margin_low()
Margin low.
Definition: DC1778A.ino:239
static float voltage
Definition: DC2289AA.ino:71
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
PMBus communication.
Definition: LT_PMBus.h:370