| Linduino 1.3.0 Linear Technology Arduino-Compatible Demonstration Board

DC2024A.ino
Go to the documentation of this file.
1 /*!
2 Linear Technology DC2024A Demonstration Board.
3 LTC4282: High Current Hotswap Controller with I2C Compatible Monitoring
4
5 @verbatim
6
7 Setting the Alarm Thresholds:
8 1. Select the Alarm option from the main menu.
9 2. Then enter the minimum and maximum
10 values.
11 3. Once you are done, the new settings will be uploaded to the Device.
12 4. Lastly, go back to the main menu and start reading values in Continuous Mode
13 Note: Alerts only respond when conversion is done. Therefore, in continuous
14 mode the alerts will constantly be updated.
15
16 Reading and Clearing Alarm Faults:
17 1. Select the View/Clear option from the main menu.
18 2. Select the Clear Faults option. This will clear all faults.
19
20 NOTES
21 Setup:
22 Set the terminal baud rate to 115200 and select the newline terminator.
23 Requires a power supply.
24 Refer to demo manual DC2024.
25
26 USER INPUT DATA FORMAT:
27 decimal : 1024
28 hex : 0x400
29 octal : 02000 (leading 0 "zero")
30 binary : B10000000000
31 float : 1024.0
32
33 @endverbatim
34
35 http://www.linear.com/product/LTC4282
36
37 http://www.linear.com/product/LTC4282#demoboards
38
39
40 Copyright 2018(c) Analog Devices, Inc.
41
42 All rights reserved.
43
44 Redistribution and use in source and binary forms, with or without
45 modification, are permitted provided that the following conditions are met:
46 - Redistributions of source code must retain the above copyright
47 notice, this list of conditions and the following disclaimer.
48 - Redistributions in binary form must reproduce the above copyright
49 notice, this list of conditions and the following disclaimer in
50 the documentation and/or other materials provided with the
51 distribution.
52 - Neither the name of Analog Devices, Inc. nor the names of its
53 contributors may be used to endorse or promote products derived
54 from this software without specific prior written permission.
55 - The use of this software may or may not infringe the patent rights
56 of one or more patent holders. This license does not release you
57 from the requirement that you obtain separate licenses from these
58 patent holders to use this software.
59 - Use of the software either in source or binary form, must be run
60 on or directly connected to an Analog Devices Inc. component.
61
62 THIS SOFTWARE IS PROVIDED BY ANALOG DEVICES "AS IS" AND ANY EXPRESS OR
63 IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, NON-INFRINGEMENT,
64 MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
65 IN NO EVENT SHALL ANALOG DEVICES BE LIABLE FOR ANY DIRECT, INDIRECT,
66 INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
67 LIMITED TO, INTELLECTUAL PROPERTY RIGHTS, PROCUREMENT OF SUBSTITUTE GOODS OR
68 SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
69 CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
70 OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
71 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
72 */
73
74 /*! @file
75 @ingroup LTC4282
76 */
77
78 #include <Arduino.h>
79 #include <stdint.h>
80 #include "Linduino.h"
81 #include "LT_I2C.h"
82 #include "UserInterface.h"
83 #include "QuikEval_EEPROM.h"
84 #include "LTC4282.h"
85 #include <Wire.h>
86 #include <SPI.h>
87
88 // Function Declaration
89 void print_title(); // Print the title block
90 void print_prompt(); // Print the Prompt
91 int8_t menu_1_continuous_mode(uint8_t CTRLA, uint8_t ILIM_ADJUST, uint8_t CLK_DECIMATOR, float resister); //! Continuous Mode Measurement
92 int8_t menu_2_alarm_thresholds(uint8_t CTRLREG_LSB); //! Set Alarm Thresholds
93 int8_t menu_3_view_clear_faults(); //! View/Clear Faults
94 int8_t menu_3_view_faults_menu_1(); //! View Faults
95 int8_t menu_3_clear_faults_menu_2(); //! Clear Faults
96 int8_t menu_4_set_alert_registers(); //! Set Alert Registers
97 int8_t menu_4_set_alert_msb_register_menu_1(); //! Set Alert MSB Register
98 int8_t menu_4_set_alert_lsb_register_menu_2(); //! Set Alert LSB Register
99 int8_t menu_5_settings(uint8_t *CTRLREG_MSB, uint8_t *CTRLREG_LSB, uint8_t *ILIM_ADJUST, uint8_t *CLK_DECIMATOR); //! Settings
100 int8_t menu_5_set_control_msb_register_menu_1(uint8_t *CTRLREG_MSB); //! Control MSB Register Menu. Configure OV/UV/OC Autoretry, FET ON, Mass Write Enable, ON/ENB, ON DELAY and ON FAULT MASK.
101 int8_t menu_5_set_control_lsb_register_menu_2(uint8_t *CTRLREG_LSB); //! Control LSB Register Menu. Configure Thresholds for POWER GOOD/OV/UV as well as for VIN MODE.
102 uint8_t menu_5_set_ilim_adjust_register_menu_3(uint8_t *ILIM_ADJUST); // ILIM ADJUST Register Menu. Configure Current Limit/Foldback Mode/ADC Voltage Monitoring/16 or 12-bit Mode
103 uint8_t menu_5_configure_GPIO_pins_menu_4(); //! Configure State of GPIO Pins. Set GPIO1 as POWERGOOD/POWERBAD/GPO/GPI, OverFlow Alert, GPIO2 Stress Mode etc.
104 uint8_t menu_5_write_register_values_to_EEPROM_menu_5(); //! Write Values currently present in the Registers of the LTC4282 to the EEPROM
105 uint8_t menu_5_restore_register_values_from_EEPROM_menu_6(); //! Restore Values Currently Present in the EEPROM to the Registers of the LTC4282
106
107
108
109 #define CONTINUOUS_MODE_DISPLAY_DELAY 2000 //!< The delay between readings
110
111 const float resistor = 343.7E-6; //!< resistor value on demo board
112 const int CLK_DIVIDER= 0x08; //!< CLK Frequency
113 float voltage_fullscale; //!< Fullscale Voltage Setting Shared Across Functions For Polling Routines
114
115 //static float LTC4282_TIME_lsb = 16.39543E-3; //!< Static variable which is based off of the default clk frequency of 250KHz.
116
117 // Error string
118 const char ack_error[] = "Error: No Acknowledge. Check I2C Address."; //!< Error message
119
120 // Global variables
121 static int8_t demo_board_connected; //!< Set to 1 if the board is connected
122
123 // Function Definitions
124 //! Print the title block
125 void print_title()
126 {
127 Serial.println(F("\n*****************************************************************"));
128 Serial.print(F("* DC2024 Demonstration Program *\n"));
129 Serial.print(F("* *\n"));
130 Serial.print(F("* This program communicates with the LTC4282 High Current *\n"));
131 Serial.print(F("* Hot-Swap Controller with I2C Monitoring Capability found on *\n"));
132 Serial.print(F("* the DC2024 Demoboard. *\n"));
133 Serial.print(F("* Set the baud rate to 115200 and select the newline terminator.*\n"));
134 Serial.print(F("* *\n"));
135 Serial.print(F("*****************************************************************\n"));
136 }
137
138 //! Print the Prompt
139 void print_prompt()
140 {
141 Serial.print(F("\n1-Continuous Mode\n"));
142 Serial.print(F("2-Set Alarm Thresholds\n"));
143 Serial.print(F("3-View/Clear Faults\n"));
144 Serial.print(F("4-Set Alert Registers\n"));
145 Serial.print(F("5-Device Settings\n"));
146 Serial.print(F("Enter a command: "));
147 }
148
149
150
151 //! Initialize Linduino
152 void setup()
153 {
154 char demo_name[] = "DC2024A"; // Demo Board Name stored in QuikEval EEPROM
155
156 quikeval_I2C_init(); //! Configure the EEPROM I2C port for 100kHz
157 quikeval_I2C_connect(); //! Connects to main I2C port
158 Serial.begin(115200); //! Initialize the serial port to the PC
159 print_title(); //! Print Title
160 demo_board_connected = discover_demo_board(demo_name);
161 if (!demo_board_connected)
162 {
163 Serial.println(F("Demo board not detected, will attempt to proceed"));
164 demo_board_connected = true;
165 }
166 if (demo_board_connected)
167 {
168 print_prompt();
169 }
170 }
171
172
173 void loop()
174 {
175 int8_t ack = 0; // I2C acknowledge indicator
176
177 static uint8_t user_command; //!< Initialize User Input Vairiable.
178
179
180 //! Initialize Default Values in Control and Configuration Registers. See Datasheet for more information.
181 static uint8_t CTRLREG_MSB = LTC4282_ON_FAULT_MASK|LTC4282_ON_ENB|LTC4282_MASS_WRITE|LTC4282_FET_ON|LTC4282_UV_AUTORETRY|LTC4282_OV_AUTORETRY;
182 static uint8_t CTRLREG_LSB = LTC4282_VIN_MODE_12_V;
183 static uint8_t ILIM_ADJUST = (LTC4282_ILIM_ADJUST_25_V_0|LTC4282_FOLDBACK_MODE_12_V_0|LTC4282_ADC_VSOURCE|LTC4282_ADC_GPIO2_MODE)& ~LTC4282_ADC_16_BIT;
184 static uint8_t CLK_DECIMATOR = (CLK_DIVIDER)&~LTC4282_COULOMB_METER&~LTC4282_TICK_OUT&~LTC4282_INT_CLK_OUT;
185 static uint8_t GPIO_CONFIG = LTC4282_GPIO1_CONFIG_INPUT;
186
187 if (demo_board_connected) //! Do nothing if the demo board is not connected
188 {
189 ack |= LTC4282_write(LTC4282_I2C_ADDRESS, LTC4282_CONTROL_MSB_REG, CTRLREG_MSB);
190 ack |= LTC4282_write(LTC4282_I2C_ADDRESS, LTC4282_CONTROL_LSB_REG, CTRLREG_LSB);
191 ack |= LTC4282_write(LTC4282_I2C_ADDRESS, LTC4282_ILIM_ADJUST_REG, ILIM_ADJUST);
192 ack |= LTC4282_write(LTC4282_I2C_ADDRESS, LTC4282_CLK_DEC_REG, CLK_DECIMATOR);
193 ack |= LTC4282_write(LTC4282_I2C_ADDRESS, LTC4282_GPIO_CONFIG_REG, GPIO_CONFIG);
194
195 if (Serial.available()) //! Do nothing if serial is not available
196 {
197 user_command = read_int(); //! Read user input command
198 if (user_command != 'm')
199 Serial.println(user_command);
200 Serial.println();
201 ack = 0;
202 switch (user_command)
203 {
204 case 1:
205 ack |= menu_1_continuous_mode(CTRLREG_LSB, ILIM_ADJUST, CLK_DECIMATOR, resistor); //! Continuous Mode Measurement
206 break ;
207 case 2:
208 ack |= menu_2_alarm_thresholds(CTRLREG_LSB); //! Set Alarm Thresholds
209 break;
210 case 3:
211 ack |= menu_3_view_clear_faults(); //! View/Clear Faults
212 break;
213 case 4:
214 ack |= menu_4_set_alert_registers(); //! Set Alert Registers
215 break;
216 case 5:
217 menu_5_settings(&CTRLREG_MSB, &CTRLREG_MSB, &ILIM_ADJUST, &CLK_DECIMATOR); //! Settings
218 break;
219 default:
220 Serial.println("Incorrect Option");
221 break;
222 }
223 if (ack != 0)
224 Serial.println(ack_error);
225 Serial.print(F("*************************"));
226 print_prompt();
227 }
228 }
229 }
230
231 //! Continious Mode
232 int8_t menu_1_continuous_mode(uint8_t CTRLREG_LSB, //!< Control LSB Register Code. Necessary to Check which Voltage Mode the Part is set to. Configured in Settings Menu.
233 uint8_t ILIM_ADJUST, //!< ILIM_ADJUST Register Code. Necessary to Check Whether the Part is Configured as a Coulomb Meter or an Energy Meter. Also Checks Resolution Mode. Configured in Settings Menu.
234 uint8_t CLK_DECIMATOR, //!< CLK_DECIMATOR Register Code. Sets the Clock Rate for the Energy/Coulomb Meter. Configured in the Settings Menu.
235 float resistor)
236 //! @return Returns the state of the acknowledge bit after the I2C write/read. 0 = acknowledge, 1 = no acknowledge.
237 {
238
239 int8_t ack = 0;
240
241 uint16_t voltage_code;
242 uint16_t current_code;
243 uint16_t power_code;
244 uint32_t time_code;
245 uint64_t meter_code;
246
247 float tConv; //!< Conversion Time Period
248
249 //! Check to see if the part is in 16-bit or 12-bit mode. Then Set the Time Period Accordingly.
250 if (ILIM_ADJUST & LTC4282_ADC_16_BIT)
251 {
252 tConv = 1.0486;
253 }
254 else
255 {
256 tConv = 65.535E-3;
257 }
258
259 //! Check to See if VIN Mode is Set to 3.3V, 5V, 12V and/or 12V. Then Set the Appropriate Fullscale Voltage
260 if ((CTRLREG_LSB & LTC4282_VIN_MODE_24_V) == LTC4282_VIN_MODE_24_V)
261 {
262
263 voltage_fullscale = LTC4282_VSOURCE_24V_FS;
264
265 }
266 else if ((CTRLREG_LSB & LTC4282_VIN_MODE_12_V) == LTC4282_VIN_MODE_12_V)
267 {
268
269 voltage_fullscale = LTC4282_VSOURCE_12V_FS;
270
271 }
272 else if ((CTRLREG_LSB & LTC4282_VIN_MODE_5_V) == LTC4282_VIN_MODE_5_V)
273 {
274
275 voltage_fullscale = LTC4282_VSOURCE_5V_FS;
276
277 }
278 else
279 {
280
281 voltage_fullscale = LTC4282_VSOURCE_3V3_FS;
282
283 }
284
285 //! Keep Polling Till the User Presses 'm'
286 do
287 {
288
289 uint8_t adc_alert_log;
290 ack |= LTC4282_read(LTC4282_I2C_ADDRESS, LTC4282_ADC_ALERT_LOG_REG, &adc_alert_log); //!<Read ADC Alert Log To Keep Track of Alerts
291
292 float vsource, vsource_min, vsource_max;
293
294 ack |= LTC4282_read_16_bits(LTC4282_I2C_ADDRESS, LTC4282_VSOURCE_MSB_REG, &voltage_code); //!< Read Voltage Code From VSOURCE Register
295 vsource = LTC4282_code_to_voltage(voltage_code, voltage_fullscale); //!< Convert Voltage Code to Current Source Voltage
296 ack |= LTC4282_read_16_bits(LTC4282_I2C_ADDRESS, LTC4282_VSOURCE_MAX_MSB_REG, &voltage_code); //!< Read Voltage Code From VSOURCE MAX Register
297 vsource_max = LTC4282_code_to_voltage(voltage_code, voltage_fullscale); //!< Convert Voltage Code to Maximum Source Voltage
298 ack |= LTC4282_read_16_bits(LTC4282_I2C_ADDRESS, LTC4282_VSOURCE_MIN_MSB_REG, &voltage_code); //!< Read Voltage Code From VSOURCE MIN Register
299 vsource_min = LTC4282_code_to_voltage(voltage_code, voltage_fullscale); //!< Convert Voltage Code to Minimum Source Voltage
300
301
302 float vgpio, vgpio_min, vgpio_max;
303
304 ack |= LTC4282_read_16_bits(LTC4282_I2C_ADDRESS, LTC4282_VGPIO_MSB_REG, &voltage_code); //!< Read Voltage Code From VGPIO Register
305 vgpio = LTC4282_code_to_VGPIO(voltage_code); //!< Convert Voltage Code to VGPIO Voltage
306 ack |= LTC4282_read_16_bits(LTC4282_I2C_ADDRESS, LTC4282_VGPIO_MAX_MSB_REG, &voltage_code); //!< Read Voltage Code From VGPIO MAX Register
307 vgpio_max = LTC4282_code_to_VGPIO(voltage_code); //!< Convert Voltage Code to Maximum VGPIO Voltage
308 ack |= LTC4282_read_16_bits(LTC4282_I2C_ADDRESS, LTC4282_VGPIO_MIN_MSB_REG, &voltage_code); //!< Read Voltage Code From VGPIO MIN Register
309 vgpio_min = LTC4282_code_to_VGPIO(voltage_code); //!< Convert Voltage Code to Minimum VGPIO Voltage
310
311
312 float current, current_min, current_max;
313
314 ack |= LTC4282_read_16_bits(LTC4282_I2C_ADDRESS, LTC4282_VSENSE_MSB_REG, &current_code); //!< Read Current Code From VSENSE Register
315 current = LTC4282_code_to_current(current_code, resistor); //!< Convert Current Code to Current
316 ack |= LTC4282_read_16_bits(LTC4282_I2C_ADDRESS, LTC4282_VSENSE_MAX_MSB_REG, &current_code); //!< Read Current Code From VSENSE MAX Register
317 current_max = LTC4282_code_to_current(current_code, resistor); //!< Convert Current Code to Maximum Current
318 ack |= LTC4282_read_16_bits(LTC4282_I2C_ADDRESS, LTC4282_VSENSE_MIN_MSB_REG, &current_code); //!< Read Current Code From VSENSE MIN Register
319 current_min = LTC4282_code_to_current(current_code, resistor); //!< Convert Current Code to Minimum Current
320
321
322 float power, power_min, power_max;
323
324 ack |= LTC4282_read_16_bits(LTC4282_I2C_ADDRESS, LTC4282_POWER_MSB_REG, &power_code); //!< Read Power Code From Power Register
325 power = LTC4282_code_to_power(power_code,voltage_fullscale, resistor); //!< Convert Power Code to Power
326 ack |= LTC4282_read_16_bits(LTC4282_I2C_ADDRESS, LTC4282_POWER_MAX_MSB_REG, &power_code); //!< Read Power Code From POWER MAX Register
327 power_max = LTC4282_code_to_power(current_code, voltage_fullscale, resistor); //!< Convert Power Code to Maximum Power
328 ack |= LTC4282_read_16_bits(LTC4282_I2C_ADDRESS, LTC4282_POWER_MIN_MSB_REG, &power_code); //!< Read Power Code From POWER MIN Register
329 power_min = LTC4282_code_to_power(current_code, voltage_fullscale, resistor); //!< Convert Power Code to Minimum Power
330
331
332 ack|= LTC4282_read_32_bits(LTC4282_I2C_ADDRESS, LTC4282_TICK_COUNTER_MSB3_REG, &time_code); //!< Read Minimum Time Code
333
334 //! Display Min, Current And Max Voltage
335 Serial.println(F("***********Voltage************"));
336 Serial.print(F("Min Voltage: "));
337 Serial.print(vsource_min);
338 Serial.print(F("V\n"));
339 Serial.print(F("Reading: "));
340 Serial.print(vsource);
341 Serial.print(F("V\n"));
342 Serial.print(F("Max Voltage: "));
343 Serial.print(vsource_max);
344 Serial.println(F("V"));
345 Serial.print(F("\n"));
346
347 //! If the Minimum or Maximum Threshold has been Exceeded Then Alert the User
348 if (adc_alert_log & LTC4282_VSOURCE_ALARM_HIGH)
349 {
350 Serial.print(F("ALERT - VOLTAGE MAXIMUM THRESHOLD EXCEEDED\n"));
351 }
352 if (adc_alert_log & LTC4282_VSOURCE_ALARM_LOW)
353 {
354 Serial.print(F("ALERT - VOLTAGE MINIMUM THRESHOLD EXCEEDED\n"));
355 }
356
357 Serial.print(F("\n"));
358
359 //! Display Min, Current And Max Current
360 Serial.println(F("***********Current************"));
361 Serial.print(F("Min Current: "));
362 Serial.print(current_min);
363 Serial.println(F("A"));
364 Serial.print(F("Reading : "));
365 Serial.print(current);
366 Serial.println(F("A"));
367 Serial.print(F("Max Current: "));
368 Serial.print(current_max);
369 Serial.println(F("A"));
370
371 //! If the Minimum or Maximum Threshold has been Exceeded Then Alert the User
372 if (adc_alert_log & LTC4282_VSENSE_ALARM_HIGH)
373 {
374 Serial.print(F("ALERT - CURRENT MAXIMUM THRESHOLD EXCEEDED\n"));
375 }
376 if (adc_alert_log & LTC4282_VSENSE_ALARM_LOW)
377 {
378 Serial.print(F("ALERT - CURRENT MINIMUM THRESHOLD EXCEEDED\n"));
379 }
380
381 Serial.print(F("\n"));
382
383 //! Display Min, Current And Max VGPIO
384 Serial.println(F("***********VGPIO************"));
385 Serial.print(F("Min VGPIO: "));
386 Serial.print(vgpio_min);
387 Serial.println(F("V"));
388 Serial.print(F("Reading : "));
389 Serial.print(vgpio);
390 Serial.println(F("V"));
391 Serial.print(F("Max VGPIO: "));
392 Serial.print(vgpio_max);
393 Serial.println(F("V"));
394
395 //! If the Minimum or Maximum Threshold has been Exceeded Then Alert the User
396 if (adc_alert_log & LTC4282_VGPIO_ALARM_HIGH)
397 {
398 Serial.print(F("ALERT - VGPIO MAXIMUM THRESHOLD EXCEEDED\n"));
399 }
400 if (adc_alert_log & LTC4282_VGPIO_ALARM_LOW)
401 {
402 Serial.print(F("ALERT - VGPIO MINIMUM THRESHOLD EXCEEDED\n"));
403 }
404
405 Serial.print(F("\n"));
406
407 //! Display Min, Current And Max VGPIO
408 Serial.println(F("***********Power************"));
409 Serial.print(F("Min Power: "));
410 Serial.print(power_min);
411 Serial.println(F("W"));
412 Serial.print(F("Reading : "));
413 Serial.print(power);
414 Serial.println(F("W"));
415 Serial.print(F("Max Power: "));
416 Serial.print(power_max);
417 Serial.println(F("W"));
418
419 //! If the Minimum or Maximum Threshold has been Exceeded Then Alert the User
420 if (adc_alert_log & LTC4282_POWER_ALARM_HIGH)
421 {
422 Serial.print(F("ALERT - POWER MAXIMUM THRESHOLD EXCEEDED\n"));
423 }
424 if (adc_alert_log & LTC4282_POWER_ALARM_LOW)
425 {
426 Serial.print(F("ALERT - POWER MINIMUM THRESHOLD EXCEEDED\n"));
427 }
428
429 Serial.print(F("\n"));
430
431 //! If Device Is Set To Accumulate Coulombs, Then Calculate Coulombs and Average Current
432 if (CLK_DECIMATOR & LTC4282_COULOMB_METER)
433 {
434
435 float coulombs;
436 ack |= LTC4282_read_48_bits(LTC4282_I2C_ADDRESS, LTC4282_METER_MSB5_REG, &meter_code);
437 coulombs = LTC4282_code_to_coulombs(meter_code, resistor, tConv);
438
439 float avg_current;
440 avg_current = LTC4282_code_to_avg_current(time_code, coulombs, tConv);
441 Serial.println(F("***********Coulombs************"));
442 Serial.print(F("Meter: "));
443 Serial.print(coulombs);
444 Serial.println(F("C"));
445 Serial.print(F("Avg Current : "));
446 Serial.print(avg_current);
447 Serial.println(F("A"));
448
449 }
450 //! Else Calculate Energy and Average Power
451 else
452 {
453 float energy;
454 ack |= LTC4282_read_48_bits(LTC4282_I2C_ADDRESS, LTC4282_METER_MSB5_REG, &meter_code);
455 energy = LTC4282_code_to_energy(meter_code, voltage_fullscale, resistor, tConv);
456
457 float avg_power;
458 avg_power = LTC4282_code_to_avg_power(time_code, energy, tConv);
459
460 Serial.println(F("***********Energy************"));
461 Serial.print(F("Meter: "));
462 Serial.print(energy);
463 Serial.println(F("J"));
464 Serial.print(F("Avg Power : "));
465 Serial.print(avg_power);
466 Serial.println(F("W"));
467
468 }
469
470 Serial.println(F("\n"));
471
472 //! Display Time
473 Serial.println(F("***********Time************"));
474 Serial.print(F("Internal Time: "));
475 Serial.print(time_code*tConv);
476 Serial.println(F("S"));
477
478 Serial.println(F("\n"));
479
480 Serial.flush();
481 delay(CONTINUOUS_MODE_DISPLAY_DELAY);
482
483 }
484 while (Serial.available() == false);
485 read_int();
486 return(ack);
487
488 }
489
490 //! Set Alarm Thresholds
491 int8_t menu_2_alarm_thresholds(uint8_t CTRLREG_LSB //!< Control LSB Value Passed On to Determine VIN MODE For Proper Voltage Conversion Of Thresholds. )
492 )
493 //! @return Returns the state of the acknowledge bit after the I2C write/read. 0 = acknowledge, 1 = no acknowledge.
494 {
495 //! Initializing Variables
496 uint8_t ack = 0;
497 uint8_t alarm_reg_code = 0;
498 float alarmValue, voltage_fullscale;
499
500 //! Determine LTC4282 VIN MODE And Set Appropriate FullScale Voltage
501 if ((CTRLREG_LSB & LTC4282_VIN_MODE_24_V) == LTC4282_VIN_MODE_24_V)
502 {
503 voltage_fullscale = LTC4282_VSOURCE_24V_FS;
504 }
505 else if ((CTRLREG_LSB & LTC4282_VIN_MODE_12_V) == LTC4282_VIN_MODE_12_V)
506 {
507 voltage_fullscale = LTC4282_VSOURCE_12V_FS;
508 }
509 else if ((CTRLREG_LSB & LTC4282_VIN_MODE_5_V) == LTC4282_VIN_MODE_5_V)
510 {
511 voltage_fullscale = LTC4282_VSOURCE_5V_FS;
512 }
513 else
514 {
515 voltage_fullscale = LTC4282_VSOURCE_3V3_FS;
516 }
517
518
519 //! Display Thresholds Currently Present Within The LTC4282 Threshold Registers
520 Serial.println(F("****CURRENT THRESHOLDS****"));
521 ack |= LTC4282_read(LTC4282_I2C_ADDRESS, LTC4282_VSOURCE_ALARM_MAX_REG, &alarm_reg_code);
522 alarmValue = LTC4282_code_to_volt_alarm(alarm_reg_code, voltage_fullscale);
523 Serial.print(F("Voltage Maximum Alarm = "));
524 Serial.print(alarmValue);
525 Serial.println(F("V"));
526
527 ack |= LTC4282_read(LTC4282_I2C_ADDRESS, LTC4282_VSOURCE_ALARM_MIN_REG, &alarm_reg_code);
528 alarmValue = LTC4282_code_to_volt_alarm(alarm_reg_code, voltage_fullscale);
529 Serial.print(F("Voltage Minimum Alarm = "));
530 Serial.print(alarmValue);
531 Serial.println(F("V"));
532
533 ack |= LTC4282_read(LTC4282_I2C_ADDRESS, LTC4282_VSENSE_ALARM_MAX_REG, &alarm_reg_code);
534 alarmValue = LTC4282_code_to_current_alarm(alarm_reg_code, resistor);
535 Serial.print(F("Current Maximum Alarm = "));
536 Serial.print(alarmValue);
537 Serial.println(F("A"));
538
539 ack |= LTC4282_read(LTC4282_I2C_ADDRESS, LTC4282_VSENSE_ALARM_MIN_REG, &alarm_reg_code);
540 alarmValue = LTC4282_code_to_current_alarm(alarm_reg_code, resistor);
541 Serial.print(F("Current Minimum Alarm = "));
542 Serial.print(alarmValue);
543 Serial.println(F("A"));
544
545 ack |= LTC4282_read(LTC4282_I2C_ADDRESS, LTC4282_VGPIO_ALARM_MAX_REG, &alarm_reg_code);
546 alarmValue = LTC4282_code_to_GPIO_alarm(alarm_reg_code);
547 Serial.print(F("VGPIO Maximum Alarm = "));
548 Serial.print(alarmValue);
549 Serial.println(F("V"));
550
551 ack |= LTC4282_read(LTC4282_I2C_ADDRESS, LTC4282_VGPIO_ALARM_MIN_REG, &alarm_reg_code);
552 alarmValue = LTC4282_code_to_GPIO_alarm(alarm_reg_code);
553 Serial.print(F("VGPIO Minimum Alarm = "));
554 Serial.print(alarmValue);
555 Serial.println(F("V\n"));
556
557 ack |= LTC4282_read(LTC4282_I2C_ADDRESS, LTC4282_POWER_ALARM_MAX_REG, &alarm_reg_code);
558 alarmValue = LTC4282_code_to_power_alarm(alarm_reg_code, voltage_fullscale, resistor);
559 Serial.print(F("Power Maximum Alarm = "));
560 Serial.print(alarmValue);
561 Serial.println(F("W\n"));
562
563 Serial.println(alarm_reg_code);
564
565 ack |= LTC4282_read(LTC4282_I2C_ADDRESS, LTC4282_POWER_ALARM_MIN_REG, &alarm_reg_code);
566 alarmValue = LTC4282_code_to_power_alarm(alarm_reg_code, voltage_fullscale, resistor);
567 Serial.print(F("Power Minimum Alarm = "));
568 Serial.print(alarmValue);
569 Serial.println(F("W\n"));
570
571 //! Enter New Thresholds to Store Within the LTC4282 Alarm Thresholds.
572 Serial.println(F("****ENTER THRESHOLD VALUES****"));
573 Serial.print(F("Enter Voltage Maximum Alarm = "));
574 float voltage_maximum = read_float();
575 Serial.println(voltage_maximum);
576 Serial.print(F("Enter Voltage Minimum Alarm = "));
577 float voltage_minimum = read_float();
578 Serial.println(voltage_minimum);
579 Serial.print(F("Enter Current Maximum Alarm = "));
580 float current_maximum = read_float();
581 Serial.println(current_maximum);
582 Serial.print(F("Enter Current Minimum Alarm = "));
583 float current_minimum = read_float();
584 Serial.println(current_minimum);
585 Serial.print(F("Enter VGPIO Maximum Alarm = "));
586 float vgpio_maximum = read_float();
587 Serial.println(vgpio_maximum);
588 Serial.print(F("Enter VGPIO Minimum Alarm = "));
589 float vgpio_minimum = read_float();
590 Serial.println(vgpio_minimum);
591 Serial.print(F("Enter Power Maximum Alarm = "));
592 float power_maximum = read_float();
593 Serial.println(power_maximum);
594 Serial.print(F("Enter Power Minimum Alarm = "));
595 float power_minimum = read_float();
596 Serial.println(power_minimum);
597
598 uint8_t adc_code = 0;
599 //! Convert Values Entered By User Into ADC Codes And Then Write To Appropriate Registers
600 adc_code = LTC4282_volt_to_code_alarm(voltage_maximum, voltage_fullscale);
601 ack |= LTC4282_write(LTC4282_I2C_ADDRESS, LTC4282_VSOURCE_ALARM_MAX_REG, adc_code);
602 adc_code = LTC4282_volt_to_code_alarm(voltage_minimum, voltage_fullscale);
603 ack |= LTC4282_write(LTC4282_I2C_ADDRESS, LTC4282_VSOURCE_ALARM_MIN_REG, adc_code);
604
605 adc_code = LTC4282_current_to_code_alarm(current_maximum, resistor);
606 ack |= LTC4282_write(LTC4282_I2C_ADDRESS, LTC4282_VSENSE_ALARM_MAX_REG, adc_code);
607 adc_code = LTC4282_current_to_code_alarm(current_minimum, resistor);
608 ack |= LTC4282_write(LTC4282_I2C_ADDRESS, LTC4282_VSENSE_ALARM_MIN_REG, adc_code);
609
610 adc_code = LTC4282_VGPIO_to_code_alarm(vgpio_maximum);
611 ack |= LTC4282_write(LTC4282_I2C_ADDRESS, LTC4282_VGPIO_ALARM_MAX_REG, adc_code);
612 adc_code = LTC4282_VGPIO_to_code_alarm(vgpio_minimum);
613 ack |= LTC4282_write(LTC4282_I2C_ADDRESS, LTC4282_VGPIO_ALARM_MIN_REG, adc_code);
614
615 adc_code = LTC4282_power_to_code_alarm(power_maximum, resistor, voltage_fullscale);
616 //Serial.println(adc_code);
617 ack |= LTC4282_write(LTC4282_I2C_ADDRESS, LTC4282_POWER_ALARM_MAX_REG, adc_code);
618 adc_code = LTC4282_power_to_code_alarm(power_minimum, resistor, voltage_fullscale);
619 ack |= LTC4282_write(LTC4282_I2C_ADDRESS, LTC4282_POWER_ALARM_MIN_REG, adc_code);
620
621 adc_code = 00;
622 ack |= LTC4282_write(LTC4282_I2C_ADDRESS, LTC4282_ADC_ALERT_LOG_REG, adc_code);
623
624 return ack;
625
626 }
627
628 //! View Faults And Clear Them
629 int8_t menu_3_view_clear_faults()
630 //! @return Returns the state of the acknowledge bit after the I2C write/read. 0 = acknowledge, 1 = no acknowledge.
631 {
632
633 int8_t ack = 0;
634
635 uint8_t user_command;
636
637 do
638 {
639 Serial.print(F("****Fault Menu****\n\n"));
640 Serial.print(F("1 - View Faults\n"));
641 Serial.print(F("2 - Clear All Faults\n"));
642 Serial.print(F("m-Main Menu\n"));
643
644 Serial.print(F("\n\nEnter a Command: "));
645 user_command = read_int();
646 if (user_command == 'm')
647 Serial.println("m");
648 else
649 {
650 Serial.println(user_command);
651 }
652
653 Serial.println();
654 switch (user_command)
655 {
656 case 1: // View Faults
657 ack |= menu_3_view_faults_menu_1();
658 break;
659
660 case 2: // Clear Faults
661 ack |= menu_3_clear_faults_menu_2();
662 break;
663 default:
664 if (user_command != 'm')
665 Serial.println("Incorrect Option");
666 break;
667 }
668
669 }
670 while (!((user_command == 'm') || (ack)));
671
672 return ack;
673 }
674
675 //! View Faults
676 int8_t menu_3_view_faults_menu_1()
677 //! @return Returns the state of the acknowledge bit after the I2C write/read. 0 = acknowledge, 1 = no acknowledge.
678 {
679
680 int8_t ack = 0;
681
682 uint8_t fault_code = 0;
683 uint8_t adc_alert_code = 0;
684
685 //! Read Both Fault Log Register and ADC Alert Log Register
686 ack |= LTC4282_read(LTC4282_I2C_ADDRESS, LTC4282_FAULT_LOG_REG, &fault_code);
687 ack |= LTC4282_read(LTC4282_I2C_ADDRESS, LTC4282_ADC_ALERT_LOG_REG, &adc_alert_code);
688
689 //! Display FAULT LOG Register
690 Serial.print(F("****FAULT LOG****\n"));
691
692 if (fault_code == 0)
693 {
694 Serial.println(F("NO FAULTS LOGGED"));
695 }
696 else
697 {
698 if ((fault_code & LTC4282_EEPROM_DONE_ALERT) != 0)
699 {
700 Serial.println(F("EEPROM DONE = TRUE"));
701 }
702 if ((fault_code & LTC4282_FET_BAD_FAULT_ALERT) != 0)
703 {
704 Serial.println(F("FET BAD FAULT = TRUE"));
705 }
706 if ((fault_code & LTC4282_FET_SHORT_ALERT) != 0)
707 {
708 Serial.println(F("FET SHORT FAULT = TRUE"));
709 }
710 if ((fault_code & LTC4282_ON_ALERT) != 0)
711 {
712 Serial.println(F("ON PIN FAULT = True"));
713 }
714 if ((fault_code & LTC4282_PB_ALERT) != 0)
715 {
716 Serial.println(F("POWER BAD FAULT = TRUE"));
717 }
718 if ((fault_code & LTC4282_OC_ALERT) != 0)
719 {
720 Serial.println(F("OVER CURRENT FAULT = TRUE"));
721 }
722 if ((fault_code & LTC4282_UV_ALERT) != 0)
723 {
724 Serial.println(F("UNDER VOLTAGE FAULT = TRUE"));
725 }
726 if ((fault_code & LTC4282_OV_ALERT) != 0)
727 {
728 Serial.println(F("OVER VOLTAGE FAULT = TRUE"));
729 }
730 }
731
732 //! Display ADC Alert Log Register
733 Serial.print(F("\n****ADC ALERT LOG****\n"));
734
735 if (adc_alert_code == 0)
736 {
737 Serial.println(F("NO ALERTS LOGGED"));
738 }
739 else
740 {
741 if ((adc_alert_code & LTC4282_POWER_ALARM_HIGH) != 0)
742 {
743 Serial.println(F("ALERT - POWER ALARM HIGH"));
744 }
745 if ((adc_alert_code & LTC4282_POWER_ALARM_LOW) != 0)
746 {
747 Serial.println(F("ALERT - POWER ALARM LOW"));
748 }
749 if ((adc_alert_code & LTC4282_VSENSE_ALARM_HIGH ) != 0)
750 {
751 Serial.println(F("ALERT - VSENSE ALARM HIGH"));
752 }
753 if ((adc_alert_code & LTC4282_VSENSE_ALARM_LOW ) != 0)
754 {
755 Serial.println(F("ALERT - VSENSE ALARM LOW"));
756 }
757 if ((adc_alert_code & LTC4282_VSOURCE_ALARM_HIGH) != 0)
758 {
759 Serial.println(F("ALERT - VSOURCE ALARM HIGH"));
760 }
761 if ((adc_alert_code & LTC4282_VSOURCE_ALARM_LOW) != 0)
762 {
763 Serial.println(F("ALERT - VSOURCE ALARM LOW"));
764 }
765 if ((adc_alert_code & LTC4282_VGPIO_ALARM_HIGH) != 0)
766 {
767 Serial.println(F("ALERT - VGPIO ALARM HIGH"));
768 }
769 if ((adc_alert_code & LTC4282_VGPIO_ALARM_LOW ) != 0)
770 {
771 Serial.println(F("ALERT VGPIO ALARM LOW\n"));
772 }
773 }
774
775 Serial.println(F("\n***************************************\n"));
776
777 return ack;
778 }
779
780 //! Clear Faults
781 int8_t menu_3_clear_faults_menu_2()
782 //! @return Returns the state of the acknowledge bit after the I2C write/read. 0 = acknowledge, 1 = no acknowledge.
783 {
784
785 int8_t ack = 0;
786 uint8_t fault_code = 0x00;
787 uint8_t adc_alert_code = 0x00;
788 ack |= LTC4282_write(LTC4282_I2C_ADDRESS, LTC4282_FAULT_LOG_REG, fault_code);
789 ack |= LTC4282_write(LTC4282_I2C_ADDRESS, LTC4282_ADC_ALERT_LOG_REG, adc_alert_code);
790
791 Serial.println("ALL FAULTS CLEARED");
792
793 return ack;
794 }
795
796 //! Set Alert Register Menu
797 int8_t menu_4_set_alert_registers()
798 //! @return Returns the state of the acknowledge bit after the I2C write/read. 0 = acknowledge, 1 = no acknowledge.
799 {
800
801 uint8_t ack = 0;
802
803 uint8_t user_command;
804
805 uint16_t alert_code;
806
807 do
808 {
809
810 Serial.print(F("****Alert Register Menu****\n\n"));
811 Serial.print(F("1 - Set Alert MSB Register\n"));
812 Serial.print(F("2 - Set Alert LSB Register\n"));
813 Serial.print(F("m-Main Menu\n"));
814
815 Serial.print(F("\n\nEnter a Command: "));
816 user_command = read_int();
817 if (user_command == 'm')
818 Serial.println("m");
819 else
820 {
821 Serial.println(user_command);
822 }
823
824 Serial.println();
825 switch (user_command)
826 {
827 case 1: // Set Alert MSB Register.
828 ack |= menu_4_set_alert_msb_register_menu_1();
829 break;
830
831 case 2: // Set Alert LSB Register
832 ack |= menu_4_set_alert_lsb_register_menu_2();
833 break;
834 default:
835 if (user_command != 'm')
836 Serial.println("Incorrect Option");
837 break;
838 }
839
840 }
841 while (!((user_command == 'm') || (ack)));
842
843 return ack;
844
845
846 }
847
848 //! Set Alert MSB Register
849 int8_t menu_4_set_alert_msb_register_menu_1()
850 //! @return Returns the state of the acknowledge bit after the I2C write/read. 0 = acknowledge, 1 = no acknowledge.
851 {
852
853 int8_t ack = 0;
854
855 uint8_t ALERTREG = 0;
856
857 ack |= LTC4282_read(LTC4282_I2C_ADDRESS, LTC4282_ALERT_MSB_REG, &ALERTREG);
858
859 Serial.println(F("****SET ALERT REGISTERS****"));
860 Serial.println(F("Use Numeric Commands: No = 0, Yes = 1"));
861 Serial.print(F("ENABLE EEPROM DONE ALERT? = "));
862 int alertEnable = read_int();
863 Serial.println(alertEnable);
864 if (alertEnable)
865 {
866 ALERTREG = ALERTREG | LTC4282_EEPROM_DONE_ALERT;
867 }
868 else
869 {
870 ALERTREG = ALERTREG & ~LTC4282_EEPROM_DONE_ALERT;
871 }
872
873 Serial.print(F("ENABLE FET BAD FAULT ALERT? = "));
874 alertEnable = read_int();
875 Serial.println(alertEnable);
876 if (alertEnable)
877 {
878 ALERTREG = ALERTREG | LTC4282_FET_BAD_FAULT_ALERT;
879 }
880 else
881 {
882 ALERTREG = ALERTREG & ~LTC4282_FET_BAD_FAULT_ALERT;
883 }
884
885 Serial.print(F("ENABLE FET SHORT FAULT? = "));
886 alertEnable = read_int();
887 Serial.println(alertEnable);
888 if (alertEnable)
889 {
890 ALERTREG = ALERTREG | LTC4282_FET_SHORT_ALERT;
891 }
892 else
893 {
894 ALERTREG = ALERTREG & ~LTC4282_FET_SHORT_ALERT;
895 }
896
897 Serial.print(F("ENABLE ON ALERT? = "));
898 alertEnable = read_int();
899 Serial.println(alertEnable);
900 if (alertEnable)
901 {
902 ALERTREG = ALERTREG | LTC4282_ON_ALERT;
903 }
904 else
905 {
906 ALERTREG = ALERTREG & ~LTC4282_ON_ALERT;
907 }
908
909 Serial.print(F("ENABLE POWER BAD FAULT ALERT? = "));
910 alertEnable = read_int();
911 Serial.println(alertEnable);
912 if (alertEnable)
913 {
914 ALERTREG = ALERTREG | LTC4282_PB_ALERT;
915 }
916 else
917 {
918 ALERTREG = ALERTREG & ~LTC4282_PB_ALERT;
919 }
920
921 Serial.print(F("ENABLE OVER CURRENT FAULT ALERT? = "));
922 alertEnable = read_int();
923 Serial.println(alertEnable);
924 if (alertEnable)
925 {
926 ALERTREG = ALERTREG | LTC4282_OC_ALERT;
927 }
928 else
929 {
930 ALERTREG = ALERTREG & ~LTC4282_OC_ALERT;
931 }
932
933 Serial.print(F("ENABLE UNDERVOLTAGE FAULT ALERT? = "));
934 alertEnable = read_int();
935 Serial.println(alertEnable);
936 if (alertEnable)
937 {
938 ALERTREG = ALERTREG | LTC4282_UV_ALERT;
939 }
940 else
941 {
942 ALERTREG = ALERTREG & ~LTC4282_UV_ALERT;
943 }
944
945 Serial.print(F("ENABLE OVERVOLTAGE FAULT ALERT? = "));
946 alertEnable = read_int();
947 Serial.println(alertEnable);
948 if (alertEnable)
949 {
950 ALERTREG = ALERTREG | LTC4282_OV_ALERT;
951 }
952 else
953 {
954 ALERTREG = ALERTREG & ~LTC4282_OV_ALERT;
955 }
956
957 ack |= LTC4282_write(LTC4282_I2C_ADDRESS, LTC4282_ALERT_MSB_REG, ALERTREG);
958
959 Serial.println(F("Alert MSB Register Updated\n"));
960
961 return ack;
962
963 }
964
965 // Set Alert LSB Register
966 int8_t menu_4_set_alert_lsb_register_menu_2()
967 //! @return Returns the state of the acknowledge bit after the I2C write/read. 0 = acknowledge, 1 = no acknowledge.
968 {
969 int ack = 0;
970 uint8_t ALERTREG = 0;
971
972 ack |= LTC4282_read(LTC4282_I2C_ADDRESS, LTC4282_ALERT_LSB_REG, &ALERTREG);
973
974 Serial.println(F("****SET ALERT REGISTERS****"));
975 Serial.println(F("Use Numeric Commands: No = 0, Yes = 1"));
976 Serial.print(F("ENABLE POWER ALARM HIGH ALERT? = "));
977 int alertEnable = read_int();
978 Serial.println(alertEnable);
979 if (alertEnable)
980 {
981 ALERTREG = ALERTREG | LTC4282_POWER_ALARM_HIGH;
982 }
983 else
984 {
985 ALERTREG = ALERTREG & ~LTC4282_POWER_ALARM_HIGH;
986 }
987
988 Serial.print(F("ENABLE POWER ALARM LOW ALERT? = "));
989 alertEnable = read_int();
990 Serial.println(alertEnable);
991 if (alertEnable)
992 {
993 ALERTREG = ALERTREG | LTC4282_POWER_ALARM_LOW;
994 }
995 else
996 {
997 ALERTREG = ALERTREG & ~LTC4282_POWER_ALARM_LOW;
998 }
999
1000 Serial.print(F("ENABLE VSENSE ALARM HIGH ALERT? = "));
1001 alertEnable = read_int();
1002 Serial.println(alertEnable);
1003 if (alertEnable)
1004 {
1005 ALERTREG = ALERTREG | LTC4282_VSENSE_ALARM_HIGH;
1006 }
1007 else
1008 {
1009 ALERTREG = ALERTREG & ~LTC4282_VSENSE_ALARM_HIGH;
1010 }
1011
1012 Serial.print(F("ENABLE VSENSE ALARM LOW ALERT? = "));
1013 alertEnable = read_int();
1014 Serial.println(alertEnable);
1015 if (alertEnable)
1016 {
1017 ALERTREG = ALERTREG | LTC4282_VSENSE_ALARM_LOW;
1018 }
1019 else
1020 {
1021 ALERTREG = ALERTREG & ~LTC4282_VSENSE_ALARM_LOW;
1022 }
1023
1024 Serial.print(F("ENABLE VSOURCE ALARM HIGH ALERT? = "));
1025 alertEnable = read_int();
1026 Serial.println(alertEnable);
1027 if (alertEnable)
1028 {
1029 ALERTREG = ALERTREG | LTC4282_VSOURCE_ALARM_HIGH;
1030 }
1031 else
1032 {
1033 ALERTREG = ALERTREG & ~LTC4282_VSOURCE_ALARM_HIGH;
1034 }
1035
1036 Serial.print(F("ENABLE VSOURCE ALARM LOW ALERT? = "));
1037 alertEnable = read_int();
1038 Serial.println(alertEnable);
1039 if (alertEnable)
1040 {
1041 ALERTREG = ALERTREG | LTC4282_VSOURCE_ALARM_LOW;
1042 }
1043 else
1044 {
1045 ALERTREG = ALERTREG & ~LTC4282_VSOURCE_ALARM_LOW;
1046 }
1047
1048 Serial.print(F("ENABLE VGPIO ALARM HIGH ALERT? = "));
1049 alertEnable = read_int();
1050 Serial.println(alertEnable);
1051 if (alertEnable)
1052 {
1053 ALERTREG = ALERTREG | LTC4282_VGPIO_ALARM_HIGH;
1054 }
1055 else
1056 {
1057 ALERTREG = ALERTREG & ~LTC4282_VGPIO_ALARM_HIGH;
1058 }
1059
1060 Serial.print(F("ENABLE VGPIO ALARM LOW ALERT? = "));
1061 alertEnable = read_int();
1062 Serial.println(alertEnable);
1063 if (alertEnable)
1064 {
1065 ALERTREG = ALERTREG | LTC4282_VGPIO_ALARM_LOW;
1066 }
1067 else
1068 {
1069 ALERTREG = ALERTREG & ~LTC4282_VGPIO_ALARM_LOW;
1070 }
1071
1072 ack |= LTC4282_write(LTC4282_I2C_ADDRESS, LTC4282_ALERT_LSB_REG, ALERTREG);
1073
1074 Serial.println(F("Alert LSB Register Updated\n"));
1075
1076 return ack;
1077 }
1078
1079 //! Settings Menu
1080 int8_t menu_5_settings(uint8_t *CTRLREG_MSB, //!< Local Control MSB Register to Change Through Settings. This is shared across multiple functions such as Continious mode.
1081 uint8_t *CTRLREG_LSB, //!< Local Control LSB Register to Change Through Settings. This is shared across multiple functions such as Continious mode.
1082 uint8_t *ILIM_ADJUST, //!< Local ILIM ADJUST Register to Change Through Settings. This is shared across multiple functions such as Continious mode.
1083 uint8_t *CLK_DECIMATOR //!< Local ILIM ADJUST Register to Change Through Settings. This is shared across multiple functions such as Continious mode.
1084 )
1085 //! @return Returns the state of the acknowledge bit after the I2C write/read. 0 = acknowledge, 1 = no acknowledge.
1086 {
1087
1088 int8_t ack = 0;
1089
1090 uint8_t user_command;
1091
1092 uint16_t alert_code;
1093
1094 do
1095 {
1096 Serial.print(F("****Settings Menu****\n\n"));
1097 Serial.print(F("1 - Set Control MSB Register\n"));
1098 Serial.print(F("2 - Set Control LSB Register\n"));
1099 Serial.print(F("3 - Set ILIM Register\n"));
1100 Serial.print(F("4 - Configure GPIO Pins\n"));
1101 Serial.print(F("5 - Write Register Values to EEPROM\n"));
1102 Serial.print(F("6 - Update Register Values From EEPROM\n"));
1103 Serial.print(F("m-Main Menu\n"));
1104
1105 Serial.print(F("\n\nEnter a Command: "));
1106 user_command = read_int();
1107 if (user_command == 'm')
1108 Serial.println("m");
1109 else
1110 {
1111 Serial.println(user_command);
1112 }
1113
1114 Serial.println();
1115 switch (user_command)
1116 {
1117 case 1: // Control MSB Register Menu. Configure OV/UV/OC Autoretry, FET ON, Mass Write Enable, ON/ENB, ON DELAY and ON FAULT MASK.
1118 ack |= menu_5_set_control_msb_register_menu_1(CTRLREG_MSB);
1119 break;
1120 case 2: // Control LSB Register Menu. Configure Thresholds for POWER GOOD/OV/UV as well as for VIN MODE.
1121 ack |= menu_5_set_control_lsb_register_menu_2(CTRLREG_LSB);
1122 break;
1123 case 3: // ILIM ADJUST Register Menu. Configure Current Limit/Foldback Mode/ADC Voltage Monitoring/16 or 12-bit Mode
1124 ack |= menu_5_set_ilim_adjust_register_menu_3(ILIM_ADJUST);
1125 break;
1126 case 4: // Configure State of GPIO Pins. Set GPIO1 as POWERGOOD/POWERBAD/GPO/GPI, OverFlow Alert, GPIO2 Stress Mode etc.
1127 ack |= menu_5_configure_GPIO_pins_menu_4();
1128 break;
1129 case 5: // Write Values currently present in the Registers of the LTC4282 to the EEPROM
1130 ack |= menu_5_write_register_values_to_EEPROM_menu_5();
1131 break;
1132 case 6: // Restore Values Currently Present in the EEPROM to the Registers of the LTC4282
1133 ack |= menu_5_restore_register_values_from_EEPROM_menu_6();
1134 break;
1135 default:
1136 if (user_command != 'm')
1137 Serial.println(F("Incorrect Option"));
1138 break;
1139 }
1140
1141 }
1142 while (!((user_command == 'm') || (ack)));
1143
1144 return ack;
1145 }
1146
1147 //! Control MSB Register Menu. Configure OV/UV/OC Autoretry, FET ON, Mass Write Enable, ON/ENB, ON DELAY and ON FAULT MASK.
1148 int8_t menu_5_set_control_msb_register_menu_1(uint8_t *CTRLREG_MSB //!< Local Control MSB Register to Change Through Settings. This is shared across multiple functions such as Continious mode.
1149 )
1150 //! @return Returns the state of the acknowledge bit after the I2C write/read. 0 = acknowledge, 1 = no acknowledge.
1151 {
1152
1153 int ack = 0;
1154 Serial.println(F("****SET MSB CONTROL REGISTERS****"));
1155 Serial.println(F("Use Numeric Commands: DISABLE = 0, ENABLE = 1"));
1156 Serial.print(F("ENABLE ON FAULT MASK? = "));
1157 int controlEnable = read_int();
1158 Serial.println(controlEnable);
1159 if (controlEnable)
1160 {
1161 *CTRLREG_MSB = *CTRLREG_MSB | LTC4282_ON_FAULT_MASK;
1162 }
1163 else
1164 {
1165 *CTRLREG_MSB = *CTRLREG_MSB & ~LTC4282_ON_FAULT_MASK;
1166 }
1167
1168
1169 Serial.print(F("ENABLE 50ms ON DELAY? = "));
1170 controlEnable = read_int();
1171 Serial.println(controlEnable);
1172 if (controlEnable)
1173 {
1174 *CTRLREG_MSB = *CTRLREG_MSB | LTC4282_ON_DELAY;
1175 }
1176 else
1177 {
1178 *CTRLREG_MSB = *CTRLREG_MSB & ~LTC4282_ON_DELAY;
1179 }
1180
1181 Serial.print(F("ENABLE ON ACTIVE HIGH? = "));
1182 controlEnable = read_int();
1183 Serial.println(controlEnable);
1184 if (controlEnable)
1185 {
1186 *CTRLREG_MSB = *CTRLREG_MSB | LTC4282_ON_ENB;
1187 }
1188 else
1189 {
1190 *CTRLREG_MSB = *CTRLREG_MSB & ~LTC4282_ON_ENB;
1191 }
1192
1193 Serial.print(F("ENABLE MASS WRITE? = "));
1194 controlEnable = read_int();
1195 Serial.println(controlEnable);
1196 if (controlEnable)
1197 {
1198 *CTRLREG_MSB = *CTRLREG_MSB | LTC4282_MASS_WRITE;
1199 }
1200 else
1201 {
1202 *CTRLREG_MSB = *CTRLREG_MSB & ~LTC4282_MASS_WRITE;
1203 }
1204
1205 Serial.print(F("ENABLE FET TURN ON? = "));
1206 controlEnable = read_int();
1207 Serial.println(controlEnable);
1208 if (controlEnable)
1209 {
1210 *CTRLREG_MSB = *CTRLREG_MSB | LTC4282_FET_ON;
1211 }
1212 else
1213 {
1214 *CTRLREG_MSB = *CTRLREG_MSB & ~LTC4282_FET_ON;
1215 }
1216
1217 Serial.print(F("ENABLE OVERCURRENT AUTORETRY? = "));
1218 controlEnable = read_int();
1219 Serial.println(controlEnable);
1220 if (controlEnable)
1221 {
1222 *CTRLREG_MSB = *CTRLREG_MSB | LTC4282_OC_AUTORETRY;
1223 }
1224 else
1225 {
1226 *CTRLREG_MSB = *CTRLREG_MSB & ~LTC4282_OC_AUTORETRY;
1227 }
1228
1229 Serial.print(F("ENABLE UNDERVOLTAGE AUTORETRY? = "));
1230 controlEnable = read_int();
1231 Serial.println(controlEnable);
1232 if (controlEnable)
1233 {
1234 *CTRLREG_MSB = *CTRLREG_MSB | LTC4282_UV_AUTORETRY;
1235 }
1236 else
1237 {
1238 *CTRLREG_MSB = *CTRLREG_MSB & ~LTC4282_UV_AUTORETRY;
1239 }
1240
1241 Serial.print(F("ENABLE OVERVOLTAGE AUTORETRY? = "));
1242 controlEnable = read_int();
1243 Serial.println(controlEnable);
1244 if (controlEnable)
1245 {
1246 *CTRLREG_MSB = *CTRLREG_MSB | LTC4282_OV_AUTORETRY;
1247 }
1248 else
1249 {
1250 *CTRLREG_MSB = *CTRLREG_MSB & ~LTC4282_OV_AUTORETRY;
1251 }
1252
1253
1254 ack |= LTC4282_write(LTC4282_I2C_ADDRESS, LTC4282_CONTROL_MSB_REG, *CTRLREG_MSB);
1255
1256 Serial.println(F("Control MSB Register Updated\n"));
1257
1258 return ack;
1259
1260 }
1261 // Control LSB Register Menu. Configure Thresholds for POWER GOOD/OV/UV as well as for VIN MODE.
1262 int8_t menu_5_set_control_lsb_register_menu_2(uint8_t *CTRLREG_LSB //!< Local Control LSB Register to Change Through Settings. This is shared across multiple functions such as Continious mode.
1263 )
1264 //! @return Returns the state of the acknowledge bit after the I2C write/read. 0 = acknowledge, 1 = no acknowledge.
1265 {
1266
1267
1268 int ack = 0;
1269 uint8_t user_command;
1270 Serial.println(F("****SET LSB CONTROL REGISTERS****"));
1271 Serial.print(F("SELECT POWER GOOD THRESHOLD:\n"));
1272 Serial.print(F(" 1. EXTERNAL\n"));
1273 Serial.print(F(" 2. 5%\n"));
1274 Serial.print(F(" 3. 10%\n"));
1275 Serial.print(F(" 4. 15%\n"));
1276
1277 user_command = read_int();
1278 Serial.print(F("Selected Value: "));
1279 Serial.print(user_command);
1280 Serial.print(F("\n"));
1281 switch (user_command)
1282 {
1283
1284 case 1:
1285 *CTRLREG_LSB = (*CTRLREG_LSB & ~LTC4282_FB_MODE_MASK) | (LTC4282_FB_MODE_EXTERNAL & LTC4282_FB_MODE_MASK);
1286 break;
1287 case 2:
1288 *CTRLREG_LSB = (*CTRLREG_LSB & ~LTC4282_FB_MODE_MASK) | (LTC4282_FB_MODE_5 & LTC4282_FB_MODE_MASK);
1289 break;
1290 case 3:
1291 *CTRLREG_LSB = (*CTRLREG_LSB & ~LTC4282_FB_MODE_MASK) | (LTC4282_FB_MODE_10 & LTC4282_FB_MODE_MASK);
1292 break;
1293 case 4:
1294 *CTRLREG_LSB = (*CTRLREG_LSB & ~LTC4282_FB_MODE_MASK) | (LTC4282_FB_MODE_15 & LTC4282_FB_MODE_MASK);
1295 break;
1296 default:
1297 Serial.println(F("Invalid entry. Exiting Menu.."));
1298 return 0;
1299 }
1300
1301 Serial.print(F("SELECT UV THRESHOLD:\n"));
1302 Serial.print(F(" 1. EXTERNAL\n"));
1303 Serial.print(F(" 2. 5%\n"));
1304 Serial.print(F(" 3. 10%\n"));
1305 Serial.print(F(" 4. 15%\n"));
1306
1307 user_command = read_int();
1308 Serial.print(F("Selected Value: "));
1309 Serial.print(user_command);
1310 Serial.print(F("\n"));
1311 switch (user_command)
1312 {
1313
1314 case 1:
1315 *CTRLREG_LSB = (*CTRLREG_LSB & ~LTC4282_UV_MODE_MASK) | (LTC4282_UV_MODE_EXTERNAL & LTC4282_UV_MODE_MASK);
1316 break;
1317 case 2:
1318 *CTRLREG_LSB = (*CTRLREG_LSB & ~LTC4282_UV_MODE_MASK) | (LTC4282_UV_MODE_5 & LTC4282_UV_MODE_MASK);
1319 break;
1320 case 3:
1321 *CTRLREG_LSB = (*CTRLREG_LSB & ~LTC4282_UV_MODE_MASK) | (LTC4282_UV_MODE_10 & LTC4282_UV_MODE_MASK);
1322 break;
1323 case 4:
1324 *CTRLREG_LSB = (*CTRLREG_LSB & ~LTC4282_UV_MODE_MASK) | (LTC4282_UV_MODE_15 & LTC4282_UV_MODE_MASK);
1325 break;
1326 default:
1327 Serial.println(F("Invalid entry. Exiting Menu.."));
1328 return 0;
1329 }
1330
1331 Serial.print(F("SELECT OV THRESHOLD:\n"));
1332 Serial.print(F(" 1. EXTERNAL\n"));
1333 Serial.print(F(" 2. 5%\n"));
1334 Serial.print(F(" 3. 10%\n"));
1335 Serial.print(F(" 4. 15%\n"));
1336
1337 user_command = read_int();
1338 Serial.print(F("Selected Value: "));
1339 Serial.print(user_command);
1340 Serial.print(F("\n"));
1341 switch (user_command)
1342 {
1343
1344 case 1:
1345 *CTRLREG_LSB = (*CTRLREG_LSB & ~LTC4282_OV_MODE_MASK) | (LTC4282_OV_MODE_EXTERNAL & LTC4282_OV_MODE_MASK);
1346 break;
1347 case 2:
1348 *CTRLREG_LSB = (*CTRLREG_LSB & ~LTC4282_OV_MODE_MASK) | (LTC4282_OV_MODE_5 & LTC4282_OV_MODE_MASK);
1349 break;
1350 case 3:
1351 *CTRLREG_LSB = (*CTRLREG_LSB & ~LTC4282_OV_MODE_MASK) | (LTC4282_OV_MODE_10 & LTC4282_OV_MODE_MASK);
1352 break;
1353 case 4:
1354 *CTRLREG_LSB = (*CTRLREG_LSB & ~LTC4282_OV_MODE_MASK) | (LTC4282_OV_MODE_15 & LTC4282_OV_MODE_MASK);
1355 break;
1356 default:
1357 Serial.println(F("Invalid entry. Exiting Menu.."));
1358 return 0;
1359 }
1360
1361 Serial.print(F("SELECT VIN MODE:\n"));
1362 Serial.print(F(" 1. 3.3V\n"));
1363 Serial.print(F(" 2. 5V\n"));
1364 Serial.print(F(" 3. 12V\n"));
1365 Serial.print(F(" 4. 24V\n"));
1366
1367 user_command = read_int();
1368 Serial.print(F("Selected Value: "));
1369 Serial.print(user_command);
1370 Serial.print(F("\n"));
1371 switch (user_command)
1372 {
1373
1374 case 1:
1375 *CTRLREG_LSB = (*CTRLREG_LSB & ~LTC4282_VIN_MODE_MASK) | (LTC4282_VIN_MODE_3_V_3 & LTC4282_VIN_MODE_MASK);
1376 break;
1377 case 2:
1378 *CTRLREG_LSB = (*CTRLREG_LSB & ~LTC4282_VIN_MODE_MASK) | (LTC4282_VIN_MODE_5_V & LTC4282_VIN_MODE_MASK);
1379 break;
1380 case 3:
1381 *CTRLREG_LSB = (*CTRLREG_LSB & ~LTC4282_VIN_MODE_MASK) | (LTC4282_VIN_MODE_12_V & LTC4282_VIN_MODE_MASK);
1382 break;
1383 case 4:
1384 *CTRLREG_LSB = (*CTRLREG_LSB & ~LTC4282_VIN_MODE_MASK) | (LTC4282_VIN_MODE_24_V & LTC4282_VIN_MODE_MASK);
1385 break;
1386 default:
1387 Serial.println(F("Invalid entry. Exiting Menu.."));
1388 return 0;
1389 }
1390
1391 ack |= LTC4282_write(LTC4282_I2C_ADDRESS, LTC4282_CONTROL_LSB_REG, *CTRLREG_LSB);
1392
1393 Serial.println(F("Control LSB Register Updated\n"));
1394
1395 return ack;
1396
1397 }
1398 // ILIM ADJUST Register Menu. Configure Current Limit/Foldback Mode/ADC Voltage Monitoring/16 or 12-bit Mode
1399 uint8_t menu_5_set_ilim_adjust_register_menu_3(uint8_t *ILIM_ADJUST //!< Local ILIM ADJUST Register to Change Through Settings. This is shared across multiple functions such as Continious mode.
1400 )
1401 //! @return Returns the state of the acknowledge bit after the I2C write/read. 0 = acknowledge, 1 = no acknowledge.
1402 {
1403
1404 int8_t ack = 0;
1405
1406 uint8_t user_command;
1407 Serial.println(F("****SET ILIM ADJUST REGISTER****"));
1408 Serial.print(F("SELECT CURRENT LIMIT THRESHOLD:\n"));
1409 Serial.print(F(" 1. 34.3mV\n"));
1410 Serial.print(F(" 2. 31.25mV\n"));
1411 Serial.print(F(" 3. 28.12mV\n"));
1412 Serial.print(F(" 4. 25mV\n"));
1413 Serial.print(F(" 5. 21.87mV\n"));
1414 Serial.print(F(" 6. 18.75mV\n"));
1415 Serial.print(F(" 7. 15.62mV\n"));
1416 Serial.print(F(" 8. 12.5mV\n"));
1417 user_command = read_int();
1418 Serial.print(F("Selected Value: "));
1419 Serial.println(user_command);
1420 Serial.print(F("\n"));
1421 switch (user_command)
1422 {
1423
1424 case 1:
1425 *ILIM_ADJUST = (*ILIM_ADJUST & ~LTC4282_ILIM_ADJUST_MASK) | (LTC4282_ILIM_ADJUST_34_V_3 & LTC4282_ILIM_ADJUST_MASK);
1426 break;
1427 case 2:
1428 *ILIM_ADJUST = (*ILIM_ADJUST & ~LTC4282_ILIM_ADJUST_MASK) | (LTC4282_ILIM_ADJUST_31_V_2 & LTC4282_ILIM_ADJUST_MASK);
1429 break;
1430 case 3:
1431 *ILIM_ADJUST = (*ILIM_ADJUST & ~LTC4282_ILIM_ADJUST_MASK) | (LTC4282_ILIM_ADJUST_28_V_1 & LTC4282_ILIM_ADJUST_MASK);
1432 break;
1433 case 4:
1434 *ILIM_ADJUST = (*ILIM_ADJUST & ~LTC4282_ILIM_ADJUST_MASK) | (LTC4282_ILIM_ADJUST_25_V_0 & LTC4282_ILIM_ADJUST_MASK);
1435 break;
1436 case 5:
1437 *ILIM_ADJUST = (*ILIM_ADJUST & ~LTC4282_ILIM_ADJUST_MASK) | (LTC4282_ILIM_ADJUST_21_V_8 & LTC4282_ILIM_ADJUST_MASK);
1438 break;
1439 case 6:
1440 *ILIM_ADJUST = (*ILIM_ADJUST & ~LTC4282_ILIM_ADJUST_MASK) | (LTC4282_ILIM_ADJUST_18_V_7 & LTC4282_ILIM_ADJUST_MASK);
1441 break;
1442 case 7:
1443 *ILIM_ADJUST = (*ILIM_ADJUST & ~LTC4282_ILIM_ADJUST_MASK) | (LTC4282_ILIM_ADJUST_15_V_6 & LTC4282_ILIM_ADJUST_MASK);
1444 break;
1445 case 8:
1446 *ILIM_ADJUST = (*ILIM_ADJUST & ~LTC4282_ILIM_ADJUST_MASK) | (LTC4282_ILIM_ADJUST_12_V_5 & LTC4282_ILIM_ADJUST_MASK);
1447 break;
1448 default:
1449 Serial.println(F("Invalid entry. Exiting Menu.."));
1450 return 0;
1451 }
1452
1453 Serial.print(F("SELECT FOLDBACK MODE:\n"));
1454 Serial.print(F(" 1. 3.3V\n"));
1455 Serial.print(F(" 2. 5V\n"));
1456 Serial.print(F(" 3. 12V\n"));
1457 Serial.print(F(" 4. 24V\n"));
1458 user_command = read_int();
1459 Serial.print(F("Selected Value: "));
1460 Serial.println(user_command);
1461 Serial.print(F("\n"));
1462 switch (user_command)
1463 {
1464
1465 case 1:
1466 *ILIM_ADJUST = (*ILIM_ADJUST & ~LTC4282_FOLDBACK_MASK) | (LTC4282_FOLDBACK_MODE_3_V_3 & LTC4282_FOLDBACK_MASK);
1467 break;
1468 case 2:
1469 *ILIM_ADJUST = (*ILIM_ADJUST & ~LTC4282_FOLDBACK_MASK) | (LTC4282_FOLDBACK_MODE_5_V_0 & LTC4282_FOLDBACK_MASK);
1470 break;
1471 case 3:
1472 *ILIM_ADJUST = (*ILIM_ADJUST & ~LTC4282_FOLDBACK_MASK) | (LTC4282_FOLDBACK_MODE_12_V_0 & LTC4282_FOLDBACK_MASK);
1473 break;
1474 case 4:
1475 *ILIM_ADJUST = (*ILIM_ADJUST & ~LTC4282_FOLDBACK_MASK) | (LTC4282_FOLDBACK_MODE_24_V_0 & LTC4282_FOLDBACK_MASK);
1476 break;
1477 default:
1478 Serial.println(F("Invalid entry. Exiting Menu.."));
1479 return 0;
1480 }
1481
1482 Serial.print(F("SELECT ADC VOLTAGE MONITOR MODE:\n"));
1483 Serial.print(F(" 1. SOURCE\n"));
1484 Serial.print(F(" 2. VDD\n"));
1485 user_command = read_int();
1486 Serial.print(F("Selected Value: "));
1487 Serial.println(user_command);
1488 Serial.print(F("\n"));
1489 switch (user_command)
1490 {
1491 case 1:
1492 *ILIM_ADJUST = *ILIM_ADJUST | LTC4282_ADC_VSOURCE;
1493 break;
1494 case 2:
1495 *ILIM_ADJUST = *ILIM_ADJUST & ~LTC4282_ADC_VSOURCE;
1496 break;
1497 default:
1498 Serial.println(F("Invalid entry. Exiting Menu.."));
1499 return 0;
1500 }
1501
1502 Serial.print(F("SELECT GPIO MONITOR MODE:\n"));
1503 Serial.print(F(" 1. GPIO2\n"));
1504 Serial.print(F(" 2. GPIO3\n"));
1505 user_command = read_int();
1506 Serial.print(F("Selected Value: "));
1507 Serial.println(user_command);
1508 Serial.print(F("\n"));
1509 switch (user_command)
1510 {
1511 case 1:
1512 *ILIM_ADJUST = *ILIM_ADJUST | LTC4282_ADC_GPIO2_MODE;
1513 break;
1514 case 2:
1515 *ILIM_ADJUST = *ILIM_ADJUST & ~LTC4282_ADC_GPIO2_MODE;
1516 break;
1517 default:
1518 Serial.println(F("Invalid entry. Exiting Menu.."));
1519 return 0;
1520 }
1521
1522
1523 Serial.print(F("SELECT ADC RESOLUTION:\n"));
1524 Serial.print(F(" 1. 16-bit\n"));
1525 Serial.print(F(" 2. 12-bit\n"));
1526 user_command = read_int();
1527 Serial.print(F("Selected Value: "));
1528 Serial.println(user_command);
1529 Serial.print(F("\n"));
1530 switch (user_command)
1531 {
1532 case 1:
1533 *ILIM_ADJUST = *ILIM_ADJUST | LTC4282_ADC_16_BIT;
1534 break;
1535 case 2:
1536 *ILIM_ADJUST = *ILIM_ADJUST & ~LTC4282_ADC_16_BIT;
1537 break;
1538 default:
1539 Serial.println(F("Invalid entry. Exiting Menu.."));
1540 return 0;
1541 }
1542
1543 ack |= LTC4282_write(LTC4282_I2C_ADDRESS, LTC4282_ILIM_ADJUST_REG, *ILIM_ADJUST);
1544
1545 Serial.println(F("Control LSB Register Updated\n"));
1546 return ack;
1547 }
1548
1549 // Configure State of GPIO Pins. Set GPIO1 as POWERGOOD/POWERBAD/GPO/GPI, OverFlow Alert, GPIO2 Stress Mode etc.
1550 uint8_t menu_5_configure_GPIO_pins_menu_4()
1551 //! @return Returns the state of the acknowledge bit after the I2C write/read. 0 = acknowledge, 1 = no acknowledge.
1552 {
1553
1554 uint8_t ack = 0;
1555
1556 uint8_t gpio_config_code;
1557
1558 ack |= LTC4282_read(LTC4282_I2C_ADDRESS, LTC4282_GPIO_CONFIG_REG, &gpio_config_code);
1559
1560 uint8_t user_command;
1561 Serial.println(F("****SET GPIO_CONFIG REGISTER****"));
1562 Serial.print(F("Set GPIO3 Pulldown: \n"));
1563 Serial.print(F(" 1. Enable\n"));
1564 Serial.print(F(" 2. Disable\n"));
1565 user_command = read_int();
1566 Serial.print(F("Selected Value: "));
1567 Serial.println(user_command);
1568 Serial.print(F("\n"));
1569 switch (user_command)
1570 {
1571 case 1:
1572 gpio_config_code |= LTC4282_GPIO3_PD;
1573 break;
1574 case 2:
1575 gpio_config_code = gpio_config_code &~LTC4282_GPIO3_PD;
1576 break;
1577 default:
1578 Serial.print(F("Invalid Entry. No Changes Made\n"));
1579 }
1580
1581 Serial.print(F("Set GPIO2 Pulldown: \n"));
1582 Serial.print(F(" 1. Enable\n"));
1583 Serial.print(F(" 2. Disable\n"));
1584 user_command = read_int();
1585 Serial.print(F("Selected Value: "));
1586 Serial.println(user_command);
1587 Serial.print(F("\n"));
1588 switch (user_command)
1589 {
1590 case 1:
1591 gpio_config_code |= LTC4282_GPIO2_PD;
1592 break;
1593 case 2:
1594 gpio_config_code = gpio_config_code &~LTC4282_GPIO2_PD;
1595 break;
1596 default:
1597 Serial.print(F("Invalid Entry. No Changes Made\n"));
1598 }
1599
1600 Serial.print(F("Configure GPIO1: \n"));
1601 Serial.print(F(" 1. Power Good\n"));
1602 Serial.print(F(" 2. Power Bad\n"));
1603 Serial.print(F(" 3. General Purpose Output\n"));
1604 Serial.print(F(" 4. General Purpose Input\n"));
1605 user_command = read_int();
1606 Serial.print(F("Selected Value: "));
1607 Serial.println(user_command);
1608 Serial.print(F("\n"));
1609 switch (user_command)
1610 {
1611 case 1:
1612 gpio_config_code = (gpio_config_code & ~LTC4282_GPIO1_CONFIG_MASK) | ( LTC4282_GPIO1_CONFIG_POWER_GOOD & LTC4282_GPIO1_CONFIG_MASK);
1613 break;
1614 case 2:
1615 gpio_config_code = (gpio_config_code & ~LTC4282_GPIO1_CONFIG_MASK) | ( LTC4282_GPIO1_CONFIG_POWER_BAD & LTC4282_GPIO1_CONFIG_MASK);
1616 break;
1617 case 3:
1618 {
1619 gpio_config_code = (gpio_config_code & ~LTC4282_GPIO1_CONFIG_MASK) | ( LTC4282_GPIO1_CONFIG_OUTPUT & LTC4282_GPIO1_CONFIG_MASK);
1620 Serial.print(F("GPIO1 Configured as output..\n"));
1621 Serial.print(F("Set Pull Down: \n"));
1622 Serial.print(F(" 1. Enable\n"));
1623 Serial.print(F(" 2. Disable\n"));
1624 user_command = read_int();
1625 Serial.print(F("Selected Value: "));
1626 Serial.println(user_command);
1627 Serial.print(F("\n"));
1628 switch (user_command)
1629 {
1630 case 1:
1631 gpio_config_code = gpio_config_code & ~LTC4282_GPIO1_OUTPUT;
1632 break;
1633 case 2:
1634 gpio_config_code |= LTC4282_GPIO1_OUTPUT;
1635 break;
1636 default:
1637 Serial.print(F("Invalid Entry. No Changes Made\n"));
1638 }
1639 }
1640 break;
1641 case 4:
1642 gpio_config_code = (gpio_config_code & ~LTC4282_GPIO1_CONFIG_MASK) | ( LTC4282_GPIO1_CONFIG_INPUT & LTC4282_GPIO1_CONFIG_MASK);
1643 break;
1644 default:
1645 Serial.print(F("Invalid Entry. No Changes Made\n"));
1646 }
1647
1648 Serial.print(F("ADC Conversion Alerts: \n"));
1649 Serial.print(F(" 1. Enable\n"));
1650 Serial.print(F(" 2. Disable\n"));
1651 user_command = read_int();
1652 Serial.print(F("Selected Value: "));
1653 Serial.println(user_command);
1654 Serial.print(F("\n"));
1655 switch (user_command)
1656 {
1657 case 1:
1658 gpio_config_code |= LTC4282_ADC_CONV_ALERT;
1659 break;
1660 case 2:
1661 gpio_config_code = gpio_config_code &~LTC4282_ADC_CONV_ALERT;
1662 break;
1663 default:
1664 Serial.print(F("Invalid Entry. No Changes Made\n"));
1665 }
1666
1667 Serial.print(F("GPIO2 Pull Low When MOSFET Under Stress: \n"));
1668 Serial.print(F(" 1. Enable\n"));
1669 Serial.print(F(" 2. Disable\n"));
1670 user_command = read_int();
1671 Serial.print(F("Selected Value: "));
1672 Serial.println(user_command);
1673 Serial.print(F("\n"));
1674 switch (user_command)
1675 {
1676 case 1:
1677 gpio_config_code |= LTC4282_STRESS_TO_GPIO2;
1678 break;
1679 case 2:
1680 gpio_config_code = gpio_config_code &~LTC4282_STRESS_TO_GPIO2;
1681 break;
1682 default:
1683 Serial.print(F("Invalid Entry. No Changes Made\n"));
1684 }
1685
1686 Serial.print(F("Set Energy And Timer Overflow Alert: \n"));
1687 Serial.print(F(" 1. Enable\n"));
1688 Serial.print(F(" 2. Disable\n"));
1689 user_command = read_int();
1690 Serial.print(F("Selected Value: "));
1691 Serial.println(user_command);
1692 Serial.print(F("\n"));
1693 switch (user_command)
1694 {
1695 case 1:
1696 gpio_config_code |= LTC4282_METER_OF_ALERT;
1697 break;
1698 case 2:
1699 gpio_config_code = gpio_config_code &~LTC4282_METER_OF_ALERT;
1700 break;
1701 default:
1702 Serial.print(F("Invalid Entry. No Changes Made\n"));
1703 }
1704
1705 ack |= LTC4282_write(LTC4282_I2C_ADDRESS, LTC4282_GPIO_CONFIG_REG, gpio_config_code);
1706 Serial.print(F("\n"));
1707 return ack;
1708 }
1709
1710 // Write Values currently present in the Registers of the LTC4282 to the EEPROM
1711 uint8_t menu_5_write_register_values_to_EEPROM_menu_5()
1712 //! @return Returns the state of the acknowledge bit after the I2C write/read. 0 = acknowledge, 1 = no acknowledge.
1713 {
1714
1715 uint8_t ack =0;
1716
1717 uint8_t CTRLREG_MSB;
1718 uint8_t CTRLREG_LSB;
1719 uint8_t ALRTREG_MSB;
1720 uint8_t ALRTREG_LSB;
1721 uint8_t FAULT_REG;
1722 uint8_t ADC_ALERT_REG;
1723 uint8_t FET_BAD_TIME;
1724 uint8_t GPIO_CONFIG;
1725 uint8_t VGPIO_ALARM_MIN;
1726 uint8_t VGPIO_ALARM_MAX;
1727 uint8_t VSOURCE_ALARM_MIN;
1728 uint8_t VSOURCE_ALARM_MAX;
1729 uint8_t VSENSE_ALARM_MIN;
1730 uint8_t VSENSE_ALARM_MAX;
1731 uint8_t POWER_ALARM_MIN;
1732 uint8_t POWER_ALARM_MAX;
1733 uint8_t CLK_DECIMATOR;
1734 uint8_t ILIM_ADJUST;
1735
1736 ack |= LTC4282_read(LTC4282_I2C_ADDRESS, LTC4282_CONTROL_MSB_REG, &CTRLREG_MSB);
1737 ack |= LTC4282_read(LTC4282_I2C_ADDRESS, LTC4282_CONTROL_LSB_REG, &CTRLREG_LSB);
1738 ack |= LTC4282_read(LTC4282_I2C_ADDRESS, LTC4282_ALERT_MSB_REG, &ALRTREG_MSB);
1739 ack |= LTC4282_read(LTC4282_I2C_ADDRESS, LTC4282_ALERT_LSB_REG, &ALRTREG_LSB);
1740 ack |= LTC4282_read(LTC4282_I2C_ADDRESS, LTC4282_FAULT_LOG_REG, &FAULT_REG);
1741 ack |= LTC4282_read(LTC4282_I2C_ADDRESS, LTC4282_ADC_ALERT_LOG_REG, &ADC_ALERT_REG);
1742 ack |= LTC4282_read(LTC4282_I2C_ADDRESS, LTC4282_FET_BAD_FAULT_TIME_REG, &FET_BAD_TIME);
1743 ack |= LTC4282_read(LTC4282_I2C_ADDRESS, LTC4282_GPIO_CONFIG_REG, &GPIO_CONFIG);
1744 ack |= LTC4282_read(LTC4282_I2C_ADDRESS, LTC4282_VGPIO_ALARM_MIN_REG, &VGPIO_ALARM_MIN);
1745 ack |= LTC4282_read(LTC4282_I2C_ADDRESS, LTC4282_VGPIO_ALARM_MAX_REG, &VGPIO_ALARM_MAX);
1746 ack |= LTC4282_read(LTC4282_I2C_ADDRESS, LTC4282_VSOURCE_ALARM_MIN_REG, &VSOURCE_ALARM_MIN);
1747 ack |= LTC4282_read(LTC4282_I2C_ADDRESS, LTC4282_VSOURCE_ALARM_MAX_REG, &VSOURCE_ALARM_MAX);
1748 ack |= LTC4282_read(LTC4282_I2C_ADDRESS, LTC4282_VSENSE_ALARM_MIN_REG, &VSENSE_ALARM_MIN);
1749 ack |= LTC4282_read(LTC4282_I2C_ADDRESS, LTC4282_VSENSE_ALARM_MAX_REG, &VSENSE_ALARM_MAX);
1750 ack |= LTC4282_read(LTC4282_I2C_ADDRESS, LTC4282_POWER_ALARM_MIN_REG, &POWER_ALARM_MIN);
1751 ack |= LTC4282_read(LTC4282_I2C_ADDRESS, LTC4282_POWER_ALARM_MAX_REG, &POWER_ALARM_MAX);
1752 ack |= LTC4282_read(LTC4282_I2C_ADDRESS, LTC4282_CLK_DEC_REG, &CLK_DECIMATOR);
1753 ack |= LTC4282_read(LTC4282_I2C_ADDRESS, LTC4282_ILIM_ADJUST_REG, &ILIM_ADJUST);
1754
1755
1756 uint8_t user_command;
1757 Serial.println(F("****CURRENT REGISTER VALUES TO BE COPIED TO EEPROM****"));
1758 Serial.print(F("CONTROL MSB: "));
1759 Serial.println(CTRLREG_MSB);
1760 Serial.print(F("CONTROL LSB: "));
1761 Serial.println((CTRLREG_LSB));
1762 Serial.print(F("ALERT MSB: "));
1763 Serial.println((ALRTREG_MSB));
1764 Serial.print(F("ALERT LSB: "));
1765 Serial.println((ALRTREG_LSB));
1766 Serial.print(F("FAULT LOG: "));
1767 Serial.println((FAULT_REG));
1768 Serial.print(F("ADC ALERT: "));
1769 Serial.println((ADC_ALERT_REG));
1770 Serial.print(F("FET BAD TIME: "));
1771 Serial.println((FET_BAD_TIME));
1772 Serial.print(F("GPIO CONFIG: "));
1773 Serial.println((GPIO_CONFIG));
1774 Serial.print(F("VGPIO ALARM MIN: "));
1775 Serial.println((VGPIO_ALARM_MIN));
1776 Serial.print(F("VGPIO ALARM MAX: "));
1777 Serial.println((VGPIO_ALARM_MAX));
1778 Serial.print(F("VSOURCE ALARM MIN: "));
1779 Serial.println((VSOURCE_ALARM_MIN));
1780 Serial.print(F("VSOURCE ALARM MAX: "));
1781 Serial.println((VSOURCE_ALARM_MAX));
1782 Serial.print(F("VSENSE ALARM MIN: "));
1783 Serial.println((VSENSE_ALARM_MIN));
1784 Serial.print(F("VSENSE ALARM MAX: "));
1785 Serial.println((VSENSE_ALARM_MAX));
1786 Serial.print(F("POWER ALARM MIN: "));
1787 Serial.println((POWER_ALARM_MIN));
1788 Serial.print(F("POWER ALARM MAX: "));
1789 Serial.println((POWER_ALARM_MAX));
1790 Serial.print(F("CLOCK DECIMATOR: "));
1791 Serial.println((CLK_DECIMATOR));
1792 Serial.print(F("ILIM ADJUST: "));
1793 Serial.println((ILIM_ADJUST));
1794 Serial.print(F("Do You Want to Enter These Values To EEPROM?\n"));
1795 Serial.print(F(" 1. Yes\n"));
1796 Serial.print(F(" 2. No\n"));
1797 user_command = read_int();
1798 Serial.print(F("Selected Value: "));
1799 Serial.println(user_command);
1800 Serial.print(F("\n"));
1801
1802 switch (user_command)
1803 {
1804
1805 case 1:
1806 ack |= LTC4282_write(LTC4282_I2C_ADDRESS, LTC4282_EE_CONTROL_MSB_REG, CTRLREG_MSB);
1807 delay(50);
1808 ack |= LTC4282_write(LTC4282_I2C_ADDRESS, LTC4282_EE_CONTROL_LSB_REG, CTRLREG_LSB);
1809 delay(50);
1810 ack |= LTC4282_write(LTC4282_I2C_ADDRESS, LTC4282_EE_ALERT_MSB_REG, ALRTREG_MSB);
1811 delay(50);
1812 ack |= LTC4282_write(LTC4282_I2C_ADDRESS, LTC4282_EE_ALERT_LSB_REG, ALRTREG_LSB);
1813 delay(50);
1814 ack |= LTC4282_write(LTC4282_I2C_ADDRESS, LTC4282_EE_FAULT_REG, FAULT_REG);
1815 delay(50);
1816 ack |= LTC4282_write(LTC4282_I2C_ADDRESS, LTC4282_EE_ADC_ALERT_LOG_REG, ADC_ALERT_REG);
1817 delay(50);
1818 ack |= LTC4282_write(LTC4282_I2C_ADDRESS, LTC4282_EE_FET_BAD_FAULT_TIME_REG, FET_BAD_TIME);
1819 delay(50);
1820 ack |= LTC4282_write(LTC4282_I2C_ADDRESS, LTC4282_EE_GPIO_CONFIG_REG, GPIO_CONFIG);
1821 delay(50);
1822 ack |= LTC4282_write(LTC4282_I2C_ADDRESS, LTC4282_EE_VGPIO_ALARM_MIN_REG, VGPIO_ALARM_MIN);
1823 delay(50);
1824 ack |= LTC4282_write(LTC4282_I2C_ADDRESS, LTC4282_EE_VGPIO_ALARM_MAX_REG, VGPIO_ALARM_MAX);
1825 delay(50);
1826 ack |= LTC4282_write(LTC4282_I2C_ADDRESS, LTC4282_EE_VSOURCE_ALARM_MIN_REG, VSOURCE_ALARM_MIN);
1827 delay(50);
1828 ack |= LTC4282_write(LTC4282_I2C_ADDRESS, LTC4282_EE_VSOURCE_ALARM_MAX_REG, VSOURCE_ALARM_MAX);
1829 delay(50);
1830 ack |= LTC4282_write(LTC4282_I2C_ADDRESS, LTC4282_EE_VSENSE_ALARM_MIN_REG, VSENSE_ALARM_MIN);
1831 delay(50);
1832 ack |= LTC4282_write(LTC4282_I2C_ADDRESS, LTC4282_EE_VSENSE_ALARM_MAX_REG, VSENSE_ALARM_MAX);
1833 delay(50);
1834 ack |= LTC4282_write(LTC4282_I2C_ADDRESS, LTC4282_EE_POWER_ALARM_MIN_REG, POWER_ALARM_MIN);
1835 delay(50);
1836 ack |= LTC4282_write(LTC4282_I2C_ADDRESS, LTC4282_EE_POWER_ALARM_MAX_REG, POWER_ALARM_MAX);
1837 delay(50);
1838 ack |= LTC4282_write(LTC4282_I2C_ADDRESS, LTC4282_EE_CLK_DEC_REG, CLK_DECIMATOR);
1839 delay(50);
1840 ack |= LTC4282_write(LTC4282_I2C_ADDRESS, LTC4282_EE_ILIM_ADJUST_REG, ILIM_ADJUST);
1841
1842 Serial.println(F("Values Written to EEPROM\n"));
1843 break;
1844 case 2:
1845 Serial.print(F("Nothing Written To EEPROM\n"));
1846 break;
1847 default:
1848 Serial.print(F("Invalid Entry. No Changes Made\n"));
1849 }
1850 Serial.print(F("\n"));
1851 return ack;
1852 }
1853
1854 // Restore Values Currently Present in the EEPROM to the Registers of the LTC4282
1855 uint8_t menu_5_restore_register_values_from_EEPROM_menu_6()
1856 //! @return Returns the state of the acknowledge bit after the I2C write/read. 0 = acknowledge, 1 = no acknowledge.
1857 {
1858
1859 uint8_t ack =0;
1860
1861 uint8_t CTRLREG_MSB;
1862 uint8_t CTRLREG_LSB;
1863 uint8_t ALRTREG_MSB;
1864 uint8_t ALRTREG_LSB;
1865 uint8_t FAULT_REG;
1866 uint8_t ADC_ALERT_REG;
1867 uint8_t FET_BAD_TIME;
1868 uint8_t GPIO_CONFIG;
1869 uint8_t VGPIO_ALARM_MIN;
1870 uint8_t VGPIO_ALARM_MAX;
1871 uint8_t VSOURCE_ALARM_MIN;
1872 uint8_t VSOURCE_ALARM_MAX;
1873 uint8_t VSENSE_ALARM_MIN;
1874 uint8_t VSENSE_ALARM_MAX;
1875 uint8_t POWER_ALARM_MIN;
1876 uint8_t POWER_ALARM_MAX;
1877 uint8_t CLK_DECIMATOR;
1878 uint8_t ILIM_ADJUST;
1879
1880 ack |= LTC4282_read(LTC4282_I2C_ADDRESS, LTC4282_EE_CONTROL_MSB_REG, &CTRLREG_MSB);
1881 ack |= LTC4282_read(LTC4282_I2C_ADDRESS, LTC4282_EE_CONTROL_LSB_REG, &CTRLREG_LSB);
1882 ack |= LTC4282_read(LTC4282_I2C_ADDRESS, LTC4282_EE_ALERT_MSB_REG, &ALRTREG_MSB);
1883 ack |= LTC4282_read(LTC4282_I2C_ADDRESS, LTC4282_EE_ALERT_LSB_REG, &ALRTREG_LSB);
1884 ack |= LTC4282_read(LTC4282_I2C_ADDRESS, LTC4282_EE_FAULT_REG, &FAULT_REG);
1885 ack |= LTC4282_read(LTC4282_I2C_ADDRESS, LTC4282_EE_ADC_ALERT_LOG_REG, &ADC_ALERT_REG);
1886 ack |= LTC4282_read(LTC4282_I2C_ADDRESS, LTC4282_EE_FET_BAD_FAULT_TIME_REG, &FET_BAD_TIME);
1887 ack |= LTC4282_read(LTC4282_I2C_ADDRESS, LTC4282_EE_GPIO_CONFIG_REG, &GPIO_CONFIG);
1888 ack |= LTC4282_read(LTC4282_I2C_ADDRESS, LTC4282_EE_VGPIO_ALARM_MIN_REG, &VGPIO_ALARM_MIN);
1889 ack |= LTC4282_read(LTC4282_I2C_ADDRESS, LTC4282_EE_VGPIO_ALARM_MAX_REG, &VGPIO_ALARM_MAX);
1890 ack |= LTC4282_read(LTC4282_I2C_ADDRESS, LTC4282_EE_VSOURCE_ALARM_MIN_REG, &VSOURCE_ALARM_MIN);
1891 ack |= LTC4282_read(LTC4282_I2C_ADDRESS, LTC4282_EE_VSOURCE_ALARM_MAX_REG, &VSOURCE_ALARM_MAX);
1892 ack |= LTC4282_read(LTC4282_I2C_ADDRESS, LTC4282_EE_VSENSE_ALARM_MIN_REG, &VSENSE_ALARM_MIN);
1893 ack |= LTC4282_read(LTC4282_I2C_ADDRESS, LTC4282_EE_VSENSE_ALARM_MAX_REG, &VSENSE_ALARM_MAX);
1894 ack |= LTC4282_read(LTC4282_I2C_ADDRESS, LTC4282_EE_POWER_ALARM_MIN_REG, &POWER_ALARM_MIN);
1895 ack |= LTC4282_read(LTC4282_I2C_ADDRESS, LTC4282_EE_POWER_ALARM_MAX_REG, &POWER_ALARM_MAX);
1896 ack |= LTC4282_read(LTC4282_I2C_ADDRESS, LTC4282_EE_CLK_DEC_REG, &CLK_DECIMATOR);
1897 ack |= LTC4282_read(LTC4282_I2C_ADDRESS, LTC4282_EE_ILIM_ADJUST_REG, &ILIM_ADJUST);
1898
1899
1900 uint8_t user_command;
1901 Serial.println(F("****RESTORE FOLLOWING VALUES FROM EEPROM****"));
1902 Serial.print(F("CONTROL MSB: "));
1903 Serial.println(CTRLREG_MSB);
1904 Serial.print(F("CONTROL LSB: "));
1905 Serial.println((CTRLREG_LSB));
1906 Serial.print(F("ALERT MSB: "));
1907 Serial.println((ALRTREG_MSB));
1908 Serial.print(F("ALERT LSB: "));
1909 Serial.println((ALRTREG_LSB));
1910 Serial.print(F("FAULT LOG: "));
1911 Serial.println((FAULT_REG));
1912 Serial.print(F("ADC ALERT: "));
1913 Serial.println((ADC_ALERT_REG));
1914 Serial.print(F("FET BAD TIME: "));
1915 Serial.println((FET_BAD_TIME));
1916 Serial.print(F("GPIO CONFIG: "));
1917 Serial.println((GPIO_CONFIG));
1918 Serial.print(F("VGPIO ALARM MIN: "));
1919 Serial.println((VGPIO_ALARM_MIN));
1920 Serial.print(F("VGPIO ALARM MAX: "));
1921 Serial.println((VGPIO_ALARM_MAX));
1922 Serial.print(F("VSOURCE ALARM MIN: "));
1923 Serial.println((VSOURCE_ALARM_MIN));
1924 Serial.print(F("VSOURCE ALARM MAX: "));
1925 Serial.println((VSOURCE_ALARM_MAX));
1926 Serial.print(F("VSENSE ALARM MIN: "));
1927 Serial.println((VSENSE_ALARM_MIN));
1928 Serial.print(F("VSENSE ALARM MAX: "));
1929 Serial.println((VSENSE_ALARM_MAX));
1930 Serial.print(F("POWER ALARM MIN: "));
1931 Serial.println((POWER_ALARM_MIN));
1932 Serial.print(F("POWER ALARM MAX: "));
1933 Serial.println((POWER_ALARM_MAX));
1934 Serial.print(F("CLOCK DECIMATOR: "));
1935 Serial.println((CLK_DECIMATOR));
1936 Serial.print(F("ILIM ADJUST: "));
1937 Serial.println((ILIM_ADJUST));
1938 Serial.print(F("Do You Want to Restore these Values from EEPROM?\n"));
1939 Serial.print(F(" 1. Yes\n"));
1940 Serial.print(F(" 2. No\n"));
1941 user_command = read_int();
1942 Serial.print(F("Selected Value: "));
1943 Serial.println(user_command);
1944 Serial.print(F("\n"));
1945
1946 switch (user_command)
1947 {
1948
1949 case 1:
1950 ack |= LTC4282_write(LTC4282_I2C_ADDRESS, LTC4282_CONTROL_MSB_REG, CTRLREG_MSB);
1951 ack |= LTC4282_write(LTC4282_I2C_ADDRESS, LTC4282_CONTROL_LSB_REG, CTRLREG_LSB);
1952 ack |= LTC4282_write(LTC4282_I2C_ADDRESS, LTC4282_ALERT_MSB_REG, ALRTREG_MSB);
1953 ack |= LTC4282_write(LTC4282_I2C_ADDRESS, LTC4282_ALERT_LSB_REG, ALRTREG_LSB);
1954 ack |= LTC4282_write(LTC4282_I2C_ADDRESS, LTC4282_FAULT_LOG_REG, FAULT_REG);
1955 ack |= LTC4282_write(LTC4282_I2C_ADDRESS, LTC4282_ADC_ALERT_LOG_REG, ADC_ALERT_REG);
1956 ack |= LTC4282_write(LTC4282_I2C_ADDRESS, LTC4282_FET_BAD_FAULT_TIME_REG, FET_BAD_TIME);
1957 ack |= LTC4282_write(LTC4282_I2C_ADDRESS, LTC4282_GPIO_CONFIG_REG, GPIO_CONFIG);
1958 ack |= LTC4282_write(LTC4282_I2C_ADDRESS, LTC4282_VGPIO_ALARM_MIN_REG, VGPIO_ALARM_MIN);
1959 ack |= LTC4282_write(LTC4282_I2C_ADDRESS, LTC4282_VGPIO_ALARM_MAX_REG, VGPIO_ALARM_MAX);
1960 ack |= LTC4282_write(LTC4282_I2C_ADDRESS, LTC4282_VSOURCE_ALARM_MIN_REG, VSOURCE_ALARM_MIN);
1961 ack |= LTC4282_write(LTC4282_I2C_ADDRESS, LTC4282_VSOURCE_ALARM_MAX_REG, VSOURCE_ALARM_MAX);
1962 ack |= LTC4282_write(LTC4282_I2C_ADDRESS, LTC4282_VSENSE_ALARM_MIN_REG, VSENSE_ALARM_MIN);
1963 ack |= LTC4282_write(LTC4282_I2C_ADDRESS, LTC4282_VSENSE_ALARM_MAX_REG, VSENSE_ALARM_MAX);
1964 ack |= LTC4282_write(LTC4282_I2C_ADDRESS, LTC4282_POWER_ALARM_MIN_REG, POWER_ALARM_MIN);
1965 ack |= LTC4282_write(LTC4282_I2C_ADDRESS, LTC4282_POWER_ALARM_MAX_REG, POWER_ALARM_MAX);
1966 ack |= LTC4282_write(LTC4282_I2C_ADDRESS, LTC4282_CLK_DEC_REG, CLK_DECIMATOR);
1967 ack |= LTC4282_write(LTC4282_I2C_ADDRESS, LTC4282_ILIM_ADJUST_REG, ILIM_ADJUST);
1968
1969 Serial.println(F("Values Restored From EEPROM\n"));
1970 break;
1971 case 2:
1972 Serial.print(F("Nothing Restored.\n"));
1973 break;
1974 default:
1975 Serial.print(F("Invalid Entry. No Changes Made\n"));
1976 }
1977
1978 Serial.print(F("\n"));
1979
1980 return ack;
1981
1982 }
1983
LTC4282_code_to_avg_power
float LTC4282_code_to_avg_power(uint64_t code, float energy, float tConv)
Convert ADC code to average power.
Definition: LTC4282.cpp:216
LTC4282_ALERT_MSB_REG
#define LTC4282_ALERT_MSB_REG
Definition: LTC4282.h:266
menu_5_settings
static int8_t menu_5_settings(uint8_t *CTRLREG_MSB, uint8_t *CTRLREG_LSB, uint8_t *ILIM_ADJUST, uint8_t *CLK_DECIMATOR)
Set Alert LSB Register.
Definition: DC2024A.ino:1080
LTC4282_MASS_WRITE
#define LTC4282_MASS_WRITE
Definition: LTC4282.h:471
LTC4282_code_to_voltage
float LTC4282_code_to_voltage(uint16_t code, float fullscaleVoltage)
Convert ADC code to voltage.
Definition: LTC4282.cpp:177
LTC4282_VSOURCE_ALARM_MIN_REG
#define LTC4282_VSOURCE_ALARM_MIN_REG
Definition: LTC4282.h:272
LTC4282_VSOURCE_ALARM_LOW
#define LTC4282_VSOURCE_ALARM_LOW
Definition: LTC4282.h:505
LTC4282_UV_ALERT
#define LTC4282_UV_ALERT
Definition: LTC4282.h:498
menu_5_write_register_values_to_EEPROM_menu_5
static uint8_t menu_5_write_register_values_to_EEPROM_menu_5()
Configure State of GPIO Pins. Set GPIO1 as POWERGOOD/POWERBAD/GPO/GPI, OverFlow Alert, GPIO2 Stress Mode etc.
Definition: DC2024A.ino:1711
LTC4282_VGPIO_to_code_alarm
uint8_t LTC4282_VGPIO_to_code_alarm(float vgpio)
Convert GPIO voltage to alarm code.
Definition: LTC4282.cpp:264
LTC4282_UV_MODE_MASK
#define LTC4282_UV_MODE_MASK
Definition: LTC4282.h:555
LTC4282_code_to_coulombs
float LTC4282_code_to_coulombs(uint64_t code, float resistor, float tConv)
Convert ADC code to coulombs.
Definition: LTC4282.cpp:208
CONTINUOUS_MODE_DISPLAY_DELAY
#define CONTINUOUS_MODE_DISPLAY_DELAY
Restore Values Currently Present in the EEPROM to the Registers of the LTC4282.
Definition: DC2024A.ino:109
LTC4282_ILIM_ADJUST_12_V_5
#define LTC4282_ILIM_ADJUST_12_V_5
Definition: LTC4282.h:521
LTC4282_FB_MODE_10
#define LTC4282_FB_MODE_10
Definition: LTC4282.h:478
LTC4282_ILIM_ADJUST_34_V_3
#define LTC4282_ILIM_ADJUST_34_V_3
Definition: LTC4282.h:528
user_command
unsigned char user_command
Definition: Serial_EEPROM_Test.ino:75
LTC4282_PB_ALERT
#define LTC4282_PB_ALERT
Definition: LTC4282.h:496
LTC4282_METER_OF_ALERT
#define LTC4282_METER_OF_ALERT
Definition: LTC4282.h:517
LTC4282_VSOURCE_MSB_REG
#define LTC4282_VSOURCE_MSB_REG
Definition: LTC4282.h:320
LTC4282_FAULT_LOG_REG
#define LTC4282_FAULT_LOG_REG
Definition: LTC4282.h:268
LTC4282_VSOURCE_ALARM_MAX_REG
#define LTC4282_VSOURCE_ALARM_MAX_REG
Definition: LTC4282.h:273
LTC4282_FOLDBACK_MODE_24_V_0
#define LTC4282_FOLDBACK_MODE_24_V_0
Definition: LTC4282.h:532
CLK_DIVIDER
const int CLK_DIVIDER
CLK Frequency.
Definition: DC2024A.ino:112
LTC4282_FET_ON
#define LTC4282_FET_ON
Definition: LTC4282.h:472
LTC4282_EE_ALERT_MSB_REG
#define LTC4282_EE_ALERT_MSB_REG
Definition: LTC4282.h:298
LTC4282_read_32_bits
int8_t LTC4282_read_32_bits(uint8_t i2c_address, uint8_t adc_command, uint32_t *adc_code)
Read a 32-bit code from the LTC4282.
Definition: LTC4282.cpp:140
LTC4282_OC_AUTORETRY
#define LTC4282_OC_AUTORETRY
Definition: LTC4282.h:473
LTC4282_ILIM_ADJUST_31_V_2
#define LTC4282_ILIM_ADJUST_31_V_2
Definition: LTC4282.h:527
menu_4_set_alert_msb_register_menu_1
static int8_t menu_4_set_alert_msb_register_menu_1()
Set Alert Registers.
Definition: DC2024A.ino:849
LTC4282_VIN_MODE_5_V
#define LTC4282_VIN_MODE_5_V
Definition: LTC4282.h:489
menu_5_set_control_lsb_register_menu_2
static int8_t menu_5_set_control_lsb_register_menu_2(uint8_t *CTRLREG_LSB)
Control MSB Register Menu. Configure OV/UV/OC Autoretry, FET ON, Mass Write Enable, ON/ENB, ON DELAY and ON FAULT MASK.
Definition: DC2024A.ino:1262
LTC4282_EE_ALERT_LSB_REG
#define LTC4282_EE_ALERT_LSB_REG
Definition: LTC4282.h:299
LTC4282_ADC_16_BIT
#define LTC4282_ADC_16_BIT
Definition: LTC4282.h:535
LTC4282_EE_FAULT_REG
#define LTC4282_EE_FAULT_REG
Definition: LTC4282.h:300
LTC4282_POWER_MSB_REG
#define LTC4282_POWER_MSB_REG
Definition: LTC4282.h:332
LTC4282_EE_POWER_ALARM_MAX_REG
#define LTC4282_EE_POWER_ALARM_MAX_REG
Definition: LTC4282.h:311
voltage_fullscale
static float voltage_fullscale
Fullscale Voltage Setting Shared Across Functions For Polling Routines.
Definition: DC2024A.ino:113
LTC4282_TICK_OUT
#define LTC4282_TICK_OUT
Definition: LTC4282.h:519
menu_3_view_faults_menu_1
static int8_t menu_3_view_faults_menu_1()
View/Clear Faults.
Definition: DC2024A.ino:676
LTC4282_OV_MODE_MASK
#define LTC4282_OV_MODE_MASK
Definition: LTC4282.h:556
LTC4282_FOLDBACK_MODE_12_V_0
#define LTC4282_FOLDBACK_MODE_12_V_0
Definition: LTC4282.h:531
LTC4282_code_to_power
float LTC4282_code_to_power(uint16_t code, float fullscaleVoltage, float resistor)
Convert ADC code to power.
Definition: LTC4282.cpp:193
Linduino.h
Header File for Linduino Libraries and Demo Code.
LTC4282_VGPIO_MSB_REG
#define LTC4282_VGPIO_MSB_REG
Definition: LTC4282.h:314
LTC4282_VSENSE_ALARM_HIGH
#define LTC4282_VSENSE_ALARM_HIGH
Definition: LTC4282.h:502
menu_5_set_control_msb_register_menu_1
static int8_t menu_5_set_control_msb_register_menu_1(uint8_t *CTRLREG_MSB)
Settings.
Definition: DC2024A.ino:1148
LTC4282_code_to_VGPIO
float LTC4282_code_to_VGPIO(uint16_t code)
Convert ADC code to VGPIO.
Definition: LTC4282.cpp:168
LTC4282_VSENSE_ALARM_MAX_REG
#define LTC4282_VSENSE_ALARM_MAX_REG
Definition: LTC4282.h:277
LTC4282_EE_VGPIO_ALARM_MAX_REG
#define LTC4282_EE_VGPIO_ALARM_MAX_REG
Definition: LTC4282.h:307
LTC4282_power_to_code_alarm
uint8_t LTC4282_power_to_code_alarm(float power, float resistor, float fullscaleVoltage)
Convert power to alarm code.
Definition: LTC4282.cpp:288
LTC4282_VGPIO_ALARM_MAX_REG
#define LTC4282_VGPIO_ALARM_MAX_REG
Definition: LTC4282.h:275
LTC4282_code_to_current
float LTC4282_code_to_current(uint16_t code, float resistor)
Convert ADC code to current.
Definition: LTC4282.cpp:185
menu_4_set_alert_registers
static int8_t menu_4_set_alert_registers()
Clear Faults.
Definition: DC2024A.ino:797
LTC4282_ON_ALERT
#define LTC4282_ON_ALERT
Definition: LTC4282.h:495
LTC4282_OV_ALERT
#define LTC4282_OV_ALERT
Definition: LTC4282.h:499
LTC4282_current_to_code_alarm
uint8_t LTC4282_current_to_code_alarm(float current, float resistor)
Convert current to alarm code.
Definition: LTC4282.cpp:280
LTC4282_FOLDBACK_MODE_5_V_0
#define LTC4282_FOLDBACK_MODE_5_V_0
Definition: LTC4282.h:530
LTC4282_OC_ALERT
#define LTC4282_OC_ALERT
Definition: LTC4282.h:497
LTC4282_read_48_bits
int8_t LTC4282_read_48_bits(uint8_t i2c_address, uint8_t adc_command, uint64_t *adc_code)
Read a 48-bit code from the LTC4282.
Definition: LTC4282.cpp:154
menu_3_clear_faults_menu_2
static int8_t menu_3_clear_faults_menu_2()
View Faults.
Definition: DC2024A.ino:781
LTC4282_EE_CLK_DEC_REG
#define LTC4282_EE_CLK_DEC_REG
Definition: LTC4282.h:312
LTC4282_I2C_ADDRESS
#define LTC4282_I2C_ADDRESS
Definition: LTC4282.h:157
LTC4282_VSOURCE_MIN_MSB_REG
#define LTC4282_VSOURCE_MIN_MSB_REG
Definition: LTC4282.h:322
LTC4282_VIN_MODE_MASK
#define LTC4282_VIN_MODE_MASK
Definition: LTC4282.h:557
LTC4282_EE_VGPIO_ALARM_MIN_REG
#define LTC4282_EE_VGPIO_ALARM_MIN_REG
Definition: LTC4282.h:306
menu_5_set_ilim_adjust_register_menu_3
static uint8_t menu_5_set_ilim_adjust_register_menu_3(uint8_t *ILIM_ADJUST)
Control LSB Register Menu. Configure Thresholds for POWER GOOD/OV/UV as well as for VIN MODE...
Definition: DC2024A.ino:1399
LTC4282_VSENSE_MIN_MSB_REG
#define LTC4282_VSENSE_MIN_MSB_REG
Definition: LTC4282.h:328
print_prompt
static void print_prompt()
Print the Prompt.
Definition: DC2024A.ino:139
LTC4282_POWER_ALARM_HIGH
#define LTC4282_POWER_ALARM_HIGH
Definition: LTC4282.h:500
LTC4282_VGPIO_MIN_MSB_REG
#define LTC4282_VGPIO_MIN_MSB_REG
Definition: LTC4282.h:316
resistor
const float resistor
resistor value on demo board
Definition: DC2024A.ino:111
menu_4_set_alert_lsb_register_menu_2
static int8_t menu_4_set_alert_lsb_register_menu_2()
Set Alert MSB Register.
Definition: DC2024A.ino:966
LTC4282_VSOURCE_5V_FS
const float LTC4282_VSOURCE_5V_FS
Definition: LTC4282.h:569
LTC4282_VSOURCE_MAX_MSB_REG
#define LTC4282_VSOURCE_MAX_MSB_REG
Definition: LTC4282.h:324
LTC4282_GPIO1_CONFIG_POWER_BAD
#define LTC4282_GPIO1_CONFIG_POWER_BAD
Definition: LTC4282.h:511
LTC4282_VSOURCE_3V3_FS
const float LTC4282_VSOURCE_3V3_FS
Definition: LTC4282.h:570
alert_code
static uint8_t alert_code
Value stored or read from ALERT register.
Definition: DC1496BB.ino:125
LTC4282_GPIO_CONFIG_REG
#define LTC4282_GPIO_CONFIG_REG
Definition: LTC4282.h:271
LTC4282_METER_MSB5_REG
#define LTC4282_METER_MSB5_REG
Definition: LTC4282.h:282
LTC4282_COULOMB_METER
#define LTC4282_COULOMB_METER
Definition: LTC4282.h:518
print_title
static void print_title()
Print the title block.
Definition: DC2024A.ino:125
LTC4282_OV_MODE_5
#define LTC4282_OV_MODE_5
Definition: LTC4282.h:485
LTC4282_FET_BAD_FAULT_TIME_REG
#define LTC4282_FET_BAD_FAULT_TIME_REG
Definition: LTC4282.h:270
LTC4282_ILIM_ADJUST_25_V_0
#define LTC4282_ILIM_ADJUST_25_V_0
Definition: LTC4282.h:525
LTC4282_VSOURCE_12V_FS
const float LTC4282_VSOURCE_12V_FS
Definition: LTC4282.h:568
LTC4282_EE_CONTROL_MSB_REG
#define LTC4282_EE_CONTROL_MSB_REG
Definition: LTC4282.h:296
LTC4282_ON_ENB
#define LTC4282_ON_ENB
Definition: LTC4282.h:470
LTC4282_VSENSE_ALARM_MIN_REG
#define LTC4282_VSENSE_ALARM_MIN_REG
Definition: LTC4282.h:276
LTC4282_GPIO3_PD
#define LTC4282_GPIO3_PD
Definition: LTC4282.h:508
LTC4282_EE_ILIM_ADJUST_REG
#define LTC4282_EE_ILIM_ADJUST_REG
Definition: LTC4282.h:313
LTC4282_GPIO2_PD
#define LTC4282_GPIO2_PD
Definition: LTC4282.h:509
LTC4282_code_to_energy
float LTC4282_code_to_energy(uint64_t code, float fullscaleVoltage, float resistor, float tConv)
Convert ADC code to energy.
Definition: LTC4282.cpp:200
LTC4282_POWER_ALARM_MIN_REG
#define LTC4282_POWER_ALARM_MIN_REG
Definition: LTC4282.h:278
LTC4282_ADC_CONV_ALERT
#define LTC4282_ADC_CONV_ALERT
Definition: LTC4282.h:515
LTC4282_FB_MODE_EXTERNAL
#define LTC4282_FB_MODE_EXTERNAL
Definition: LTC4282.h:476
LTC4282_code_to_GPIO_alarm
float LTC4282_code_to_GPIO_alarm(uint8_t code)
Convert ADC code to GPIO alarm voltage.
Definition: LTC4282.cpp:232
LTC4282_volt_to_code_alarm
uint8_t LTC4282_volt_to_code_alarm(float volt, float fullscaleVoltage)
Convert voltage to alarm code.
Definition: LTC4282.cpp:272
QuikEval_EEPROM.h
QuikEval EEPROM Library.
LTC4282_write
int8_t LTC4282_write(uint8_t i2c_address, uint8_t adc_command, uint8_t code)
Write an 8-bit code to the LTC4282.
Definition: LTC4282.cpp:69
LTC4282_CONTROL_MSB_REG
#define LTC4282_CONTROL_MSB_REG
Definition: LTC4282.h:264
LTC4282_FB_MODE_5
#define LTC4282_FB_MODE_5
Definition: LTC4282.h:477
LTC4282_VGPIO_ALARM_LOW
#define LTC4282_VGPIO_ALARM_LOW
Definition: LTC4282.h:507
LTC4282_UV_AUTORETRY
#define LTC4282_UV_AUTORETRY
Definition: LTC4282.h:474
LTC4282_ILIM_ADJUST_28_V_1
#define LTC4282_ILIM_ADJUST_28_V_1
Definition: LTC4282.h:526
LTC4282_ILIM_ADJUST_21_V_8
#define LTC4282_ILIM_ADJUST_21_V_8
Definition: LTC4282.h:524
LTC4282_GPIO1_OUTPUT
#define LTC4282_GPIO1_OUTPUT
Definition: LTC4282.h:514
LTC4282_EE_FET_BAD_FAULT_TIME_REG
#define LTC4282_EE_FET_BAD_FAULT_TIME_REG
Definition: LTC4282.h:302
menu_5_configure_GPIO_pins_menu_4
static uint8_t menu_5_configure_GPIO_pins_menu_4()
Definition: DC2024A.ino:1550
LTC4282_GPIO1_CONFIG_INPUT
#define LTC4282_GPIO1_CONFIG_INPUT
Definition: LTC4282.h:513
discover_demo_board
int8_t discover_demo_board(char *demo_name)
Read the ID string from the EEPROM and determine if the correct board is connected.
Definition: QuikEval_EEPROM.cpp:141
LTC4282_code_to_volt_alarm
float LTC4282_code_to_volt_alarm(uint8_t code, float fullscaleVoltage)
Convert ADC code to alarm voltage.
Definition: LTC4282.cpp:240
LTC4282_VIN_MODE_12_V
#define LTC4282_VIN_MODE_12_V
Definition: LTC4282.h:490
LTC4282_FB_MODE_15
#define LTC4282_FB_MODE_15
Definition: LTC4282.h:479
menu_2_alarm_thresholds
static int8_t menu_2_alarm_thresholds(uint8_t CTRLREG_LSB)
Continuous Mode Measurement.
Definition: DC2024A.ino:491
LTC4282_EE_POWER_ALARM_MIN_REG
#define LTC4282_EE_POWER_ALARM_MIN_REG
Definition: LTC4282.h:310
LTC4282_ON_DELAY
#define LTC4282_ON_DELAY
Definition: LTC4282.h:469
LTC4282_ILIM_ADJUST_REG
#define LTC4282_ILIM_ADJUST_REG
Definition: LTC4282.h:281
LTC4282_FB_MODE_MASK
#define LTC4282_FB_MODE_MASK
LTC4282 Register MASKS.
Definition: LTC4282.h:554
LTC4282_VIN_MODE_3_V_3
#define LTC4282_VIN_MODE_3_V_3
Definition: LTC4282.h:488
menu_3_view_clear_faults
static int8_t menu_3_view_clear_faults()
Set Alarm Thresholds.
Definition: DC2024A.ino:629
LTC4282_EE_VSOURCE_ALARM_MIN_REG
#define LTC4282_EE_VSOURCE_ALARM_MIN_REG
Definition: LTC4282.h:304
LTC4282_CONTROL_LSB_REG
#define LTC4282_CONTROL_LSB_REG
Definition: LTC4282.h:265
LTC4282_STRESS_TO_GPIO2
#define LTC4282_STRESS_TO_GPIO2
Definition: LTC4282.h:516
LTC4282_ALERT_LSB_REG
#define LTC4282_ALERT_LSB_REG
Definition: LTC4282.h:267
demo_board_connected
static int8_t demo_board_connected
Set to 1 if the board is connected.
Definition: DC2024A.ino:121
LTC4282_EE_VSENSE_ALARM_MIN_REG
#define LTC4282_EE_VSENSE_ALARM_MIN_REG
Definition: LTC4282.h:308
LT_I2C.h
LT_I2C: Routines to communicate with ATmega328P&#39;s hardware I2C port.
LTC4282_VSOURCE_ALARM_HIGH
#define LTC4282_VSOURCE_ALARM_HIGH
Definition: LTC4282.h:504
LTC4282_VSENSE_MSB_REG
#define LTC4282_VSENSE_MSB_REG
Definition: LTC4282.h:326
LTC4282_OV_MODE_EXTERNAL
#define LTC4282_OV_MODE_EXTERNAL
Definition: LTC4282.h:484
LTC4282_UV_MODE_5
#define LTC4282_UV_MODE_5
Definition: LTC4282.h:481
setup
static void setup()
Initialize Linduino.
Definition: DC2024A.ino:152
LTC4282_OV_MODE_15
#define LTC4282_OV_MODE_15
Definition: LTC4282.h:487
LTC4282_POWER_ALARM_LOW
#define LTC4282_POWER_ALARM_LOW
Definition: LTC4282.h:501
LTC4282_CLK_DEC_REG
#define LTC4282_CLK_DEC_REG
Definition: LTC4282.h:280
demo_name
char demo_name[]
Demo Board Name stored in QuikEval EEPROM.
Definition: DC1880A.ino:97
LTC4282_OV_AUTORETRY
#define LTC4282_OV_AUTORETRY
Definition: LTC4282.h:475
UserInterface.h
LTC4282_VGPIO_ALARM_MIN_REG
#define LTC4282_VGPIO_ALARM_MIN_REG
Definition: LTC4282.h:274
read_int
int32_t read_int()
Definition: UserInterface.cpp:93
LTC4282_VSENSE_MAX_MSB_REG
#define LTC4282_VSENSE_MAX_MSB_REG
Definition: LTC4282.h:330
LTC4282_ON_FAULT_MASK
#define LTC4282_ON_FAULT_MASK
Definition: LTC4282.h:467
LTC4282_ILIM_ADJUST_15_V_6
#define LTC4282_ILIM_ADJUST_15_V_6
Definition: LTC4282.h:522
LTC4282_ADC_VSOURCE
#define LTC4282_ADC_VSOURCE
Definition: LTC4282.h:533
LTC4282_ADC_ALERT_LOG_REG
#define LTC4282_ADC_ALERT_LOG_REG
Definition: LTC4282.h:269
LTC4282_EE_VSENSE_ALARM_MAX_REG
#define LTC4282_EE_VSENSE_ALARM_MAX_REG
Definition: LTC4282.h:309
LTC4282_FET_BAD_FAULT_ALERT
#define LTC4282_FET_BAD_FAULT_ALERT
Definition: LTC4282.h:493
LTC4282_ILIM_ADJUST_18_V_7
#define LTC4282_ILIM_ADJUST_18_V_7
Definition: LTC4282.h:523
read_float
float read_float()
Definition: UserInterface.cpp:78
LTC4282_INT_CLK_OUT
#define LTC4282_INT_CLK_OUT
Definition: LTC4282.h:520
LTC4282_UV_MODE_10
#define LTC4282_UV_MODE_10
Definition: LTC4282.h:482
LTC4282_VGPIO_ALARM_HIGH
#define LTC4282_VGPIO_ALARM_HIGH
Definition: LTC4282.h:506
LTC4282_GPIO1_CONFIG_POWER_GOOD
#define LTC4282_GPIO1_CONFIG_POWER_GOOD
Definition: LTC4282.h:510
LTC4282_EE_ADC_ALERT_LOG_REG
#define LTC4282_EE_ADC_ALERT_LOG_REG
Definition: LTC4282.h:301
LTC4282_read_16_bits
int8_t LTC4282_read_16_bits(uint8_t i2c_address, uint8_t adc_command, uint16_t *adc_code)
Read a 16-bit code from the LTC4282.
Definition: LTC4282.cpp:129
LTC4282.h
LTC4282: High Current Hot Swap Controller with I2C Compatible Monitoring and EEPROM.
LTC4282_POWER_MIN_MSB_REG
#define LTC4282_POWER_MIN_MSB_REG
Definition: LTC4282.h:334
LTC4282_OV_MODE_10
#define LTC4282_OV_MODE_10
Definition: LTC4282.h:486
quikeval_I2C_init
void quikeval_I2C_init(void)
Initializes Linduino I2C port.
Definition: LT_I2C.cpp:394
LTC4282_EE_GPIO_CONFIG_REG
#define LTC4282_EE_GPIO_CONFIG_REG
Definition: LTC4282.h:303
menu_1_continuous_mode
static int8_t menu_1_continuous_mode(uint8_t CTRLA, uint8_t ILIM_ADJUST, uint8_t CLK_DECIMATOR, float resister)
Continious Mode.
Definition: DC2024A.ino:232
LTC4282_FOLDBACK_MODE_3_V_3
#define LTC4282_FOLDBACK_MODE_3_V_3
Definition: LTC4282.h:529
quikeval_I2C_connect
void quikeval_I2C_connect(void)
Switch MUX to connect I2C pins to QuikEval connector.
Definition: LT_I2C.cpp:401
LTC4282_EEPROM_DONE_ALERT
#define LTC4282_EEPROM_DONE_ALERT
Definition: LTC4282.h:492
LTC4282_VSENSE_ALARM_LOW
#define LTC4282_VSENSE_ALARM_LOW
Definition: LTC4282.h:503
LTC4282_FET_SHORT_ALERT
#define LTC4282_FET_SHORT_ALERT
Definition: LTC4282.h:494
LTC4282_VIN_MODE_24_V
#define LTC4282_VIN_MODE_24_V
Definition: LTC4282.h:491
LTC4282_UV_MODE_EXTERNAL
#define LTC4282_UV_MODE_EXTERNAL
Definition: LTC4282.h:480
LTC4282_read
int8_t LTC4282_read(uint8_t i2c_address, uint8_t adc_command, uint8_t *adc_code)
Read an 8-bit code from the LTC4282.
Definition: LTC4282.cpp:120
current
static uint16_t current
the current measurement from the LTC3335&#39;s counter test mode.
Definition: DC2343A.ino:114
LTC4282_EE_VSOURCE_ALARM_MAX_REG
#define LTC4282_EE_VSOURCE_ALARM_MAX_REG
Definition: LTC4282.h:305
LTC4282_FOLDBACK_MASK
#define LTC4282_FOLDBACK_MASK
Definition: LTC4282.h:559
LTC4282_GPIO1_CONFIG_OUTPUT
#define LTC4282_GPIO1_CONFIG_OUTPUT
Definition: LTC4282.h:512
LTC4282_EE_CONTROL_LSB_REG
#define LTC4282_EE_CONTROL_LSB_REG
Definition: LTC4282.h:297
ack_error
const char ack_error[]
Error message.
Definition: DC2024A.ino:118
LTC4282_VSOURCE_24V_FS
const float LTC4282_VSOURCE_24V_FS
Definition: LTC4282.h:567
LTC4282_VGPIO_MAX_MSB_REG
#define LTC4282_VGPIO_MAX_MSB_REG
Definition: LTC4282.h:318
LTC4282_code_to_current_alarm
float LTC4282_code_to_current_alarm(uint8_t code, float resistor)
Convert ADC code to alarm current.
Definition: LTC4282.cpp:248
LTC4282_UV_MODE_15
#define LTC4282_UV_MODE_15
Definition: LTC4282.h:483
LTC4282_TICK_COUNTER_MSB3_REG
#define LTC4282_TICK_COUNTER_MSB3_REG
Definition: LTC4282.h:288
LTC4282_POWER_MAX_MSB_REG
#define LTC4282_POWER_MAX_MSB_REG
Definition: LTC4282.h:336
LTC4282_code_to_avg_current
float LTC4282_code_to_avg_current(uint64_t code, float coulombs, float tConv)
Convert ADC code to average current.
Definition: LTC4282.cpp:224
LTC4282_ILIM_ADJUST_MASK
#define LTC4282_ILIM_ADJUST_MASK
Definition: LTC4282.h:558
adc_code
static uint32_t adc_code
Definition: DC2071AA.ino:113
menu_5_restore_register_values_from_EEPROM_menu_6
static uint8_t menu_5_restore_register_values_from_EEPROM_menu_6()
Write Values currently present in the Registers of the LTC4282 to the EEPROM.
Definition: DC2024A.ino:1855
LTC4282_GPIO1_CONFIG_MASK
#define LTC4282_GPIO1_CONFIG_MASK
Definition: LTC4282.h:560
LTC4282_POWER_ALARM_MAX_REG
#define LTC4282_POWER_ALARM_MAX_REG
Definition: LTC4282.h:279
LTC4282_code_to_power_alarm
float LTC4282_code_to_power_alarm(uint8_t code, float fullscaleVoltage, float resistor)
Convert ADC code to alarm power.
Definition: LTC4282.cpp:256
LTC4282_ADC_GPIO2_MODE
#define LTC4282_ADC_GPIO2_MODE
Definition: LTC4282.h:534
loop
static void loop()
Definition: DC2024A.ino:173