Linduino  1.3.0
Linear Technology Arduino-Compatible Demonstration Board
LTC6813.cpp
Go to the documentation of this file.
1 /*! LTC6813: Multicell Battery Monitors
2 *
3 *@verbatim
4 *The LTC6813 is multi-cell battery stack monitor that measures up to 18 series
5 *connected battery cells with a total measurement error of less than 2.2mV.
6 *The cell measurement range of 0V to 5V makes the LTC6813 suitable for most
7 *battery chemistries. All 18 cell voltages can be captured in 290uS, and lower
8 *data acquisition rates can be selected for high noise reduction.
9 *Using the LTC6813-1, multiple devices are connected in a daisy-chain with one
10 *host processor connection for all devices, permitting simultaneous cell monitoring
11 *of long, high voltage battery strings.
12 *@endverbatim
13 *
14 * https://www.analog.com/en/products/ltc6813-1.html
15 * https://www.analog.com/en/design-center/evaluation-hardware-and-software/evaluation-boards-kits/dc2350a-b.html
16 *
17 *********************************************************************************
18 * Copyright 2019(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 //! @ingroup BMS
53 //! @{
54 //! @defgroup LTC6813-1 LTC6813-1: Multicell Battery Monitor
55 //! @}
56 
57 /*! @file
58  @ingroup LTC6813-1
59  Library for LTC6813-1 Multicell Battery Monitor
60 */
61 
62 #include "stdint.h"
63 #include "LTC681x.h"
64 #include "LTC6813.h"
65 
66 /* Helper function to initialize register limits. */
67 void LTC6813_init_reg_limits(uint8_t total_ic, //Number of ICs in the system
68  cell_asic *ic // A two dimensional array that will store the data
69  )
70 {
71  for(uint8_t cic=0; cic<total_ic; cic++)
72  {
73  ic[cic].ic_reg.cell_channels=18;
74  ic[cic].ic_reg.stat_channels=4;
75  ic[cic].ic_reg.aux_channels=9;
76  ic[cic].ic_reg.num_cv_reg=6;
77  ic[cic].ic_reg.num_gpio_reg=4;
78  ic[cic].ic_reg.num_stat_reg=2;
79  }
80 }
81 
82  /*
83 This command will write the configuration registers of the LTC6813-1s
84 connected in a daisy chain stack. The configuration is written in descending
85 order so the last device's configuration is written first.
86 */
87 void LTC6813_wrcfg(uint8_t total_ic, //The number of ICs being written to
88  cell_asic *ic //A two dimensional array of the configuration data that will be written
89  )
90 {
91  LTC681x_wrcfg(total_ic,ic);
92 }
93 
94 /*
95 This command will write the configuration b registers of the LTC6813-1s
96 connected in a daisy chain stack. The configuration is written in descending
97 order so the last device's configuration is written first.
98 */
99 void LTC6813_wrcfgb(uint8_t total_ic, //The number of ICs being written to
100  cell_asic *ic //A two dimensional array of the configuration data that will be written
101  )
102 {
103  LTC681x_wrcfgb(total_ic,ic);
104 }
105 
106 /* Reads configuration registers of a LTC6813 daisy chain */
107 int8_t LTC6813_rdcfg(uint8_t total_ic, //Number of ICs in the system
108  cell_asic *ic //A two dimensional array that the function stores the read configuration data.
109  )
110 {
111  int8_t pec_error = 0;
112  pec_error = LTC681x_rdcfg(total_ic,ic);
113  return(pec_error);
114 }
115 
116 /* Reads configuration b registers of a LTC6813 daisy chain */
117 int8_t LTC6813_rdcfgb(uint8_t total_ic, //Number of ICs in the system
118  cell_asic *ic //A two dimensional array that the function stores the read configuration data.
119  )
120 {
121  int8_t pec_error = 0;
122  pec_error = LTC681x_rdcfgb(total_ic,ic);
123  return(pec_error);
124 }
125 
126 /* Starts cell voltage conversion */
127 void LTC6813_adcv(uint8_t MD, //ADC Mode
128  uint8_t DCP, //Discharge Permit
129  uint8_t CH //Cell Channels to be measured
130  )
131 {
132  LTC681x_adcv(MD,DCP,CH);
133 }
134 
135 /* Start a GPIO and Vref2 Conversion */
136 void LTC6813_adax(uint8_t MD, //ADC Mode
137  uint8_t CHG //GPIO Channels to be measured)
138  )
139 {
140  LTC681x_adax(MD,CHG);
141 }
142 
143 /* Start a Status ADC Conversion */
144 void LTC6813_adstat(uint8_t MD, //ADC Mode
145  uint8_t CHST //Stat Channels to be measured
146 )
147 {
148  LTC681x_adstat(MD,CHST);
149 }
150 
151 /* Starts cell voltage and GPIO 1&2 conversion */
152 void LTC6813_adcvax(uint8_t MD, //ADC Mode
153  uint8_t DCP //Discharge Permit
154  )
155 {
156  LTC681x_adcvax(MD,DCP);
157 }
158 
159 /* Starts cell voltage and SOC conversion */
160 void LTC6813_adcvsc( uint8_t MD, //ADC Mode
161  uint8_t DCP //Discharge Permit
162  )
163 {
164  LTC681x_adcvsc(MD,DCP);
165 }
166 
167 /* Reads and parses the LTC6813 cell voltage registers */
168 uint8_t LTC6813_rdcv(uint8_t reg, // Controls which cell voltage register is read back.
169  uint8_t total_ic, // The number of ICs in the system
170  cell_asic *ic // Array of the parsed cell codes
171  )
172 {
173  int8_t pec_error = 0;
174  pec_error = LTC681x_rdcv(reg,total_ic,ic);
175  return(pec_error);
176 }
177 
178 /*
179 The function is used
180 to read the parsed GPIO codes of the LTC6813. This function will send the requested
181 read commands parse the data and store the gpio voltages in aux_codes variable
182 */
183 int8_t LTC6813_rdaux(uint8_t reg, //Determines which GPIO voltage register is read back.
184  uint8_t total_ic,//The number of ICs in the system
185  cell_asic *ic//A two dimensional array of the gpio voltage codes.
186  )
187 {
188  int8_t pec_error = 0;
189  LTC681x_rdaux(reg,total_ic,ic);
190  return (pec_error);
191 }
192 
193 /*
194 Reads and parses the LTC6813 stat registers.
195 The function is used
196 to read the parsed stat codes of the LTC6813. This function will send the requested
197 read commands parse the data and store the stat voltages in stat_codes variable
198 */
199 int8_t LTC6813_rdstat(uint8_t reg, //Determines which Stat register is read back.
200  uint8_t total_ic,//The number of ICs in the system
201  cell_asic *ic //A two dimensional array of the stat codes.
202  )
203 {
204  int8_t pec_error = 0;
205  pec_error = LTC681x_rdstat(reg,total_ic,ic);
206  return (pec_error);
207 }
208 
209 /* Sends the poll ADC command */
210 uint8_t LTC6813_pladc()
211 {
212  return(LTC681x_pladc());
213 }
214 
215 /* This function will block operation until the ADC has finished it's conversion */
216 uint32_t LTC6813_pollAdc()
217 {
218  return(LTC681x_pollAdc());
219 }
220 
221 /*
222 The command clears the cell voltage registers and initializes
223 all values to 1. The register will read back hexadecimal 0xFF
224 after the command is sent.
225 */
227 {
228  LTC681x_clrcell();
229 }
230 
231 /*
232 The command clears the Auxiliary registers and initializes
233 all values to 1. The register will read back hexadecimal 0xFF
234 after the command is sent.
235 */
237 {
238  LTC681x_clraux();
239 }
240 
241 /*
242 The command clears the Stat registers and initializes
243 all values to 1. The register will read back hexadecimal 0xFF
244 after the command is sent.
245 */
247 {
248  LTC681x_clrstat();
249 }
250 
251 /* Starts the Mux Decoder diagnostic self test */
253 {
254  LTC681x_diagn();
255 }
256 
257 /* Starts cell voltage self test conversion */
258 void LTC6813_cvst(uint8_t MD, //ADC Mode
259  uint8_t ST //Self Test
260  )
261 {
262  LTC681x_cvst(MD,ST);
263 }
264 
265 /* Start an Auxiliary Register Self Test Conversion */
266 void LTC6813_axst(uint8_t MD, //ADC Mode
267  uint8_t ST //Self Test
268  )
269 {
270  LTC681x_axst(MD,ST);
271 }
272 
273 /* Start a Status Register Self Test Conversion */
274 void LTC6813_statst(uint8_t MD, //ADC Mode
275  uint8_t ST //Self Test
276  )
277 {
278  LTC681x_statst(MD,ST);
279 }
280 
281 /* Starts cell voltage overlap conversion */
282 void LTC6813_adol(uint8_t MD, //ADC Mode
283  uint8_t DCP //Discharge Permit
284  )
285 {
286  LTC681x_adol(MD,DCP);
287 }
288 
289 /* Start an GPIO Redundancy test */
290 void LTC6813_adaxd(uint8_t MD, //ADC Mode
291  uint8_t CHG //GPIO Channels to be measured
292  )
293 {
294  LTC681x_adaxd(MD,CHG);
295 }
296 
297 /* Start a Status register redundancy test Conversion */
298 void LTC6813_adstatd(uint8_t MD, //ADC Mode
299  uint8_t CHST //Stat Channels to be measured
300  )
301 {
302  LTC681x_adstatd(MD,CHST);
303 }
304 
305 /* Runs the Digital Filter Self Test */
306 int16_t LTC6813_run_cell_adc_st(uint8_t adc_reg, // Type of register
307  uint8_t total_ic, // Number of ICs in the system
308  cell_asic *ic, // A two dimensional array that will store the data
309  uint8_t md, //ADC Mode
310  bool adcopt // The adcopt bit in the configuration register
311  )
312 {
313  int16_t error = 0;
314  error = LTC681x_run_cell_adc_st(adc_reg,total_ic,ic,md,adcopt);
315  return(error);
316 }
317 
318 /* Runs the ADC overlap test for the IC */
319 uint16_t LTC6813_run_adc_overlap(uint8_t total_ic, // Number of ICs in the system
320  cell_asic *ic // A two dimensional array that will store the data
321  )
322 {
323  uint16_t error = 0;
324  int32_t measure_delta =0;
325  int16_t failure_pos_limit = 20;
326  int16_t failure_neg_limit = -20;
327  uint32_t conv_time=0;
328  wakeup_idle(total_ic);
330  conv_time = LTC681x_pollAdc();
331 
332  wakeup_idle(total_ic);
333  error = LTC681x_rdcv(0, total_ic,ic);
334  for (int cic = 0; cic<total_ic; cic++)
335  {
336 
337 
338  measure_delta = (int32_t)ic[cic].cells.c_codes[6]-(int32_t)ic[cic].cells.c_codes[7];
339  if ((measure_delta>failure_pos_limit) || (measure_delta<failure_neg_limit))
340  {
341  error = error | (1<<(cic-1));
342  }
343  measure_delta = (int32_t)ic[cic].cells.c_codes[12]-(int32_t)ic[cic].cells.c_codes[13];
344  if ((measure_delta>failure_pos_limit) || (measure_delta<failure_neg_limit))
345  {
346  error = error | (1<<(cic-1));
347  }
348  }
349  return(error);
350 }
351 
352 /* Runs the redundancy self test */
353 int16_t LTC6813_run_adc_redundancy_st(uint8_t adc_mode, //ADC Mode
354  uint8_t adc_reg, // Type of register
355  uint8_t total_ic, // Number of ICs in the system
356  cell_asic *ic // A two dimensional array that will store the data
357  )
358 {
359  int16_t error = 0;
360  LTC681x_run_adc_redundancy_st(adc_mode,adc_reg,total_ic,ic);
361  return(error);
362 }
363 
364 /* Start an open wire Conversion */
365 void LTC6813_adow(uint8_t MD, //ADC Mode
366  uint8_t PUP, //Pull up/Pull down current
367  uint8_t CH, //Sets which Cell channels are converted
368  uint8_t DCP //Discharge Permit
369  )
370 {
371  LTC681x_adow(MD,PUP,CH,DCP);
372 }
373 
374 /* Start GPIOs open wire ADC conversion */
375 void LTC6813_axow(uint8_t MD, //ADC Mode
376  uint8_t PUP //Pull up/Pull down current
377  )
378 {
379  LTC681x_axow(MD, PUP);
380 }
381 
382 /* Runs the data sheet algorithm for open wire for single cell detection */
383 void LTC6813_run_openwire_single(uint8_t total_ic, // Number of ICs in the system
384  cell_asic *ic // A two dimensional array that will store the data
385  )
386 {
387  LTC681x_run_openwire_single(total_ic, ic);
388 }
389 
390 /* Runs the data sheet algorithm for open wire for multiple cell and two consecutive cells detection */
391 void LTC6813_run_openwire_multi(uint8_t total_ic, // Number of ICs in the system
392  cell_asic *ic // A two dimensional array that will store the data
393  )
394 {
395  LTC681x_run_openwire_multi( total_ic, ic);
396 }
397 
398 /* Runs open wire for GPIOs */
399 void LTC6813_run_gpio_openwire(uint8_t total_ic, // Number of ICs in the system
400  cell_asic *ic // A two dimensional array that will store the data
401  )
402 {
403  LTC681x_run_gpio_openwire(total_ic, ic);
404 }
405 
406 /* Helper function to set discharge bit in CFG register */
407 void LTC6813_set_discharge(int Cell, // Cell to be discharged
408  uint8_t total_ic, // Number of ICs in the system
409  cell_asic *ic // A two dimensional array that will store the data
410  )
411 {
412  for (int i=0; i<total_ic; i++)
413  {
414  if (Cell==0)
415  {
416  ic[i].configb.tx_data[1] = ic[i].configb.tx_data[1] |(0x04);
417  }
418  else if (Cell<9)
419  {
420  ic[i].config.tx_data[4] = ic[i].config.tx_data[4] | (1<<(Cell-1));
421  }
422  else if (Cell < 13)
423  {
424  ic[i].config.tx_data[5] = ic[i].config.tx_data[5] | (1<<(Cell-9));
425  }
426  else if (Cell<17)
427  {
428  ic[i].configb.tx_data[0] = ic[i].configb.tx_data[0] | (1<<(Cell-9));
429  }
430  else if (Cell<19)
431  {
432  ic[i].configb.tx_data[1] = ic[i].configb.tx_data[1] | (1<<(Cell-17));
433  }
434  else
435  {
436  break;
437  }
438  }
439 }
440 
441 /* Clears all of the DCC bits in the configuration registers */
442 void LTC6813_clear_discharge(uint8_t total_ic, // Number of ICs in the system
443  cell_asic *ic // A two dimensional array that will store the data
444  )
445 {
446  LTC681x_clear_discharge(total_ic,ic);
447 }
448 
449 /* Writes the pwm registers of a LTC6813 daisy chain */
450 void LTC6813_wrpwm(uint8_t total_ic, // Number of ICs in the system
451  uint8_t pwmReg, // PWM Register A or B
452  cell_asic *ic //A two dimensional array of the configuration data that will be written
453  )
454 {
455  LTC681x_wrpwm(total_ic,pwmReg,ic);
456 }
457 
458 /* Reads pwm registers of a LTC6813 daisy chain */
459 int8_t LTC6813_rdpwm(uint8_t total_ic, //Number of ICs in the system
460  uint8_t pwmReg, // PWM Register A or B
461  cell_asic *ic //A two dimensional array that the function stores the read configuration data.
462  )
463 {
464  int8_t pec_error =0;
465  pec_error = LTC681x_rdpwm(total_ic,pwmReg,ic);
466  return(pec_error);
467 }
468 
469 /* Writes data in S control register the ltc6813-1 connected in a daisy chain stack */
470 void LTC6813_wrsctrl(uint8_t total_ic, // number of ICs in the daisy chain
471  uint8_t sctrl_reg, // SCTRL Register A or B
472  cell_asic *ic // A two dimensional array that will store the data
473  )
474 {
475  LTC681x_wrsctrl(total_ic, sctrl_reg, ic);
476 }
477 
478 /* Reads sctrl registers of a LTC6813 daisy chain */
479 int8_t LTC6813_rdsctrl(uint8_t total_ic, // number of ICs in the daisy chain
480  uint8_t sctrl_reg, // SCTRL Register A or B
481  cell_asic *ic //< a two dimensional array that the function stores the read data
482  )
483 {
484  LTC681x_rdsctrl( total_ic, sctrl_reg,ic );
485 }
486 
487 /*
488 Start Sctrl data communication
489 This command will start the sctrl pulse communication over the spins
490 */
492 {
493  LTC681x_stsctrl();
494 }
495 
496 /*
497 The command clears the Sctrl registers and initializes
498 all values to 0. The register will read back hexadecimal 0x00
499 after the command is sent.
500 */
502 {
504 }
505 
506 /* Write the 6813 PWM/Sctrl Register B */
507 void LTC6813_wrpsb(uint8_t total_ic, // Number of ICs in the system
508  cell_asic *ic // A two dimensional array that will store the data
509  )
510 {
511  uint8_t cmd[2];
512  uint8_t write_buffer[256];
513  uint8_t c_ic = 0;
514 
515  cmd[0] = 0x00;
516  cmd[1] = 0x1C;
517  for(uint8_t current_ic = 0; current_ic<total_ic;current_ic++)
518  {
519  if(ic->isospi_reverse == true){c_ic = current_ic;}
520  else{c_ic = total_ic - current_ic - 1;}
521 
522  write_buffer[0] = ic[c_ic].pwmb.tx_data[0];
523  write_buffer[1] = ic[c_ic].pwmb.tx_data[1];
524  write_buffer[2]= ic[c_ic].pwmb.tx_data[2];
525  write_buffer[3] = ic[c_ic].sctrlb.tx_data[3];
526  write_buffer[4] = ic[c_ic].sctrlb.tx_data[4];
527  write_buffer[5]= ic[c_ic].sctrlb.tx_data[5];
528  }
529  write_68(total_ic, cmd, write_buffer);
530 }
531 
532 /* Reading the 6813 PWM/Sctrl Register B */
533 uint8_t LTC6813_rdpsb(uint8_t total_ic, //< number of ICs in the daisy chain
534  cell_asic *ic //< a two dimensional array that the function stores the read data
535  )
536 {
537  uint8_t cmd[4];
538  uint8_t read_buffer[256];
539  int8_t pec_error = 0;
540  uint16_t data_pec;
541  uint16_t calc_pec;
542  uint8_t c_ic = 0;
543  cmd[0] = 0x00;
544  cmd[1] = 0x1E;
545  pec_error = read_68(total_ic, cmd, read_buffer);
546 
547  for(uint8_t current_ic =0; current_ic<total_ic; current_ic++)
548  {
549  if(ic->isospi_reverse == false){c_ic = current_ic;}
550  else{c_ic = total_ic - current_ic - 1;}
551  for(int byte=0; byte<3;byte++)
552  {
553  ic[c_ic].pwmb.rx_data[byte] = read_buffer[byte+(8*current_ic)];
554  }
555 
556  for(int byte=3; byte<6;byte++)
557  {
558  ic[c_ic].sctrlb.rx_data[byte] = read_buffer[byte+(8*current_ic)];
559  }
560 
561  for(int byte=6; byte<8;byte++)
562  {
563  ic[c_ic].pwmb.rx_data[byte] = read_buffer[byte+(8*current_ic)];
564  ic[c_ic].sctrlb.rx_data[byte] = read_buffer[byte+(8*current_ic)];
565  }
566 
567  calc_pec = pec15_calc(6,&read_buffer[8*current_ic]);
568  data_pec = read_buffer[7+(8*current_ic)] | (read_buffer[6+(8*current_ic)]<<8);
569  if(calc_pec != data_pec )
570  {
571  ic[c_ic].pwmb.rx_pec_match = 1;
572  ic[c_ic].sctrlb.rx_pec_match = 1;
573 
574  }
575  else
576  {
577  ic[c_ic].pwmb.rx_pec_match = 0;
578  ic[c_ic].sctrlb.rx_pec_match = 0;
579 
580  }
581  }
582  return(pec_error);
583 }
584 
585 /* Writes the COMM registers of a LTC6813 daisy chain */
586 void LTC6813_wrcomm(uint8_t total_ic, //The number of ICs being written to
587  cell_asic *ic //A two dimensional array of the comm data that will be written
588  )
589 {
590  LTC681x_wrcomm(total_ic,ic);
591 }
592 
593 /* Reads COMM registers of a LTC6813 daisy chain */
594 int8_t LTC6813_rdcomm(uint8_t total_ic, //Number of ICs in the system
595  cell_asic *ic //A two dimensional array that the function stores the read data.
596  )
597 {
598  int8_t pec_error = 0;
599  LTC681x_rdcomm(total_ic, ic);
600  return(pec_error);
601 }
602 
603 /* Shifts data in COMM register out over LTC6813 SPI/I2C port */
604 void LTC6813_stcomm(uint8_t len) //Length of data to be transmitted
605 {
606  LTC681x_stcomm(len);
607 }
608 
609 /* Mutes the LTC6813 discharge transistors */
611 {
612  uint8_t cmd[2];
613 
614  cmd[0] = 0x00;
615  cmd[1] = 0x28;
616  cmd_68(cmd);
617 }
618 
619 /* Clears the LTC6813 Mute Discharge */
621 {
622  uint8_t cmd[2];
623 
624  cmd[0] = 0x00;
625  cmd[1] = 0x29;
626  cmd_68(cmd);
627 }
628 
629 /* Helper function that increments PEC counters */
630 void LTC6813_check_pec(uint8_t total_ic,//Number of ICs in the system
631  uint8_t reg, // Type of register
632  cell_asic *ic // A two dimensional array that will store the data
633  )
634 {
635  LTC681x_check_pec(total_ic,reg,ic);
636 }
637 
638 /* Helper Function to reset PEC counters */
639 void LTC6813_reset_crc_count(uint8_t total_ic, //Number of ICs in the system
640  cell_asic *ic // A two dimensional array that will store the data
641  )
642 {
643  LTC681x_reset_crc_count(total_ic,ic);
644 }
645 
646 /* Helper function to initialize CFG variables */
647 void LTC6813_init_cfg(uint8_t total_ic, cell_asic *ic)
648 {
649  LTC681x_init_cfg(total_ic,ic);
650 }
651 
652 /* Helper function to set CFGR variable */
653 void LTC6813_set_cfgr(uint8_t nIC, cell_asic *ic, bool refon, bool adcopt, bool gpio[5],bool dcc[12],bool dcto[4], uint16_t uv, uint16_t ov)
654 {
655  LTC681x_set_cfgr_refon(nIC,ic,refon);
656  LTC681x_set_cfgr_adcopt(nIC,ic,adcopt);
657  LTC681x_set_cfgr_gpio(nIC,ic,gpio);
658  LTC681x_set_cfgr_dis(nIC,ic,dcc);
659  LTC681x_set_cfgr_dcto(nIC,ic,dcto);
660  LTC681x_set_cfgr_uv(nIC, ic, uv);
661  LTC681x_set_cfgr_ov(nIC, ic, ov);
662 }
663 
664 /* Helper function to set the REFON bit */
665 void LTC6813_set_cfgr_refon(uint8_t nIC, cell_asic *ic, bool refon)
666 {
667  LTC681x_set_cfgr_refon(nIC,ic,refon);
668 }
669 
670 /* Helper function to set the adcopt bit */
671 void LTC6813_set_cfgr_adcopt(uint8_t nIC, cell_asic *ic, bool adcopt)
672 {
673  LTC681x_set_cfgr_adcopt(nIC,ic,adcopt);
674 }
675 
676 /* Helper function to set GPIO bits */
677 void LTC6813_set_cfgr_gpio(uint8_t nIC, cell_asic *ic,bool gpio[5])
678 {
679  LTC681x_set_cfgr_gpio(nIC,ic,gpio);
680 }
681 
682 /* Helper function to control discharge */
683 void LTC6813_set_cfgr_dis(uint8_t nIC, cell_asic *ic,bool dcc[12])
684 {
685  LTC681x_set_cfgr_dis(nIC,ic,dcc);
686 }
687 
688 /* Helper Function to set uv value in CFG register */
689 void LTC6813_set_cfgr_uv(uint8_t nIC, cell_asic *ic,uint16_t uv)
690 {
691  LTC681x_set_cfgr_uv(nIC, ic, uv);
692 }
693 
694 /* Helper Function to set dcto value in CFG register */
695 void LTC6813_set_cfgr_dcto(uint8_t nIC, cell_asic *ic,bool dcto[4])
696 {
697  LTC681x_set_cfgr_dcto(nIC, ic, dcto);
698 }
699 
700 /* Helper function to set OV value in CFG register */
701 void LTC6813_set_cfgr_ov(uint8_t nIC, cell_asic *ic,uint16_t ov)
702 {
703  LTC681x_set_cfgr_ov( nIC, ic, ov);
704 }
705 
706 /* Helper Function to initialize the CFGRB data structures */
707 void LTC6813_init_cfgb(uint8_t total_ic,cell_asic *ic)
708 {
709  for (uint8_t current_ic = 0; current_ic<total_ic;current_ic++)
710  {
711  for(int j =0; j<6;j++)
712  {
713  ic[current_ic].configb.tx_data[j] = 0;
714  }
715  }
716 }
717 
718 /* Helper Function to set the configuration register B */
719 void LTC6813_set_cfgrb(uint8_t nIC, cell_asic *ic,bool fdrf,bool dtmen,bool ps[2],bool gpiobits[4],bool dccbits[7])
720 {
721  LTC6813_set_cfgrb_fdrf(nIC,ic,fdrf);
722  LTC6813_set_cfgrb_dtmen(nIC,ic,dtmen);
723  LTC6813_set_cfgrb_ps(nIC,ic,ps);
724  LTC6813_set_cfgrb_gpio_b(nIC,ic,gpiobits);
725  LTC6813_set_cfgrb_dcc_b(nIC,ic,dccbits);
726 }
727 
728 /* Helper function to set the FDRF bit */
729 void LTC6813_set_cfgrb_fdrf(uint8_t nIC, cell_asic *ic, bool fdrf)
730 {
731  if(fdrf) ic[nIC].configb.tx_data[1] = ic[nIC].configb.tx_data[1]|0x40;
732  else ic[nIC].configb.tx_data[1] = ic[nIC].configb.tx_data[1]&0xBF;
733 }
734 
735 /* Helper function to set the DTMEN bit */
736 void LTC6813_set_cfgrb_dtmen(uint8_t nIC, cell_asic *ic, bool dtmen)
737 {
738  if(dtmen) ic[nIC].configb.tx_data[1] = ic[nIC].configb.tx_data[1]|0x08;
739  else ic[nIC].configb.tx_data[1] = ic[nIC].configb.tx_data[1]&0xF7;
740 }
741 
742 /* Helper function to set the PATH SELECT bit */
743 void LTC6813_set_cfgrb_ps(uint8_t nIC, cell_asic *ic, bool ps[])
744 {
745  for(int i =0;i<2;i++)
746  {
747  if(ps[i])ic[nIC].configb.tx_data[1] = ic[nIC].configb.tx_data[1]|(0x01<<(i+4));
748  else ic[nIC].configb.tx_data[1] = ic[nIC].configb.tx_data[1]&(~(0x01<<(i+4)));
749  }
750 }
751 
752 /* Helper function to set the gpio bits in configb b register */
753 void LTC6813_set_cfgrb_gpio_b(uint8_t nIC, cell_asic *ic, bool gpiobits[])
754 {
755  for(int i =0;i<4;i++)
756  {
757  if(gpiobits[i])ic[nIC].configb.tx_data[0] = ic[nIC].configb.tx_data[0]|(0x01<<i);
758  else ic[nIC].configb.tx_data[0] = ic[nIC].configb.tx_data[0]&(~(0x01<<i));
759  }
760 }
761 
762 /* Helper function to set the dcc bits in configb b register */
763 void LTC6813_set_cfgrb_dcc_b(uint8_t nIC, cell_asic *ic, bool dccbits[])
764 {
765  for(int i =0;i<7;i++)
766  {
767  if(i==0)
768  {
769  if(dccbits[i])ic[nIC].configb.tx_data[1] = ic[nIC].configb.tx_data[1]|0x04;
770  else ic[nIC].configb.tx_data[1] = ic[nIC].configb.tx_data[1]&0xFB;
771  }
772  if(i>0 and i<5)
773  {
774  if(dccbits[i])ic[nIC].configb.tx_data[0] = ic[nIC].configb.tx_data[0]|(0x01<<(i+3));
775  else ic[nIC].configb.tx_data[0] = ic[nIC].configb.tx_data[0]&(~(0x01<<(i+3)));
776  }
777  if(i>4 and i<7)
778  {
779  if(dccbits[i])ic[nIC].configb.tx_data[1] = ic[nIC].configb.tx_data[1]|(0x01<<(i-5));
780  else ic[nIC].configb.tx_data[1] = ic[nIC].configb.tx_data[1]&(~(0x01<<(i-5)));
781  }
782  }
783 }
int8_t LTC6813_rdaux(uint8_t reg, uint8_t total_ic, cell_asic *ic)
Reads and parses the LTC6813 auxiliary registers.
Definition: LTC6813.cpp:183
void LTC6813_set_cfgrb_ps(uint8_t nIC, cell_asic *ic, bool ps[])
Helper function to turn the Path Select bit HIGH or LOW.
Definition: LTC6813.cpp:743
int16_t LTC6813_run_adc_redundancy_st(uint8_t adc_mode, uint8_t adc_reg, uint8_t total_ic, cell_asic *ic)
Helper function that runs the ADC Digital Redundancy commands and checks output for errors...
Definition: LTC6813.cpp:353
void LTC681x_adaxd(uint8_t MD, uint8_t CHG)
Start an GPIO Redundancy test.
Definition: LTC681x.cpp:1038
void LTC681x_adcvax(uint8_t MD, uint8_t DCP)
Starts cell voltage and GPIO 1&2 conversion.
Definition: LTC681x.cpp:415
uint32_t LTC6813_pollAdc()
This function will block operation until the ADC has finished it&#39;s conversion.
Definition: LTC6813.cpp:216
General BMS Library.
void LTC6813_wrpsb(uint8_t total_ic, cell_asic *ic)
Write the 6813 PWM/Sctrl Register B.
Definition: LTC6813.cpp:507
void LTC6813_set_cfgrb_dcc_b(uint8_t nIC, cell_asic *ic, bool dccbits[])
Helper function to turn the DCC bit HIGH or LOW.
Definition: LTC6813.cpp:763
ic_register configb
Definition: LTC681x.h:173
void LTC681x_stcomm(uint8_t len)
Issues a stcomm command and clocks data out of the COMM register.
Definition: LTC681x.cpp:1978
void LTC681x_adow(uint8_t MD, uint8_t PUP, uint8_t CH, uint8_t DCP)
Start an open wire Conversion.
Definition: LTC681x.cpp:1292
void LTC681x_set_cfgr_gpio(uint8_t nIC, cell_asic *ic, bool gpio[5])
Definition: LTC681x.cpp:2133
void LTC6813_set_cfgrb_dtmen(uint8_t nIC, cell_asic *ic, bool dtmen)
Helper function to turn the DTMEN bit HIGH or LOW.
Definition: LTC6813.cpp:736
void LTC681x_diagn()
Starts the Mux Decoder diagnostic self test Running this command will start the Mux Decoder Diagnosti...
Definition: LTC681x.cpp:967
int8_t LTC681x_rdstat(uint8_t reg, uint8_t total_ic, cell_asic *ic)
Reads and parses the LTC681x stat registers.
Definition: LTC681x.cpp:560
uint8_t tx_data[6]
Stores data to be transmitted.
Definition: LTC681x.h:143
void LTC681x_wrpwm(uint8_t total_ic, uint8_t pwmReg, cell_asic ic[])
Definition: LTC681x.cpp:1696
void LTC6813_adcvsc(uint8_t MD, uint8_t DCP)
Starts cell voltage and Sum of cells conversion.
Definition: LTC6813.cpp:160
ic_register sctrlb
Definition: LTC681x.h:181
void LTC681x_set_cfgr_uv(uint8_t nIC, cell_asic *ic, uint16_t uv)
Helper function to set uv field in CFGRA register.
Definition: LTC681x.cpp:2168
uint8_t rx_data[8]
Stores received data.
Definition: LTC681x.h:144
void LTC681x_axow(uint8_t MD, uint8_t PUP)
Start GPIOs open wire ADC conversion.
Definition: LTC681x.cpp:1310
void LTC681x_clrcell()
Clears the LTC681x Cell voltage registers The command clears the cell voltage registers and initializ...
Definition: LTC681x.cpp:937
void LTC681x_statst(uint8_t MD, uint8_t ST)
Start a Status Register Self Test Conversion.
Definition: LTC681x.cpp:1006
void LTC6813_set_cfgr_gpio(uint8_t nIC, cell_asic *ic, bool gpio[5])
Definition: LTC6813.cpp:677
int8_t LTC681x_rdcfgb(uint8_t total_ic, cell_asic ic[])
Definition: LTC681x.cpp:307
void LTC6813_init_cfgb(uint8_t total_ic, cell_asic *ic)
Helper Function to initialize the CFGR B data structures.
Definition: LTC6813.cpp:707
void LTC681x_adstat(uint8_t MD, uint8_t CHST)
Start a Status ADC Conversion.
Definition: LTC681x.cpp:383
Cell variable structure.
Definition: LTC681x.h:170
void LTC6813_init_reg_limits(uint8_t total_ic, cell_asic *ic)
Helper function to initialize register limits.
Definition: LTC6813.cpp:67
void LTC6813_wrsctrl(uint8_t total_ic, uint8_t sctrl_reg, cell_asic *ic)
Write the LTC6813 Sctrl register.
Definition: LTC6813.cpp:470
void LTC6813_axst(uint8_t MD, uint8_t ST)
Start an Auxiliary Register Self Test Conversion.
Definition: LTC6813.cpp:266
void LTC6813_set_cfgrb_gpio_b(uint8_t nIC, cell_asic *ic, bool gpiobits[])
Helper function to turn the GPIO bit HIGH or LOW.
Definition: LTC6813.cpp:753
void LTC681x_clrsctrl()
Clears the LTC681x SCTRL registers The command clears the SCTRL registers and initializes all values ...
Definition: LTC681x.cpp:1900
void LTC6813_set_discharge(int Cell, uint8_t total_ic, cell_asic *ic)
Helper Function to Set DCC bits in the CFGR Registers.
Definition: LTC6813.cpp:407
register_cfg ic_reg
Definition: LTC681x.h:185
void LTC6813_run_openwire_single(uint8_t total_ic, cell_asic *ic)
Helper function that runs the data sheet algorithm for open wire for single cell detection.
Definition: LTC6813.cpp:383
void LTC681x_wrcfg(uint8_t total_ic, cell_asic ic[])
Definition: LTC681x.cpp:204
void LTC6813_set_cfgr_uv(uint8_t nIC, cell_asic *ic, uint16_t uv)
Helper function to set UV field in CFGRA register.
Definition: LTC6813.cpp:689
void LTC681x_set_cfgr_ov(uint8_t nIC, cell_asic *ic, uint16_t ov)
Helper function to set ov field in CFGRA register.
Definition: LTC681x.cpp:2177
uint8_t num_cv_reg
Number of Cell voltage register.
Definition: LTC681x.h:164
uint8_t num_gpio_reg
Number of Aux register.
Definition: LTC681x.h:165
void LTC681x_wrsctrl(uint8_t total_ic, uint8_t sctrl_reg, cell_asic *ic)
Write the LTC681x Sctrl register.
Definition: LTC681x.cpp:1791
void LTC681x_adax(uint8_t MD, uint8_t CHG)
Start a GPIO and Vref2 Conversion.
Definition: LTC681x.cpp:367
void LTC6813_adcvax(uint8_t MD, uint8_t DCP)
Starts cell voltage and GPIO 1 & 2 conversion.
Definition: LTC6813.cpp:152
void LTC6813_adcv(uint8_t MD, uint8_t DCP, uint8_t CH)
Starts cell voltage conversion.
Definition: LTC6813.cpp:127
void LTC681x_set_cfgr_refon(uint8_t nIC, cell_asic *ic, bool refon)
Helper function to turn the REFON bit HIGH or LOW.
Definition: LTC681x.cpp:2119
void LTC6813_adstat(uint8_t MD, uint8_t CHST)
Start a Status ADC Conversion.
Definition: LTC6813.cpp:144
void LTC6813_set_cfgr(uint8_t nIC, cell_asic *ic, bool refon, bool adcopt, bool gpio[5], bool dcc[12], bool dcto[4], uint16_t uv, uint16_t ov)
Helper function to set appropriate bits in CFGR register based on bit function.
Definition: LTC6813.cpp:653
uint8_t LTC6813_pladc()
Sends the poll ADC command.
Definition: LTC6813.cpp:210
int8_t LTC6813_rdcfg(uint8_t total_ic, cell_asic *ic)
Reads configuration register A of a LTC6813 daisy chain.
Definition: LTC6813.cpp:107
uint8_t LTC681x_rdcv(uint8_t reg, uint8_t total_ic, cell_asic *ic)
Reads and parses the LTC681x cell voltage registers.
Definition: LTC681x.cpp:436
void LTC681x_run_gpio_openwire(uint8_t total_ic, cell_asic ic[])
Definition: LTC681x.cpp:1590
void LTC6813_adax(uint8_t MD, uint8_t CHG)
Start a GPIO and Vref2 Conversion.
Definition: LTC6813.cpp:136
void LTC681x_cvst(uint8_t MD, uint8_t ST)
Starts cell voltage self test conversion.
Definition: LTC681x.cpp:974
void LTC681x_adcvsc(uint8_t MD, uint8_t DCP)
Starts cell voltage and SOC conversion.
Definition: LTC681x.cpp:399
void LTC681x_wrcomm(uint8_t total_ic, cell_asic ic[])
Definition: LTC681x.cpp:1907
void LTC681x_stsctrl()
Start Sctrl data communication This command will start the sctrl pulse communication over the spins...
Definition: LTC681x.cpp:1879
int8_t LTC681x_rdsctrl(uint8_t total_ic, uint8_t sctrl_reg, cell_asic *ic)
Reads sctrl registers of a LTC681x daisy chain.
Definition: LTC681x.cpp:1827
void LTC6813_set_cfgr_adcopt(uint8_t nIC, cell_asic *ic, bool adcopt)
Helper function to turn the ADCOPT bit HIGH or LOW.
Definition: LTC6813.cpp:671
void LTC681x_reset_crc_count(uint8_t total_ic, cell_asic *ic)
Helper Function that resets the PEC error counters.
Definition: LTC681x.cpp:2059
void LTC681x_clear_discharge(uint8_t total_ic, cell_asic *ic)
Helper Function to clear DCC bits in the CFGR Registers.
Definition: LTC681x.cpp:1682
void LTC6813_clrstat()
Clears the LTC6813 Stat registers.
Definition: LTC6813.cpp:246
uint8_t LTC6813_rdcv(uint8_t reg, uint8_t total_ic, cell_asic *ic)
Reads and parses the LTC6813 cell voltage registers.
Definition: LTC6813.cpp:168
void LTC6813_statst(uint8_t MD, uint8_t ST)
Start a Status Register Self Test Conversion.
Definition: LTC6813.cpp:274
uint8_t LTC6813_rdpsb(uint8_t total_ic, cell_asic *ic)
Reading pwm/s control register B.
Definition: LTC6813.cpp:533
void LTC6813_cvst(uint8_t MD, uint8_t ST)
Starts cell voltage self test conversion.
Definition: LTC6813.cpp:258
int8_t LTC681x_rdaux(uint8_t reg, uint8_t total_ic, cell_asic *ic)
Reads and parses the LTC681x auxiliary registers.
Definition: LTC681x.cpp:498
void LTC6813_stcomm(uint8_t len)
Issues a stcomm command and clocks data out of the COMM register.
Definition: LTC6813.cpp:604
void LTC6813_set_cfgr_refon(uint8_t nIC, cell_asic *ic, bool refon)
Helper function to turn the REFON bit HIGH or LOW.
Definition: LTC6813.cpp:665
uint8_t stat_channels
Number of Stat channels.
Definition: LTC681x.h:162
void LTC681x_adstatd(uint8_t MD, uint8_t CHST)
Start a Status register redundancy test Conversion.
Definition: LTC681x.cpp:1054
void LTC6813_adaxd(uint8_t MD, uint8_t CHG)
Start an GPIO Redundancy test.
Definition: LTC6813.cpp:290
void LTC681x_clrstat()
Clears the LTC681x Stat registers The command clears the Stat registers and initializes all values to...
Definition: LTC681x.cpp:960
uint32_t LTC681x_pollAdc()
This function will block operation until the ADC has finished it&#39;s conversion.
Definition: LTC681x.cpp:899
void LTC6813_mute()
Mutes the LTC6813 discharge transistors.
Definition: LTC6813.cpp:610
void LTC6813_wrcfg(uint8_t total_ic, cell_asic *ic)
Write the LTC6813 configuration register A.
Definition: LTC6813.cpp:87
void wakeup_idle()
Definition: LTC68041.cpp:957
void LTC681x_axst(uint8_t MD, uint8_t ST)
Start an Auxiliary Register Self Test Conversion.
Definition: LTC681x.cpp:990
void LTC681x_check_pec(uint8_t total_ic, uint8_t reg, cell_asic *ic)
Helper Function that counts overall PEC errors and register/IC PEC errors.
Definition: LTC681x.cpp:1999
void LTC6813_axow(uint8_t MD, uint8_t PUP)
Start GPIOs open wire ADC conversion.
Definition: LTC6813.cpp:375
uint8_t LTC681x_pladc()
Sends the poll ADC command.
Definition: LTC681x.cpp:878
int8_t read_68(uint8_t total_ic, uint8_t tx_cmd[2], uint8_t *rx_data)
Issues a command onto the daisy chain and reads back 6*total_ic data in the rx_data array...
Definition: LTC681x.cpp:140
uint8_t cell_channels
Number of Cell channels.
Definition: LTC681x.h:161
void LTC6813_set_cfgr_ov(uint8_t nIC, cell_asic *ic, uint16_t ov)
Helper function to set OV field in CFGRA register.
Definition: LTC6813.cpp:701
uint8_t num_stat_reg
Number of Status register.
Definition: LTC681x.h:166
static int error
uint16_t LTC6813_run_adc_overlap(uint8_t total_ic, cell_asic *ic)
Helper Function that runs the ADC Overlap test.
Definition: LTC6813.cpp:319
void LTC6813_adstatd(uint8_t MD, uint8_t CHST)
Start a Status register redundancy test Conversion.
Definition: LTC6813.cpp:298
void LTC6813_set_cfgr_dis(uint8_t nIC, cell_asic *ic, bool dcc[12])
Definition: LTC6813.cpp:683
void LTC681x_set_cfgr_dcto(uint8_t nIC, cell_asic *ic, bool dcto[4])
Definition: LTC681x.cpp:2158
void cmd_68(uint8_t tx_cmd[2])
Sends a command to the BMS IC.
Definition: LTC681x.cpp:77
uint16_t pec15_calc(uint8_t len, uint8_t *data)
Definition: LTC68041.cpp:985
void LTC6813_clraux()
Clears the LTC6813 Auxiliary registers.
Definition: LTC6813.cpp:236
void LTC6813_reset_crc_count(uint8_t total_ic, cell_asic *ic)
Helper Function that resets the PEC error counters.
Definition: LTC6813.cpp:639
int8_t LTC681x_rdpwm(uint8_t total_ic, uint8_t pwmReg, cell_asic ic[])
Definition: LTC681x.cpp:1738
uint8_t rx_pec_match
If a PEC error was detected during most recent read cmd.
Definition: LTC681x.h:145
void LTC6813_clrsctrl()
Clears the LTC6813 Sctrl registers.
Definition: LTC6813.cpp:501
int8_t LTC6813_rdcfgb(uint8_t total_ic, cell_asic *ic)
Reads configuration register B of a LTC6813 daisy chain.
Definition: LTC6813.cpp:117
ic_register config
Definition: LTC681x.h:172
void LTC6813_clrcell()
Clears the LTC6813 cell voltage registers.
Definition: LTC6813.cpp:226
void LTC6813_set_cfgrb(uint8_t nIC, cell_asic *ic, bool fdrf, bool dtmen, bool ps[2], bool gpiobits[4], bool dccbits[7])
Helper function to set appropriate bits in CFGR register based on bit function.
Definition: LTC6813.cpp:719
int8_t LTC6813_rdstat(uint8_t reg, uint8_t total_ic, cell_asic *ic)
Reads and parses the LTC6813 stat registers.
Definition: LTC6813.cpp:199
int8_t LTC681x_rdcomm(uint8_t total_ic, cell_asic ic[])
Definition: LTC681x.cpp:1936
void LTC6813_wrcomm(uint8_t total_ic, cell_asic *ic)
Write the LTC6813 COMM register.
Definition: LTC6813.cpp:586
int8_t LTC6813_rdsctrl(uint8_t total_ic, uint8_t sctrl_reg, cell_asic *ic)
Reads sctrl registers of a LTC6813 daisy chain.
Definition: LTC6813.cpp:479
#define MD_7KHZ_3KHZ
Definition: LTC681x.h:63
void LTC6813_set_cfgrb_fdrf(uint8_t nIC, cell_asic *ic, bool fdrf)
Helper function to turn the FDRF bit HIGH or LOW.
Definition: LTC6813.cpp:729
void LTC6813_wrcfgb(uint8_t total_ic, cell_asic *ic)
Write the LTC6813 configuration register B.
Definition: LTC6813.cpp:99
uint16_t c_codes[18]
Cell Voltage Codes.
Definition: LTC681x.h:119
void LTC6813_stsctrl()
Start Sctrl data communication This command will start the sctrl pulse communication over the spins...
Definition: LTC6813.cpp:491
void LTC681x_init_cfg(uint8_t total_ic, cell_asic *ic)
Helper Function to initialize the CFGR data structures.
Definition: LTC681x.cpp:2084
void LTC6813_init_cfg(uint8_t total_ic, cell_asic *ic)
Helper Function to initialize the CFGR data structures.
Definition: LTC6813.cpp:647
LTC6813: Multicell Battery Monitors.
int8_t LTC681x_rdcfg(uint8_t total_ic, cell_asic ic[])
Definition: LTC681x.cpp:264
void LTC6813_adow(uint8_t MD, uint8_t PUP, uint8_t CH, uint8_t DCP)
Start an open wire Conversion.
Definition: LTC6813.cpp:365
void LTC6813_adol(uint8_t MD, uint8_t DCP)
Starts cell voltage overlap conversion.
Definition: LTC6813.cpp:282
#define DCP_DISABLED
Definition: LTC68041.h:183
void LTC6813_unmute()
Clears the LTC6813 Mute Discharge.
Definition: LTC6813.cpp:620
void LTC681x_clraux()
Clears the LTC681x Auxiliary registers The command clears the Auxiliary registers and initializes all...
Definition: LTC681x.cpp:948
void LTC681x_adcv(uint8_t MD, uint8_t DCP, uint8_t CH)
Starts cell voltage conversion Starts ADC conversions of the LTC681x Cpin inputs. ...
Definition: LTC681x.cpp:350
int8_t LTC6813_rdpwm(uint8_t total_ic, uint8_t pwmReg, cell_asic *ic)
Reads pwm registers of a LTC6813 daisy chain.
Definition: LTC6813.cpp:459
void LTC6813_check_pec(uint8_t total_ic, uint8_t reg, cell_asic *ic)
Helper Function that counts overall PEC errors and register/IC PEC errors.
Definition: LTC6813.cpp:630
int16_t LTC681x_run_adc_redundancy_st(uint8_t adc_mode, uint8_t adc_reg, uint8_t total_ic, cell_asic *ic)
Helper function that runs the ADC Digital Redundancy commands and checks output for errors...
Definition: LTC681x.cpp:1188
void LTC681x_set_cfgr_adcopt(uint8_t nIC, cell_asic *ic, bool adcopt)
Helper function to turn the ADCOPT bit HIGH or LOW.
Definition: LTC681x.cpp:2126
static int i
Definition: DC2430A.ino:184
void LTC681x_run_openwire_multi(uint8_t total_ic, cell_asic ic[])
Definition: LTC681x.cpp:1416
int16_t LTC6813_run_cell_adc_st(uint8_t adc_reg, uint8_t total_ic, cell_asic *ic, uint8_t md, bool adcopt)
Helper function that runs the ADC Self Tests.
Definition: LTC6813.cpp:306
cv cells
Definition: LTC681x.h:174
void LTC681x_run_openwire_single(uint8_t total_ic, cell_asic ic[])
Definition: LTC681x.cpp:1326
void LTC681x_set_cfgr_dis(uint8_t nIC, cell_asic *ic, bool dcc[12])
Definition: LTC681x.cpp:2143
uint8_t aux_channels
Number of Aux channels.
Definition: LTC681x.h:163
void LTC681x_adol(uint8_t MD, uint8_t DCP)
Starts cell voltage overlap conversion.
Definition: LTC681x.cpp:1022
int16_t LTC681x_run_cell_adc_st(uint8_t adc_reg, uint8_t total_ic, cell_asic *ic, uint8_t md, bool adcopt)
Helper function that runs the ADC Self Tests.
Definition: LTC681x.cpp:1070
int8_t LTC6813_rdcomm(uint8_t total_ic, cell_asic *ic)
Reads comm registers of a LTC6813 daisy chain.
Definition: LTC6813.cpp:594
void LTC6813_set_cfgr_dcto(uint8_t nIC, cell_asic *ic, bool dcto[4])
Helper function to set DCTO field in CFGRA register.
Definition: LTC6813.cpp:695
ic_register pwmb
Definition: LTC681x.h:179
bool isospi_reverse
Definition: LTC681x.h:183
void LTC6813_clear_discharge(uint8_t total_ic, cell_asic *ic)
Helper Function to clear DCC bits in the CFGR Registers.
Definition: LTC6813.cpp:442
void LTC6813_run_openwire_multi(uint8_t total_ic, cell_asic *ic)
Helper function that runs open wire for multiple cell and two consecutive cells detection.
Definition: LTC6813.cpp:391
void LTC6813_wrpwm(uint8_t total_ic, uint8_t pwmReg, cell_asic *ic)
Write the LTC6813 PWM register.
Definition: LTC6813.cpp:450
void LTC6813_diagn()
Starts the Mux Decoder diagnostic self test Running this command will start the Mux Decoder Diagnosti...
Definition: LTC6813.cpp:252
void LTC681x_wrcfgb(uint8_t total_ic, cell_asic ic[])
Definition: LTC681x.cpp:234
void write_68(uint8_t total_ic, uint8_t tx_cmd[2], uint8_t data[])
Writes an array of data to the daisy chain.
Definition: LTC681x.cpp:98
void LTC6813_run_gpio_openwire(uint8_t total_ic, cell_asic *ic)
Runs open wire for GPIOs.
Definition: LTC6813.cpp:399