Linduino  1.3.0
Linear Technology Arduino-Compatible Demonstration Board
LTC681x.h
Go to the documentation of this file.
1 /*! General BMS Library
2 *******************************************************************************
3 * @file LTC681x.h
4 * @author BMS (bms.support@analog.com)
5 
6 ********************************************************************************
7 * Copyright 2019(c) Analog Devices, Inc.
8 *
9 * All rights reserved.
10 *
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions are met:
13 * - Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer.
15 * - Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in
17 * the documentation and/or other materials provided with the
18 * distribution.
19 * - Neither the name of Analog Devices, Inc. nor the names of its
20 * contributors may be used to endorse or promote products derived
21 * from this software without specific prior written permission.
22 * - The use of this software may or may not infringe the patent rights
23 * of one or more patent holders. This license does not release you
24 * from the requirement that you obtain separate licenses from these
25 * patent holders to use this software.
26 * - Use of the software either in source or binary form, must be run
27 * on or directly connected to an Analog Devices Inc. component.
28 *
29 * THIS SOFTWARE IS PROVIDED BY ANALOG DEVICES "AS IS" AND ANY EXPRESS OR
30 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, NON-INFRINGEMENT,
31 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
32 * IN NO EVENT SHALL ANALOG DEVICES BE LIABLE FOR ANY DIRECT, INDIRECT,
33 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
34 * LIMITED TO, INTELLECTUAL PROPERTY RIGHTS, PROCUREMENT OF SUBSTITUTE GOODS OR
35 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
36 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
37 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
38 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
39 *******************************************************************************/
40 
41 /*! @file
42  Library for LTC681x Multi-cell Battery Monitor
43 */
44 
45 #ifndef LTC681x_h
46 #define LTC681x_h
47 #include <stdint.h>
48 #include <Arduino.h>
49 #define LINDUINO
50 
51 #ifdef MBED
52 #include "mbed.h"//remove when using with LINDUINO
53 #endif
54 
55 #ifdef LINDUINO
56 #include <Arduino.h>
57 #endif
58 
59 #define IC_LTC6813
60 
61 #define MD_422HZ_1KHZ 0
62 #define MD_27KHZ_14KHZ 1
63 #define MD_7KHZ_3KHZ 2
64 #define MD_26HZ_2KHZ 3
65 
66 #define ADC_OPT_ENABLED 1
67 #define ADC_OPT_DISABLED 0
68 
69 #define CELL_CH_ALL 0
70 #define CELL_CH_1and7 1
71 #define CELL_CH_2and8 2
72 #define CELL_CH_3and9 3
73 #define CELL_CH_4and10 4
74 #define CELL_CH_5and11 5
75 #define CELL_CH_6and12 6
76 
77 #define SELFTEST_1 1
78 #define SELFTEST_2 2
79 
80 #define AUX_CH_ALL 0
81 #define AUX_CH_GPIO1 1
82 #define AUX_CH_GPIO2 2
83 #define AUX_CH_GPIO3 3
84 #define AUX_CH_GPIO4 4
85 #define AUX_CH_GPIO5 5
86 #define AUX_CH_VREF2 6
87 
88 #define STAT_CH_ALL 0
89 #define STAT_CH_SOC 1
90 #define STAT_CH_ITEMP 2
91 #define STAT_CH_VREGA 3
92 #define STAT_CH_VREGD 4
93 
94 #define REG_ALL 0
95 #define REG_1 1
96 #define REG_2 2
97 #define REG_3 3
98 #define REG_4 4
99 #define REG_5 5
100 #define REG_6 6
101 
102 #define DCP_DISABLED 0
103 #define DCP_ENABLED 1
104 
105 #define PULL_UP_CURRENT 1
106 #define PULL_DOWN_CURRENT 0
107 
108 #define NUM_RX_BYT 8
109 #define CELL 1
110 #define AUX 2
111 #define STAT 3
112 #define CFGR 0
113 #define CFGRB 4
114 #define CS_PIN 10
115 
116 /*! Cell Voltage data structure. */
117 typedef struct
118 {
119  uint16_t c_codes[18]; //!< Cell Voltage Codes
120  uint8_t pec_match[6]; //!< If a PEC error was detected during most recent read cmd
121 } cv;
122 
123 /*! AUX Reg Voltage Data structure */
124 typedef struct
125 {
126  uint16_t a_codes[9]; //!< Aux Voltage Codes
127  uint8_t pec_match[4]; //!< If a PEC error was detected during most recent read cmd
128 } ax;
129 
130 /*! Status Reg data structure. */
131 typedef struct
132 {
133  uint16_t stat_codes[4]; //!< Status codes.
134  uint8_t flags[3]; //!< Byte array that contains the uv/ov flag data
135  uint8_t mux_fail[1]; //!< Mux self test status flag
136  uint8_t thsd[1]; //!< Thermal shutdown status
137  uint8_t pec_match[2]; //!< If a PEC error was detected during most recent read cmd
138 } st;
139 
140 /*! IC register structure. */
141 typedef struct
142 {
143  uint8_t tx_data[6]; //!< Stores data to be transmitted
144  uint8_t rx_data[8]; //!< Stores received data
145  uint8_t rx_pec_match; //!< If a PEC error was detected during most recent read cmd
146 } ic_register;
147 
148 /*! PEC error counter structure. */
149 typedef struct
150 {
151  uint16_t pec_count; //!< Overall PEC error count
152  uint16_t cfgr_pec; //!< Configuration register data PEC error count
153  uint16_t cell_pec[6]; //!< Cell voltage register data PEC error count
154  uint16_t aux_pec[4]; //!< Aux register data PEC error count
155  uint16_t stat_pec[2]; //!< Status register data PEC error count
156 } pec_counter;
157 
158 /*! Register configuration structure */
159 typedef struct
160 {
161  uint8_t cell_channels; //!< Number of Cell channels
162  uint8_t stat_channels; //!< Number of Stat channels
163  uint8_t aux_channels; //!< Number of Aux channels
164  uint8_t num_cv_reg; //!< Number of Cell voltage register
165  uint8_t num_gpio_reg; //!< Number of Aux register
166  uint8_t num_stat_reg; //!< Number of Status register
167 } register_cfg;
168 
169 /*! Cell variable structure */
170 typedef struct
171 {
182  uint8_t sid[6];
187 } cell_asic;
188 
189 /*!
190  Wake isoSPI up from IDlE state and enters the READY state
191  @return void
192  */
193 void wakeup_idle(uint8_t total_ic);//!< Number of ICs in the daisy chain
194 
195 /*!
196  Wake the LTC681x from the sleep state
197  @return void
198  */
199 void wakeup_sleep(uint8_t total_ic); //!< Number of ICs in the daisy chain
200 
201 /*!
202  Sends a command to the BMS IC. This code will calculate the PEC code for the transmitted command
203  @return void
204  */
205 void cmd_68(uint8_t tx_cmd[2]); //!< 2 byte array containing the BMS command to be sent
206 
207 /*!
208  Writes an array of data to the daisy chain
209  @return void
210  */
211 void write_68(uint8_t total_ic , //!< Number of ICs in the daisy chain
212  uint8_t tx_cmd[2], //!< 2 byte array containing the BMS command to be sent
213  uint8_t data[] //!< Array containing the data to be written to the BMS ICs
214  );
215 
216 /*!
217  Issues a command onto the daisy chain and reads back 6*total_ic data in the rx_data array
218  @return int8_t, PEC Status.
219  0: Data read back has matching PEC
220  -1: Data read back has incorrect PEC
221  */
222 int8_t read_68( uint8_t total_ic, //!< Number of ICs in the daisy chain
223  uint8_t tx_cmd[2], //!< 2 byte array containing the BMS command to be sent
224  uint8_t *rx_data); //!< Array that the read back data will be stored in.
225 
226 /*!
227  Calculates and returns the CRC15
228  @returns The calculated pec15 as an unsigned int
229  */
230 uint16_t pec15_calc(uint8_t len, //!< The length of the data array being passed to the function
231  uint8_t *data //!< The array of data that the PEC will be generated from
232  );
233 
234 /*!
235  Write the LTC681x CFGRA register
236  This command will write the configuration registers of the LTC681xs connected in a daisy chain stack.
237  The configuration is written in descending order so the last device's configuration is written first.
238  @return void
239  */
240 void LTC681x_wrcfg(uint8_t total_ic, //!< The number of ICs being written to
241  cell_asic *ic //!< A two dimensional array of the configuration data that will be written
242  );
243 
244 /*!
245  Write the LTC681x CFGRB register
246  This command will write the configuration registers of the LTC681xs connected in a daisy chain stack.
247  The configuration is written in descending order so the last device's configuration is written first.
248  @return void
249  */
250 void LTC681x_wrcfgb(uint8_t total_ic, //!< The number of ICs being written to
251  cell_asic *ic //!< A two dimensional array of the configuration data that will be written
252  );
253 
254 /*!
255  Reads the LTC681x CFGRA register
256  @return int8_t, PEC Status.
257  0: Data read back has matching PEC
258  -1: Data read back has incorrect PEC
259  */
260 int8_t LTC681x_rdcfg(uint8_t total_ic, //!< Number of ICs in the system
261  cell_asic *ic //!< A two dimensional array that the function stores the read configuration data.
262  );
263 
264 /*!
265  Reads the LTC681x CFGRB register
266  @return int8_t, PEC Status.
267  0: Data read back has matching PEC
268  -1: Data read back has incorrect PEC
269  */
270 int8_t LTC681x_rdcfgb(uint8_t total_ic, //!< Number of ICs in the system
271  cell_asic *ic //!< A two dimensional array that the function stores the read configuration data.
272  );
273 
274 /*!
275  Starts cell voltage conversion
276  Starts ADC conversions of the LTC681x Cpin inputs.
277  The type of ADC conversion executed can be changed by setting the following parameters:
278  @return void
279  */
280 void LTC681x_adcv(uint8_t MD, //!< ADC conversion Mode
281  uint8_t DCP, //!< Controls if Discharge is permitted during conversion
282  uint8_t CH //!< Sets which Cell channels are converted
283  );
284 
285 /*!
286  Start a GPIO and Vref2 Conversion
287  @return void
288  */
289 void LTC681x_adax( uint8_t MD, //!< ADC Conversion Mode
290  uint8_t CHG //!< Sets which GPIO channels are converted
291  );
292 
293 /*!
294  Start a Status ADC Conversion
295  @return void
296  */
297 void LTC681x_adstat(uint8_t MD, //!< ADC Conversion Mode
298  uint8_t CHST //!< Sets which Stat channels are converted
299  );
300 
301 /*!
302  Starts cell voltage and GPIO 1&2 conversion
303  @return void
304  */
305 void LTC681x_adcvax( uint8_t MD, //!< ADC Conversion Mode
306  uint8_t DCP //!< Controls if Discharge is permitted during conversion
307  );
308 
309 /*!
310  Starts cell voltage and SOC conversion
311  @return void
312  */
313 void LTC681x_adcvsc(uint8_t MD, //!< ADC Conversion Mode
314  uint8_t DCP //!< Controls if Discharge is permitted during conversion
315  );
316 
317 /*!
318  Reads and parses the LTC681x cell voltage registers.
319  The function is used to read the cell codes of the LTC681x.
320  This function will send the requested read commands parse the data and store the cell voltages in the cell_asic structure.
321  @return uint8_t, PEC Status.
322  0: No PEC error detected
323  -1: PEC error detected, retry read
324  */
325 uint8_t LTC681x_rdcv(uint8_t reg, //!< Controls which cell voltage register is read back.
326  uint8_t total_ic, //!< The number of ICs in the system
327  cell_asic *ic //!< Array of the parsed cell codes
328  );
329 
330 /*!
331  Reads and parses the LTC681x auxiliary registers.
332  The function is used to read the parsed GPIO codes of the LTC681x.
333  This function will send the requested read commands parse the data and store the gpio voltages in the cell_asic structure.
334  @return int8_t, PEC Status
335  0: No PEC error detected
336  -1: PEC error detected, retry read
337  */
338 int8_t LTC681x_rdaux(uint8_t reg, //!< Determines which GPIO voltage register is read back.
339  uint8_t total_ic,//!< the number of ICs in the system
340  cell_asic *ic//!< Array of the parsed aux codes
341  );
342 
343 /*!
344  Reads and parses the LTC681x stat registers.
345  The function is used to read the parsed status codes of the LTC681x.
346  This function will send the requested read commands parse the data and store the status voltages in the cell_asic structure
347  @return int8_t, PEC Status
348  0: No PEC error detected
349  -1: PEC error detected, retry read
350  */
351 int8_t LTC681x_rdstat(uint8_t reg, //!< Determines which Stat register is read back.
352  uint8_t total_ic,//!< The number of ICs in the system
353  cell_asic *ic//!< Array of the parsed stat codes
354  );
355 
356 /*!
357  Reads the raw cell voltage register data
358  @return void
359  */
360 void LTC681x_rdcv_reg(uint8_t reg, //!< Determines which cell voltage register is read back
361  uint8_t total_ic, //!< The number of ICs in the
362  uint8_t *data //!< An array of the unparsed cell codes
363  );
364 
365 /*!
366  Read the raw data from the LTC681x auxiliary register
367  The function reads a single GPIO voltage register and stores the read data in the *data point as a byte array.
368  This function is rarely used outside of the LTC681x_rdaux() command.
369  @return void
370  */
371 void LTC681x_rdaux_reg( uint8_t reg, //!< Determines which GPIO voltage register is read back
372  uint8_t total_ic, //!< The number of ICs in the system
373  uint8_t *data //!< Array of the unparsed auxiliary codes
374  );
375 
376 /*!
377  Read the raw data from the LTC681x stat register
378  The function reads a single Status register and stores the read data in the *data point as a byte array.
379  This function is rarely used outside of the LTC681x_rdstat() command.
380  @return void
381  */
382 void LTC681x_rdstat_reg(uint8_t reg, //!< Determines which stat register is read back
383  uint8_t total_ic, //!< The number of ICs in the system
384  uint8_t *data //!< Array of the unparsed stat codes
385  );
386 
387 /*!
388  Helper function that parses voltage measurement registers
389  @return int8_t, pec_error PEC Status.
390  0: Data read back has matching PEC
391  -1: Data read back has incorrect PEC
392  */
393 int8_t parse_cells(uint8_t current_ic, //!< Current IC
394  uint8_t cell_reg, //!< Type of register
395  uint8_t cell_data[], //!< Unparsed data
396  uint16_t *cell_codes, //!< Parsed data
397  uint8_t *ic_pec //!< PEC error
398  );
399 
400 /*!
401  Sends the poll ADC command
402  @returns uint8_t adc_state 1 byte read back after a pladc command. If the byte is not 0xFF ADC conversion has completed
403  */
404 uint8_t LTC681x_pladc();
405 
406 /*!
407  This function will block operation until the ADC has finished it's conversion
408  @returns uint32_t counter The approximate time it took for the ADC function to complete.
409  */
410 uint32_t LTC681x_pollAdc();
411 
412 /*!
413  Clears the LTC681x Cell voltage registers
414  The command clears the cell voltage registers and initializes all values to 1.
415  The register will read back hexadecimal 0xFF after the command is sent.
416  @return void
417  */
418 void LTC681x_clrcell();
419 
420 /*!
421  Clears the LTC681x Auxiliary registers
422  The command clears the Auxiliary registers and initializes all values to 1.
423  The register will read back hexadecimal 0xFF after the command is sent.
424  @return void
425  */
426 void LTC681x_clraux();
427 
428 /*!
429  Clears the LTC681x Stat registers
430  The command clears the Stat registers and initializes all values to 1.
431  The register will read back hexadecimal 0xFF after the command is sent.
432  @return void
433  */
434 void LTC681x_clrstat();
435 
436 /*!
437  Starts the Mux Decoder diagnostic self test
438  Running this command will start the Mux Decoder Diagnostic Self Test
439  This test takes roughly 1ms to complete. The MUXFAIL bit will be updated,
440  the bit will be set to 1 for a failure and 0 if the test has been passed.
441  @return void
442  */
443 void LTC681x_diagn();
444 
445 /*!
446  Starts cell voltage self test conversion
447  @return void
448  */
449 void LTC681x_cvst(uint8_t MD, //!< ADC Conversion Mode
450  uint8_t ST //!< Sets if self test 1 or 2 is run
451  );
452 
453 /*!
454  Start an Auxiliary Register Self Test Conversion
455  @return void
456  */
457 void LTC681x_axst(uint8_t MD, //!< ADC Conversion Mode
458  uint8_t ST //!< Sets if self test 1 or 2 is run
459  );
460 
461 /*!
462  Start a Status Register Self Test Conversion
463  @return void
464  */
465 void LTC681x_statst( uint8_t MD, //!< ADC Conversion Mode
466  uint8_t ST //!< Sets if self test 1 or 2 is run
467  );
468 
469 /*!
470  Starts cell voltage overlap conversion
471  @return void
472  */
473 void LTC681x_adol(uint8_t MD, //!< ADC Conversion Mode
474  uint8_t DCP //!< Discharge permitted during conversion
475  );
476 
477 /*!
478  Start an GPIO Redundancy test
479  @return void
480  */
481 void LTC681x_adaxd(uint8_t MD, //!< ADC Conversion Mode
482  uint8_t CHG //!< Sets which GPIO channels are converted
483  );
484 
485 /*!
486  Start a Status register redundancy test Conversion
487  @return void
488  */
489 void LTC681x_adstatd(uint8_t MD, //!< ADC Mode
490  uint8_t CHST //!< Sets which Status channels are converted
491  );
492 
493 /*!
494  Helper function that runs the ADC Self Tests
495  @return int16_t, error Number of errors detected.
496  */
497 int16_t LTC681x_run_cell_adc_st(uint8_t adc_reg, //!< Type of register
498  uint8_t total_ic, //!< Number of ICs in the daisy chain
499  cell_asic *ic, //!< A two dimensional array that will store the data
500  uint8_t md, //!< ADC Mode
501  bool adcopt //!< ADCOPT bit in the configuration register
502  );
503 
504 /*!
505  Self Test Helper Function
506  @return uint16_t test_pattern returns the register data pattern for a given ADC MD and Self test
507  */
508 uint16_t LTC681x_st_lookup( uint8_t MD, //!< ADC Mode
509  uint8_t ST, //!< Self Test
510  bool adcopt //!< ADCOPT bit in the configuration register
511  );
512 
513 /*!
514  Helper Function that runs the ADC Overlap test
515  @return uint16_t, error
516  0: Pass
517  -1: False, Error detected
518  */
519 uint16_t LTC681x_run_adc_overlap(uint8_t total_ic, //!< Number of ICs in the daisy chain
520  cell_asic *ic //!< A two dimensional array that will store the data
521  );
522 
523 /*!
524  Helper function that runs the ADC Digital Redundancy commands and checks output for errors
525  @return int16_t, error Number of errors detected.
526  */
527 int16_t LTC681x_run_adc_redundancy_st(uint8_t adc_mode, //!< ADC Mode
528  uint8_t adc_reg, //!< Type of register
529  uint8_t total_ic, //!< Number of ICs in the daisy chain
530  cell_asic *ic //!< A two dimensional array that will store the data
531  );
532 
533 /*!
534  Start an open wire Conversion
535  @return void
536  */
537 void LTC681x_adow(uint8_t MD, //!< ADC Conversion Mode
538  uint8_t PUP, //!< Pull up/Pull down current
539  uint8_t CH, //!< Channels
540  uint8_t DCP//!< Discharge Permit
541  );
542 
543 /*!
544  Start GPIOs open wire ADC conversion
545  @return void
546  */
547 void LTC681x_axow(uint8_t MD, //!< ADC Mode
548  uint8_t PUP //!<Pull up/Pull down current
549  );
550 
551 /*!
552  Helper function that runs the data sheet algorithm for open wire for single cell detection
553  @return void
554  */
555 void LTC681x_run_openwire_single(uint8_t total_ic, //!< Number of ICs in the daisy chain
556  cell_asic *ic //!< A two dimensional array that will store the data
557  );
558 
559 /*!
560  Helper function that runs open wire for multiple cell and two consecutive cells detection
561  @return void
562  */
563  void LTC681x_run_openwire_multi(uint8_t total_ic, //!< Number of ICs in the daisy chain
564  cell_asic *ic //!< A two dimensional array that will store the data
565  );
566 
567 /*!
568  Runs open wire for GPIOs
569  @return void
570  */
571 void LTC681x_run_gpio_openwire(uint8_t total_ic, //!< Number of ICs in the daisy chain
572  cell_asic *ic //!< A two dimensional array that will store the data
573  );
574 
575 /*!
576  Helper Function to clear DCC bits in the CFGR Registers
577  @return void
578  */
579 void LTC681x_clear_discharge(uint8_t total_ic,//!< Number of ICs in the daisy chain
580  cell_asic *ic //!< A two dimensional array that will store the data
581  );
582 
583 /*!
584  Write the LTC681x PWM register
585  This command will write the pwm registers of the LTC681x connected in a daisy chain stack.
586  The pwm is written in descending order so the last device's pwm is written first.
587  @return void
588  */
589 void LTC681x_wrpwm(uint8_t total_ic, //!< The number of ICs being written to
590  uint8_t pwmReg, //!< The PWM Register to be written
591  cell_asic *ic //!< A two dimensional array that will store the data to be written
592  );
593 
594 /*!
595  Reads pwm registers of a LTC681x daisy chain
596  @return int8_t, pec_error PEC Status.
597  0: Data read back has matching PEC
598  -1: Data read back has incorrect PEC
599  */
600 int8_t LTC681x_rdpwm(uint8_t total_ic, //!< Number of ICs in the system
601  uint8_t pwmReg, //!< The PWM Register to be written A or B
602  cell_asic *ic //!< A two dimensional array that will store the read data
603  );
604 
605 /*!
606  Write the LTC681x Sctrl register
607  @return void
608  */
609 void LTC681x_wrsctrl(uint8_t total_ic, //!< Number of ICs in the daisy chain
610  uint8_t sctrl_reg, //!< The Sctrl Register to be written A or B
611  cell_asic *ic //!< A two dimensional array that will store the data to be written
612  );
613 
614 /*!
615  Reads sctrl registers of a LTC681x daisy chain
616  @return int8_t, pec_error PEC Status.
617  0: Data read back has matching PEC
618  -1: Data read back has incorrect PEC
619  */
620 int8_t LTC681x_rdsctrl(uint8_t total_ic, //!< Number of ICs in the daisy chain
621  uint8_t sctrl_reg, //!< The Sctrl Register to be written A or B
622  cell_asic *ic //!< A two dimensional array that the function stores the read data
623  );
624 
625 /*!
626  Start Sctrl data communication
627  This command will start the sctrl pulse communication over the spins
628  @return void
629  */
630 void LTC681x_stsctrl();
631 
632 /*!
633  Clears the LTC681x SCTRL registers
634  The command clears the SCTRL registers and initializes all values to 0.
635  The register will read back hexadecimal 0x00 after the command is sent.
636  @return void
637  */
638 void LTC681x_clrsctrl();
639 
640 /*!
641  Write the LTC681x COMM register
642  This command will write the comm registers of the LTC681x connected in a daisy chain stack.
643  The comm is written in descending order so the last device's configuration is written first.
644  @return void
645  */
646 void LTC681x_wrcomm(uint8_t total_ic, //!< The number of ICs being written to
647  cell_asic *ic //!< A two dimensional array that will store the data to be written
648  );
649 
650 /*!
651  Reads comm registers of a LTC681x daisy chain
652  @return int8_t, pec_error PEC Status.
653  0: Data read back has matching PEC
654  -1: Data read back has incorrect PEC
655  */
656 int8_t LTC681x_rdcomm(uint8_t total_ic, //!< Number of ICs in the system
657  cell_asic *ic //!< A two dimensional array that the function stores the read data
658  );
659 
660 /*!
661  Issues a stcomm command and clocks data out of the COMM register
662  @return void
663  */
664 void LTC681x_stcomm(uint8_t len //!< Length of data to be transmitted
665  );
666 
667 /*!
668  Helper Function that counts overall PEC errors and register/IC PEC errors
669  @return void
670  */
671 void LTC681x_check_pec(uint8_t total_ic, //!< Number of ICs in the daisy chain
672  uint8_t reg, //!< Type of register
673  cell_asic *ic //!< A two dimensional array that will store the data
674  );
675 
676 /*!
677  Helper Function that resets the PEC error counters
678  @return void
679  */
680 void LTC681x_reset_crc_count(uint8_t total_ic, //!< Number of ICs in the daisy chain
681  cell_asic *ic //!< A two dimensional array that will store the data
682  );
683 
684 /*!
685  Helper Function to initialize the CFGR data structures
686  @return void
687  */
688 void LTC681x_init_cfg(uint8_t total_ic, //!< Number of ICs in the daisy chain
689  cell_asic *ic //!< A two dimensional array that will store the data
690  );
691 
692 /*!
693  Helper function to set appropriate bits in CFGR register based on bit function
694  @return void
695  */
696 void LTC681x_set_cfgr(uint8_t nIC, //!< Current IC
697  cell_asic *ic, //!< A two dimensional array that will store the data
698  bool refon, //!< The REFON bit
699  bool adcopt, //!< The ADCOPT bit
700  bool gpio[5],//!< The GPIO bits
701  bool dcc[12],//!< The DCC bits
702  bool dcto[4],//!< The Dcto bits
703  uint16_t uv, //!< The UV value
704  uint16_t ov //!< The OV value
705  );
706 
707 /*!
708  Helper function to turn the REFON bit HIGH or LOW
709  @return void
710  */
711 void LTC681x_set_cfgr_refon(uint8_t nIC, //!< Current IC
712  cell_asic *ic, //!< A two dimensional array that will store the data
713  bool refon //!< The REFON bit
714  );
715 
716 /*!
717  Helper function to turn the ADCOPT bit HIGH or LOW
718  @return void
719  */
720 void LTC681x_set_cfgr_adcopt(uint8_t nIC, //!< Current IC
721  cell_asic *ic, //!< A two dimensional array that will store the data
722  bool adcopt //!< The ADCOPT bit
723  );
724 
725 /*!
726  Helper function to turn the GPIO bits HIGH or LOW
727  @return void
728  */
729 void LTC681x_set_cfgr_gpio(uint8_t nIC, //!< Current IC
730  cell_asic *ic, //!< A two dimensional array that will store the data
731  bool gpio[] //!< The GPIO bits
732  );
733 
734 /*!
735  Helper function to turn the DCC bits HIGH or LOW
736  @return void
737  */
738 void LTC681x_set_cfgr_dis(uint8_t nIC, //!< Current IC
739  cell_asic *ic, //!< A two dimensional array that will store the data
740  bool dcc[] //!< The DCC bits
741  );
742 
743 /*!
744  Helper function to control discharge time value
745  @return void
746  */
747 void LTC681x_set_cfgr_dcto(uint8_t nIC, //!< Current IC
748  cell_asic *ic, //!< A two dimensional array that will store the data
749  bool dcto[] //!< The Dcto bits
750  );
751 
752 /*!
753  Helper function to set uv field in CFGRA register
754  @return void
755  */
756 void LTC681x_set_cfgr_uv(uint8_t nIC, //!< Current IC
757  cell_asic *ic, //!< A two dimensional array that will store the data
758  uint16_t uv //!< The UV value
759  );
760 
761 /*!
762  Helper function to set ov field in CFGRA register
763  @return void
764  */
765 void LTC681x_set_cfgr_ov(uint8_t nIC, //!< Current IC
766  cell_asic *ic, //!< A two dimensional array that will store the data
767  uint16_t ov //!< The OV value
768  );
769 
770 #ifdef MBED
771 //This needs a PROGMEM = when using with a LINDUINO
772 const uint16_t crc15Table[256] {0x0,0xc599, 0xceab, 0xb32, 0xd8cf, 0x1d56, 0x1664, 0xd3fd, 0xf407, 0x319e, 0x3aac, // precomputed CRC15 Table
773  0xff35, 0x2cc8, 0xe951, 0xe263, 0x27fa, 0xad97, 0x680e, 0x633c, 0xa6a5, 0x7558, 0xb0c1,
774  0xbbf3, 0x7e6a, 0x5990, 0x9c09, 0x973b, 0x52a2, 0x815f, 0x44c6, 0x4ff4, 0x8a6d, 0x5b2e,
775  0x9eb7, 0x9585, 0x501c, 0x83e1, 0x4678, 0x4d4a, 0x88d3, 0xaf29, 0x6ab0, 0x6182, 0xa41b,
776  0x77e6, 0xb27f, 0xb94d, 0x7cd4, 0xf6b9, 0x3320, 0x3812, 0xfd8b, 0x2e76, 0xebef, 0xe0dd,
777  0x2544, 0x2be, 0xc727, 0xcc15, 0x98c, 0xda71, 0x1fe8, 0x14da, 0xd143, 0xf3c5, 0x365c,
778  0x3d6e, 0xf8f7,0x2b0a, 0xee93, 0xe5a1, 0x2038, 0x7c2, 0xc25b, 0xc969, 0xcf0, 0xdf0d,
779  0x1a94, 0x11a6, 0xd43f, 0x5e52, 0x9bcb, 0x90f9, 0x5560, 0x869d, 0x4304, 0x4836, 0x8daf,
780  0xaa55, 0x6fcc, 0x64fe, 0xa167, 0x729a, 0xb703, 0xbc31, 0x79a8, 0xa8eb, 0x6d72, 0x6640,
781  0xa3d9, 0x7024, 0xb5bd, 0xbe8f, 0x7b16, 0x5cec, 0x9975, 0x9247, 0x57de, 0x8423, 0x41ba,
782  0x4a88, 0x8f11, 0x57c, 0xc0e5, 0xcbd7, 0xe4e, 0xddb3, 0x182a, 0x1318, 0xd681, 0xf17b,
783  0x34e2, 0x3fd0, 0xfa49, 0x29b4, 0xec2d, 0xe71f, 0x2286, 0xa213, 0x678a, 0x6cb8, 0xa921,
784  0x7adc, 0xbf45, 0xb477, 0x71ee, 0x5614, 0x938d, 0x98bf, 0x5d26, 0x8edb, 0x4b42, 0x4070,
785  0x85e9, 0xf84, 0xca1d, 0xc12f, 0x4b6, 0xd74b, 0x12d2, 0x19e0, 0xdc79, 0xfb83, 0x3e1a, 0x3528,
786  0xf0b1, 0x234c, 0xe6d5, 0xede7, 0x287e, 0xf93d, 0x3ca4, 0x3796, 0xf20f, 0x21f2, 0xe46b, 0xef59,
787  0x2ac0, 0xd3a, 0xc8a3, 0xc391, 0x608, 0xd5f5, 0x106c, 0x1b5e, 0xdec7, 0x54aa, 0x9133, 0x9a01,
788  0x5f98, 0x8c65, 0x49fc, 0x42ce, 0x8757, 0xa0ad, 0x6534, 0x6e06, 0xab9f, 0x7862, 0xbdfb, 0xb6c9,
789  0x7350, 0x51d6, 0x944f, 0x9f7d, 0x5ae4, 0x8919, 0x4c80, 0x47b2, 0x822b, 0xa5d1, 0x6048, 0x6b7a,
790  0xaee3, 0x7d1e, 0xb887, 0xb3b5, 0x762c, 0xfc41, 0x39d8, 0x32ea, 0xf773, 0x248e, 0xe117, 0xea25,
791  0x2fbc, 0x846, 0xcddf, 0xc6ed, 0x374, 0xd089, 0x1510, 0x1e22, 0xdbbb, 0xaf8, 0xcf61, 0xc453,
792  0x1ca, 0xd237, 0x17ae, 0x1c9c, 0xd905, 0xfeff, 0x3b66, 0x3054, 0xf5cd, 0x2630, 0xe3a9, 0xe89b,
793  0x2d02, 0xa76f, 0x62f6, 0x69c4, 0xac5d, 0x7fa0, 0xba39, 0xb10b, 0x7492, 0x5368, 0x96f1, 0x9dc3,
794  0x585a, 0x8ba7, 0x4e3e, 0x450c, 0x8095
795  };
796 
797 #else
798 const uint16_t crc15Table[256] PROGMEM = {0x0,0xc599, 0xceab, 0xb32, 0xd8cf, 0x1d56, 0x1664, 0xd3fd, 0xf407, 0x319e, 0x3aac, // precomputed CRC15 Table
799  0xff35, 0x2cc8, 0xe951, 0xe263, 0x27fa, 0xad97, 0x680e, 0x633c, 0xa6a5, 0x7558, 0xb0c1,
800  0xbbf3, 0x7e6a, 0x5990, 0x9c09, 0x973b, 0x52a2, 0x815f, 0x44c6, 0x4ff4, 0x8a6d, 0x5b2e,
801  0x9eb7, 0x9585, 0x501c, 0x83e1, 0x4678, 0x4d4a, 0x88d3, 0xaf29, 0x6ab0, 0x6182, 0xa41b,
802  0x77e6, 0xb27f, 0xb94d, 0x7cd4, 0xf6b9, 0x3320, 0x3812, 0xfd8b, 0x2e76, 0xebef, 0xe0dd,
803  0x2544, 0x2be, 0xc727, 0xcc15, 0x98c, 0xda71, 0x1fe8, 0x14da, 0xd143, 0xf3c5, 0x365c,
804  0x3d6e, 0xf8f7,0x2b0a, 0xee93, 0xe5a1, 0x2038, 0x7c2, 0xc25b, 0xc969, 0xcf0, 0xdf0d,
805  0x1a94, 0x11a6, 0xd43f, 0x5e52, 0x9bcb, 0x90f9, 0x5560, 0x869d, 0x4304, 0x4836, 0x8daf,
806  0xaa55, 0x6fcc, 0x64fe, 0xa167, 0x729a, 0xb703, 0xbc31, 0x79a8, 0xa8eb, 0x6d72, 0x6640,
807  0xa3d9, 0x7024, 0xb5bd, 0xbe8f, 0x7b16, 0x5cec, 0x9975, 0x9247, 0x57de, 0x8423, 0x41ba,
808  0x4a88, 0x8f11, 0x57c, 0xc0e5, 0xcbd7, 0xe4e, 0xddb3, 0x182a, 0x1318, 0xd681, 0xf17b,
809  0x34e2, 0x3fd0, 0xfa49, 0x29b4, 0xec2d, 0xe71f, 0x2286, 0xa213, 0x678a, 0x6cb8, 0xa921,
810  0x7adc, 0xbf45, 0xb477, 0x71ee, 0x5614, 0x938d, 0x98bf, 0x5d26, 0x8edb, 0x4b42, 0x4070,
811  0x85e9, 0xf84, 0xca1d, 0xc12f, 0x4b6, 0xd74b, 0x12d2, 0x19e0, 0xdc79, 0xfb83, 0x3e1a, 0x3528,
812  0xf0b1, 0x234c, 0xe6d5, 0xede7, 0x287e, 0xf93d, 0x3ca4, 0x3796, 0xf20f, 0x21f2, 0xe46b, 0xef59,
813  0x2ac0, 0xd3a, 0xc8a3, 0xc391, 0x608, 0xd5f5, 0x106c, 0x1b5e, 0xdec7, 0x54aa, 0x9133, 0x9a01,
814  0x5f98, 0x8c65, 0x49fc, 0x42ce, 0x8757, 0xa0ad, 0x6534, 0x6e06, 0xab9f, 0x7862, 0xbdfb, 0xb6c9,
815  0x7350, 0x51d6, 0x944f, 0x9f7d, 0x5ae4, 0x8919, 0x4c80, 0x47b2, 0x822b, 0xa5d1, 0x6048, 0x6b7a,
816  0xaee3, 0x7d1e, 0xb887, 0xb3b5, 0x762c, 0xfc41, 0x39d8, 0x32ea, 0xf773, 0x248e, 0xe117, 0xea25,
817  0x2fbc, 0x846, 0xcddf, 0xc6ed, 0x374, 0xd089, 0x1510, 0x1e22, 0xdbbb, 0xaf8, 0xcf61, 0xc453,
818  0x1ca, 0xd237, 0x17ae, 0x1c9c, 0xd905, 0xfeff, 0x3b66, 0x3054, 0xf5cd, 0x2630, 0xe3a9, 0xe89b,
819  0x2d02, 0xa76f, 0x62f6, 0x69c4, 0xac5d, 0x7fa0, 0xba39, 0xb10b, 0x7492, 0x5368, 0x96f1, 0x9dc3,
820  0x585a, 0x8ba7, 0x4e3e, 0x450c, 0x8095
821  };
822  #endif
823 #endif
void LTC681x_wrcomm(uint8_t total_ic, cell_asic *ic)
Write the LTC681x COMM register This command will write the comm registers of the LTC681x connected i...
int8_t LTC681x_rdcfg(uint8_t total_ic, cell_asic *ic)
Reads the LTC681x CFGRA register.
ic_register sctrl
Definition: LTC681x.h:180
PEC error counter structure.
Definition: LTC681x.h:149
void LTC681x_clrstat()
Clears the LTC681x Stat registers The command clears the Stat registers and initializes all values to...
Definition: LTC681x.cpp:960
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
ic_register configb
Definition: LTC681x.h:173
void LTC681x_statst(uint8_t MD, uint8_t ST)
Start a Status Register Self Test Conversion.
Definition: LTC681x.cpp:1006
void LTC681x_stcomm(uint8_t len)
Issues a stcomm command and clocks data out of the COMM register.
Definition: LTC681x.cpp:1978
Cell Voltage data structure.
Definition: LTC681x.h:117
int8_t LTC681x_rdcfgb(uint8_t total_ic, cell_asic *ic)
Reads the LTC681x CFGRB register.
void LTC681x_cvst(uint8_t MD, uint8_t ST)
Starts cell voltage self test conversion.
Definition: LTC681x.cpp:974
ax aux
Definition: LTC681x.h:175
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
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
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
uint16_t LTC681x_st_lookup(uint8_t MD, uint8_t ST, bool adcopt)
Self Test Helper Function.
Definition: LTC681x.cpp:1245
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
Cell variable structure.
Definition: LTC681x.h:170
void LTC681x_reset_crc_count(uint8_t total_ic, cell_asic *ic)
Helper Function that resets the PEC error counters.
Definition: LTC681x.cpp:2059
int8_t LTC681x_rdcomm(uint8_t total_ic, cell_asic *ic)
Reads comm registers of a LTC681x daisy chain.
void LTC681x_axow(uint8_t MD, uint8_t PUP)
Start GPIOs open wire ADC conversion.
Definition: LTC681x.cpp:1310
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
pec_counter crc_count
Definition: LTC681x.h:184
register_cfg ic_reg
Definition: LTC681x.h:185
void LTC681x_wrpwm(uint8_t total_ic, uint8_t pwmReg, cell_asic *ic)
Write the LTC681x PWM register This command will write the pwm registers of the LTC681x connected in ...
uint8_t num_cv_reg
Number of Cell voltage register.
Definition: LTC681x.h:164
ic_register com
Definition: LTC681x.h:177
uint8_t num_gpio_reg
Number of Aux register.
Definition: LTC681x.h:165
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 wakeup_sleep(uint8_t total_ic)
Wake the LTC681x from the sleep state.
Definition: LTC681x.cpp:65
void LTC681x_wrcfgb(uint8_t total_ic, cell_asic *ic)
Write the LTC681x CFGRB register This command will write the configuration registers of the LTC681xs ...
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
void LTC681x_adstat(uint8_t MD, uint8_t CHST)
Start a Status ADC Conversion.
Definition: LTC681x.cpp:383
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_adol(uint8_t MD, uint8_t DCP)
Starts cell voltage overlap conversion.
Definition: LTC681x.cpp:1022
union LT_union_int32_4bytes data
Definition: DC2094A.ino:138
void LTC681x_rdcv_reg(uint8_t reg, uint8_t total_ic, uint8_t *data)
Reads the raw cell voltage register data.
Definition: LTC681x.cpp:694
static const unsigned int crc15Table[256]
Definition: LTC68041.h:90
void LTC681x_adax(uint8_t MD, uint8_t CHG)
Start a GPIO and Vref2 Conversion.
Definition: LTC681x.cpp:367
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
Register configuration structure.
Definition: LTC681x.h:159
void LTC681x_run_openwire_multi(uint8_t total_ic, cell_asic *ic)
Helper function that runs open wire for multiple cell and two consecutive cells detection.
void LTC681x_init_cfg(uint8_t total_ic, cell_asic *ic)
Helper Function to initialize the CFGR data structures.
Definition: LTC681x.cpp:2084
uint16_t pec_count
Overall PEC error count.
Definition: LTC681x.h:151
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
uint8_t stat_channels
Number of Stat channels.
Definition: LTC681x.h:162
int8_t LTC681x_rdpwm(uint8_t total_ic, uint8_t pwmReg, cell_asic *ic)
Reads pwm registers of a LTC681x daisy chain.
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_adcvsc(uint8_t MD, uint8_t DCP)
Starts cell voltage and SOC conversion.
Definition: LTC681x.cpp:399
ic_register pwm
Definition: LTC681x.h:178
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 LTC681x_diagn()
Starts the Mux Decoder diagnostic self test Running this command will start the Mux Decoder Diagnosti...
Definition: LTC681x.cpp:967
uint8_t cell_channels
Number of Cell channels.
Definition: LTC681x.h:161
void LTC681x_adaxd(uint8_t MD, uint8_t CHG)
Start an GPIO Redundancy test.
Definition: LTC681x.cpp:1038
uint8_t num_stat_reg
Number of Status register.
Definition: LTC681x.h:166
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 LTC681x_clrsctrl()
Clears the LTC681x SCTRL registers The command clears the SCTRL registers and initializes all values ...
Definition: LTC681x.cpp:1900
void LTC681x_run_gpio_openwire(uint8_t total_ic, cell_asic *ic)
Runs open wire for GPIOs.
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
void LTC681x_axst(uint8_t MD, uint8_t ST)
Start an Auxiliary Register Self Test Conversion.
Definition: LTC681x.cpp:990
uint8_t rx_pec_match
If a PEC error was detected during most recent read cmd.
Definition: LTC681x.h:145
Status Reg data structure.
Definition: LTC681x.h:131
void wakeup_idle(uint8_t total_ic)
Wake isoSPI up from IDlE state and enters the READY state.
Definition: LTC681x.cpp:54
uint16_t cfgr_pec
Configuration register data PEC error count.
Definition: LTC681x.h:152
st stat
Definition: LTC681x.h:176
ic_register config
Definition: LTC681x.h:172
void LTC681x_adstatd(uint8_t MD, uint8_t CHST)
Start a Status register redundancy test Conversion.
Definition: LTC681x.cpp:1054
const uint16_t crc15Table [256] PROGMEM
Definition: LTC681x.h:798
uint8_t LTC681x_pladc()
Sends the poll ADC command.
Definition: LTC681x.cpp:878
void LTC681x_set_cfgr_dis(uint8_t nIC, cell_asic *ic, bool dcc[])
Helper function to turn the DCC bits HIGH or LOW.
void cmd_68(uint8_t tx_cmd[2])
Sends a command to the BMS IC.
Definition: LTC681x.cpp:77
void LTC681x_set_cfgr_dcto(uint8_t nIC, cell_asic *ic, bool dcto[])
Helper function to control discharge time value.
IC register structure.
Definition: LTC681x.h:141
uint16_t LTC681x_run_adc_overlap(uint8_t total_ic, cell_asic *ic)
Helper Function that runs the ADC Overlap test.
Definition: LTC681x.cpp:1158
void LTC681x_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.
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_rdaux_reg(uint8_t reg, uint8_t total_ic, uint8_t *data)
Read the raw data from the LTC681x auxiliary register The function reads a single GPIO voltage regist...
Definition: LTC681x.cpp:748
void LTC681x_clrcell()
Clears the LTC681x Cell voltage registers The command clears the cell voltage registers and initializ...
Definition: LTC681x.cpp:937
void LTC681x_wrcfg(uint8_t total_ic, cell_asic *ic)
Write the LTC681x CFGRA register This command will write the configuration registers of the LTC681xs ...
uint32_t LTC681x_pollAdc()
This function will block operation until the ADC has finished it&#39;s conversion.
Definition: LTC681x.cpp:899
AUX Reg Voltage Data structure.
Definition: LTC681x.h:124
void LTC681x_set_cfgr_gpio(uint8_t nIC, cell_asic *ic, bool gpio[])
Helper function to turn the GPIO bits HIGH or LOW.
long system_open_wire
Definition: LTC681x.h:186
cv cells
Definition: LTC681x.h:174
uint8_t aux_channels
Number of Aux channels.
Definition: LTC681x.h:163
static uint16_t cell_codes[TOTAL_IC][12]
The cell codes will be stored in the cell_codes[][12] array in the following format: ...
Definition: DC1651A.ino:108
int8_t parse_cells(uint8_t current_ic, uint8_t cell_reg, uint8_t cell_data[], uint16_t *cell_codes, uint8_t *ic_pec)
Helper function that parses voltage measurement registers.
Definition: LTC681x.cpp:833
void LTC681x_stsctrl()
Start Sctrl data communication This command will start the sctrl pulse communication over the spins...
Definition: LTC681x.cpp:1879
ic_register pwmb
Definition: LTC681x.h:179
bool isospi_reverse
Definition: LTC681x.h:183
void LTC681x_rdstat_reg(uint8_t reg, uint8_t total_ic, uint8_t *data)
Read the raw data from the LTC681x stat register The function reads a single Status register and stor...
Definition: LTC681x.cpp:797
uint16_t pec15_calc(uint8_t len, uint8_t *data)
Calculates and returns the CRC15.
Definition: LTC68041.cpp:985
void LTC681x_clraux()
Clears the LTC681x Auxiliary registers The command clears the Auxiliary registers and initializes all...
Definition: LTC681x.cpp:948
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
void LTC681x_adcvax(uint8_t MD, uint8_t DCP)
Starts cell voltage and GPIO 1&2 conversion.
Definition: LTC681x.cpp:415
void LTC681x_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: LTC681x.cpp:2098