Linduino  1.3.0
Linear Technology Arduino-Compatible Demonstration Board
DC1936A.ino
Go to the documentation of this file.
1 /*!
2 Linear Technology DC1936A Demonstration Board
3 LTC3882: Dual Output PolyPhase Step-Down DC/DC Voltage Mode 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/LTC3882
14 
15 http://www.linear.com/demo/DC1936A
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 LTC3882
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 LTC3882_I2C_ADDRESS 0x5C
66 
67 // Global variables
68 static uint8_t ltc3882_i2c_address;
69 static LT_SMBus *smbus = new LT_SMBusPec();
70 static LT_PMBus *pmbus = new LT_PMBus(smbus);
71 
72 //! Initialize Linduino
73 void setup()
74 {
75  Serial.begin(115200); //! Initialize the serial port to the PC
76  print_title();
78  print_prompt();
79 }
80 
81 //! Repeats Linduino loop
82 void loop()
83 {
84  uint8_t user_command;
85  uint8_t res;
86  uint8_t model[7];
87  uint8_t *addresses = NULL;
88 
89  if (Serial.available()) //! Checks for user input
90  {
91  user_command = read_int(); //! Reads the user command
92  if (user_command != 'm')
93  Serial.println(user_command);
94 
95  switch (user_command) //! Prints the appropriate submenu
96  {
97  case 1:
98  menu_1_basic_commands(); // Print single-ended voltage menu
99  break;
100  case 2:
101  pmbus->readModel(ltc3882_i2c_address, model);
102  Serial.print(F("MODEL "));
103  Serial.print((char *)model);
104  Serial.println();
105  break;
106  case 3:
108  Serial.println(res, HEX);
109  break;
110  case 4:
112  delete smbus;
113  delete pmbus;
114  smbus = new LT_SMBusPec();
115  pmbus = new LT_PMBus(smbus);
116  break;
117  case 5:
119  delete smbus;
120  delete pmbus;
121  smbus = new LT_SMBusNoPec();
122  pmbus = new LT_PMBus(smbus);
123  break;
124  case 6:
125  addresses = smbus->probe(0);
126  while (*addresses != 0)
127  {
128  Serial.print(F("ADDR 0x"));
129  Serial.println(*addresses++, HEX);
130  }
131  break;
132  case 7 :
133  pmbus->resetGlobal();
134  break;
135  default:
136  Serial.println(F("Incorrect Option"));
137  break;
138  }
139  print_prompt();
140  }
141 
142 }
143 
144 // Function Definitions
145 
146 //! Prints the title block when program first starts.
148 {
149  Serial.print(F("\n*****************************************************************\n"));
150  Serial.print(F("* DC1936A Demonstration Program *\n"));
151  Serial.print(F("* *\n"));
152  Serial.print(F("* This program demonstrates how to send and receive data from *\n"));
153  Serial.print(F("* the DC1936A demo board. *\n"));
154  Serial.print(F("* *\n"));
155  Serial.print(F("* Set the baud rate to 115200 and select the newline terminator.*\n"));
156  Serial.print(F("* *\n"));
157  Serial.print(F("*****************************************************************\n"));
158 }
159 
160 //! Prints main menu.
162 {
163  Serial.print(F("\n 1-Basic Commands\n"));
164  Serial.print(F(" 2-Model Number\n"));
165  Serial.print(F(" 3-Revision Number\n"));
166  Serial.print(F(" 4-PEC On\n"));
167  Serial.print(F(" 5-PEC Off\n"));
168  Serial.print(F(" 6-Bus Probe\n"));
169  Serial.print(F(" 7-Reset\n"));
170  Serial.print(F("\nEnter a command:"));
171 }
172 
173 //! Prints a warning if the demo board is not detected.
175 {
176  Serial.println(F("\nWarning: Demo board not detected. Linduino will attempt to proceed."));
177 }
178 
180 {
181  float voltage;
182  uint8_t page;
183 
184  for (page = 0; page < 2; page++)
185  {
186  voltage = pmbus->readVoutWithPage(ltc3882_i2c_address, page);
187  Serial.print(F("LTC3882 VOUT "));
188  Serial.println(voltage, DEC);
189  }
190 }
191 
193 {
194  float current;
195  uint8_t page;
196 
197  for (page = 0; page < 2; page++)
198  {
199  current = pmbus->readIoutWithPage(ltc3882_i2c_address, page);
200  Serial.print(F("LTC3882 IOUT "));
201  Serial.println(current, DEC);
202  }
203 }
204 
206 {
207  uint8_t b;
208  uint16_t w;
209  uint8_t page;
210 
211  for (page = 0; page < 2; page++)
212  {
213  Serial.print(F("PAGE "));
214  Serial.println(page, DEC);
215  pmbus->setPage(ltc3882_i2c_address, page);
217  Serial.print(F("LTC3880 STATUS BYTE 0x"));
218  Serial.println(b, HEX);
220  Serial.print(F("LTC3882 STATUS WORD 0x"));
221  Serial.println(w, HEX);
222  }
223 }
224 
226 {
227  pmbus->sequenceOffGlobal();
228  delay (2000);
229  pmbus->sequenceOnGlobal();
230 }
231 
233 {
234  pmbus->marginHighGlobal();
235 }
236 
238 {
239  pmbus->marginLowGlobal();
240 }
241 
243 {
244  pmbus->sequenceOnGlobal();
245 }
246 
248 {
249  uint8_t user_command;
250 
251  do
252  {
253  //! Displays the Read/Write menu
254  Serial.print(F("\nRead/Write\n\n"));
255  Serial.print(F(" 1-Read All Voltages\n"));
256  Serial.print(F(" 2-Read All Currents\n"));
257  Serial.print(F(" 3-Read All Status\n"));
258  Serial.print(F(" 4-Sequence Off/On\n"));
259  Serial.print(F(" 5-Margin High\n"));
260  Serial.print(F(" 6-Margin Low\n"));
261  Serial.print(F(" 7-Margin Off\n"));
262  Serial.print(F(" m-Main Menu\n"));
263  Serial.print(F("\nEnter a command: "));
264 
265  user_command = read_int(); //! Reads the user command
266  if (user_command == 'm') // Print m if it is entered
267  {
268  Serial.print(F("m\n"));
269  }
270  else
271  Serial.println(user_command); // Print user command
272 
273  switch (user_command)
274  {
275  case 1:
277  break;
278  case 2:
280  break;
281  case 3:
283  break;
284  case 4:
285  sequence_off_on();
286  break;
287  case 5:
288  margin_high();
289  break;
290  case 6:
291  margin_low();
292  break;
293  case 7:
294  margin_off();
295  break;
296  default:
297  if (user_command != 'm')
298  Serial.println(F("Invalid Selection"));
299  break;
300  }
301  }
302  while (user_command != 'm');
303 }
304 
305 
unsigned char user_command
static LT_SMBus * smbus
Definition: DC1936A.ino:69
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 LT_PMBus * pmbus
Definition: DC1936A.ino:70
static void print_title()
Prints the title block when program first starts.
Definition: DC1936A.ino:147
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 print_all_currents()
Definition: DC1936A.ino:192
uint16_t readStatusWord(uint8_t address)
Get the status word.
Definition: LT_PMBus.cpp:2470
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
static void print_all_voltages()
Definition: DC1936A.ino:179
static void print_prompt()
Prints main menu.
Definition: DC1936A.ino:161
static void setup()
Initialize Linduino.
Definition: DC1936A.ino:73
LT_I2CBus: Routines to communicate to I2C by Wire Library.
static void margin_high()
Definition: DC1936A.ino:232
void resetGlobal(void)
Issue reset to all devices.
Definition: LT_PMBus.cpp:2906
static void print_all_status()
Definition: DC1936A.ino:205
static void print_warning_prompt()
Prints a warning if the demo board is not detected.
Definition: DC1936A.ino:174
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
static void loop()
Repeats Linduino loop.
Definition: DC1936A.ino:82
void sequenceOnGlobal(void)
Sequence on all rails.
Definition: LT_PMBus.cpp:2896
virtual uint8_t * probe(uint8_t command)=0
SMBus bus probe.
static void menu_1_basic_commands()
Definition: DC1936A.ino:247
LTC SMBus Support: Implementation for a shared SMBus layer.
int32_t read_int()
#define LTC3882_I2C_ADDRESS
Definition: DC1936A.ino:65
void sequenceOffGlobal(void)
Sequence off all rails.
Definition: LT_PMBus.cpp:2876
static uint8_t ltc3882_i2c_address
Definition: DC1936A.ino:68
static void margin_low()
Definition: DC1936A.ino:237
LTC PMBus Support.
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
float readVoutWithPage(uint8_t address, uint8_t page)
Get the measured output voltage.
Definition: LT_PMBus.cpp:1678
static void margin_off()
Definition: DC1936A.ino:242
static void sequence_off_on()
Definition: DC1936A.ino:225
float readIoutWithPage(uint8_t address, uint8_t page)
Get the measured output current.
Definition: LT_PMBus.cpp:1924
PMBus communication.
Definition: LT_PMBus.h:370