| Linduino 1.3.0 Linear Technology Arduino-Compatible Demonstration Board

Functions | Macros | Variables
LTC68041.h File Reference
Battery Management System (BMS) » LTC6804-1: Multicell Battery Monitor

LTC6804-1 Multicell Battery Monitor. More...

## Detailed Description

LTC6804-1 Multicell Battery Monitor.

http://www.linear.com/product/LTC6804-1

http://www.linear.com/product/LTC6804-1#demoboards

Copyright 2018(c) Analog Devices, Inc.

All rights reserved.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

- Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
- Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
- Neither the name of Analog Devices, Inc. nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
- The use of this software may or may not infringe the patent rights of one or more patent holders. This license does not release you from the requirement that you obtain separate licenses from these patent holders to use this software.
- Use of the software either in source or binary form, must be run on or directly connected to an Analog Devices Inc. component.

THIS SOFTWARE IS PROVIDED BY ANALOG DEVICES "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL ANALOG DEVICES BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, INTELLECTUAL PROPERTY RIGHTS, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

Copyright 2013 Linear Technology Corp. (LTC)

Header for LTC6804-1 Multicell Battery Monitor

Definition in file LTC68041.h.

Go to the source code of this file.

## Functions
void | LTC6804_initialize ()
| This function will initialize all 6804 variables and the SPI port. More...
void | set_adc (uint8_t MD, uint8_t DCP, uint8_t CH, uint8_t CHG)
| More...
void | LTC6804_adcv ()
| More...
void | LTC6804_adax ()
| More...
uint8_t | LTC6804_rdcv (uint8_t reg, uint8_t total_ic, uint16_t cell_codes[][12])
| Reads and parses the LTC6804 cell voltage registers. More...
void | LTC6804_rdcv_reg (uint8_t reg, uint8_t nIC, uint8_t *data)
| Read the raw data from the LTC6804 cell voltage register. More...
int8_t | LTC6804_rdaux (uint8_t reg, uint8_t nIC, uint16_t aux_codes[][6])
| Reads and parses the LTC6804 auxiliary registers. More...
void | LTC6804_rdaux_reg (uint8_t reg, uint8_t nIC, uint8_t *data)
| Read the raw data from the LTC6804 auxiliary register. More...
void | LTC6804_clrcell ()
| Clears the LTC6804 cell voltage registers. More...
void | LTC6804_clraux ()
| Clears the LTC6804 Auxiliary registers. More...
void | LTC6804_wrcfg (uint8_t nIC, uint8_t config[][6])
| Write the LTC6804 configuration register. More...
int8_t | LTC6804_rdcfg (uint8_t nIC, uint8_t r_config[][8])
| More...
void | wakeup_idle ()
| More...
void | wakeup_sleep ()
| More...
uint16_t | pec15_calc (uint8_t len, uint8_t *data)
| More...
void | spi_write_array (uint8_t length, uint8_t *data)
void | spi_write_read (uint8_t *TxData, uint8_t TXlen, uint8_t *rx_data, uint8_t RXlen)

## Macros
#define | LTC6804_CS QUIKEVAL_CS
#define | MD_FAST 1
MD | Dec | ADC Conversion Model
--- | --- | ---
01 | 1 | Fast
10 | 2 | Normal
11 | 3 | Filtered
More...
#define | MD_NORMAL 2
#define | MD_FILTERED 3
#define | CELL_CH_ALL 0
CH | Dec | Channels to convert
--- | --- | ---
000 | 0 | All Cells
001 | 1 | Cell 1 and Cell 7
010 | 2 | Cell 2 and Cell 8
011 | 3 | Cell 3 and Cell 9
100 | 4 | Cell 4 and Cell 10
101 | 5 | Cell 5 and Cell 11
110 | 6 | Cell 6 and Cell 12
More...
#define | CELL_CH_1and7 1
#define | CELL_CH_2and8 2
#define | CELL_CH_3and9 3
#define | CELL_CH_4and10 4
#define | CELL_CH_5and11 5
#define | CELL_CH_6and12 6
#define | AUX_CH_ALL 0
CHG | Dec | Channels to convert
--- | --- | ---
000 | 0 | All GPIOS and 2nd Ref
001 | 1 | GPIO 1
010 | 2 | GPIO 2
011 | 3 | GPIO 3
100 | 4 | GPIO 4
101 | 5 | GPIO 5
110 | 6 | Vref2
More...
#define | AUX_CH_GPIO1 1
#define | AUX_CH_GPIO2 2
#define | AUX_CH_GPIO3 3
#define | AUX_CH_GPIO4 4
#define | AUX_CH_GPIO5 5
#define | AUX_CH_VREF2 6
#define | DCP_DISABLED 0
| More...
#define | DCP_ENABLED 1

## Variables
static const unsigned int | crc15Table [256]

## Function Documentation

## ◆ LTC6804_adax()

void LTC6804_adax | ( |  | ) |

Start an GPIO Conversion

Starts an ADC conversions of the LTC6804 GPIO inputs. The type of ADC conversion executed can be changed by setting the associated global variables:

Variable | Function
--- | ---
MD | Determines the filter corner of the ADC
CHG | Determines which GPIO channels are converted

## Command Code:

CMD[0:1] | 15 | 14 | 13 | 12 | 11 | 10 | 9 | 8 | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0
--- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | ---
ADAX: | 0 | 0 | 0 | 0 | 0 | 1 | 0 | MD[1] | MD[2] | 1 | 1 | DCP | 0 | CHG[2] | CHG[1] | CHG[0]

Start an GPIO Conversion

Starts an ADC conversions of the LTC6804 GPIO inputs. The type of ADC conversion done is set using the associated global variables:

Variable | Function
--- | ---
MD | Determines the filter corner of the ADC
CHG | Determines which GPIO channels are converted

Definition at line 206 of file LTC68041.cpp.

## ◆ LTC6804_adcv()

void LTC6804_adcv | ( |  | ) |

Starts cell voltage conversion

Starts ADC conversions of the LTC6804 Cpin inputs. The type of ADC conversion executed can be changed by setting the associated global variables:

Variable | Function
--- | ---
MD | Determines the filter corner of the ADC
CH | Determines which cell channels are converted
DCP | Determines if Discharge is Permitted

## Command Code:

CMD[0:1] | 15 | 14 | 13 | 12 | 11 | 10 | 9 | 8 | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0
--- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | ---
ADCV: | 0 | 0 | 0 | 0 | 0 | 0 | 1 | MD[1] | MD[2] | 1 | 1 | DCP | 0 | CH[2] | CH[1] | CH[0]

Starts cell voltage conversion

Starts ADC conversions of the LTC6804 Cpin inputs. The type of ADC conversion done is set using the associated global variables:

Variable | Function
--- | ---
MD | Determines the filter corner of the ADC
CH | Determines which cell channels are converted
DCP | Determines if Discharge is Permitted

Definition at line 154 of file LTC68041.cpp.

## ◆ LTC6804_clraux()

void LTC6804_clraux | ( |  | ) |

Clears the LTC6804 Auxiliary registers.

The command clears the Auxiliary registers and intiallizes all values to 1. The register will read back hexadecimal 0xFF after the command is sent.

## Command Code:

CMD[0:1] | 15 | 14 | 13 | 12 | 11 | 10 | 9 | 8 | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0
--- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | ---
CLRAUX: | 0 | 0 | 0 | 0 | 0 | 1 | 1 | 1 | 0 | 0 | 0 | 1 | 0 | 0 | 2 | 0

The command clears the Auxiliary registers and intiallizes all values to 1. The register will read back hexadecimal 0xFF after the command is sent.

Definition at line 746 of file LTC68041.cpp.

## ◆ LTC6804_clrcell()

void LTC6804_clrcell | ( |  | ) |

Clears the LTC6804 cell voltage registers.

The command clears the cell voltage registers and intiallizes all values to 1. The register will read back hexadecimal 0xFF after the command is sent.

## Command Code:

CMD[0:1] | 15 | 14 | 13 | 12 | 11 | 10 | 9 | 8 | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0
--- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | ---
CLRCELL: | 0 | 0 | 0 | 0 | 0 | 1 | 1 | 1 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 1

The command clears the cell voltage registers and intiallizes all values to 1. The register will read back hexadecimal 0xFF after the command is sent.

Definition at line 699 of file LTC68041.cpp.

## ◆ LTC6804_initialize()

void LTC6804_initialize | ( |  | ) |

This function will initialize all 6804 variables and the SPI port.

This function will initialize the Linduino to communicate with the LTC6804 with a 1MHz SPI clock. The Function also intializes the ADCV and ADAX commands to convert all cell and GPIO voltages in the Normal ADC mode.

## input:

IC: number of ICs being controlled. The address of the ICs in a LTC6804-2 network will start at 0 and continue in an ascending order.

Definition at line 92 of file LTC68041.cpp.

## ◆ LTC6804_rdaux()

int8_t LTC6804_rdaux | ( | uint8_t | reg,
|  | uint8_t | total_ic,
|  | uint16_t | aux_codes[][6]
| ) |  |

Reads and parses the LTC6804 auxiliary registers.

The function is used to read the parsed GPIO codes of the LTC6804. This function will send the requested read commands parse the data and store the gpio voltages in aux_codes variable

Parameters

  [in] | uint8_t | reg; This controls which GPIO voltage register is read back.
            0: Read back all auxiliary registers

            1: Read back auxiliary group A

            2: Read back auxiliary group B
  [in] | uint8_t | total_ic; This is the number of ICs in the daisy chain(-1 only)
  [out] | uint16_t | aux_codes[][6]; A two dimensional array of the gpio voltage codes. The GPIO codes will be stored in the aux_codes[][6] array in the following format:
  aux_codes[0][0] | aux_codes[0][1] | aux_codes[0][2] | aux_codes[0][3] | aux_codes[0][4] | aux_codes[0][5] | aux_codes[1][0] | aux_codes[1][1] | .....
  --- | --- | --- | --- | --- | --- | --- | --- | ---
  IC1 GPIO1 | IC1 GPIO2 | IC1 GPIO3 | IC1 GPIO4 | IC1 GPIO5 | IC1 Vref2 | IC2 GPIO1 | IC2 GPIO2 | .....

Returns
  int8_t, PEC Status

0: No PEC error detected

-1: PEC error detected, retry read

The function is used to read the parsed GPIO codes of the LTC6804. This function will send the requested read commands parse the data and store the gpio voltages in aux_codes variable

Parameters

  [in] | uint8_t | reg; This controls which GPIO voltage register is read back.
           0: Read back all auxiliary registers

           1: Read back auxiliary group A

           2: Read back auxiliary group B
  [in] | uint8_t | total_ic; This is the number of ICs in the network
  [out] | uint8_t | aux_codes[]; An array of the aux codes from lowest to highest. The GPIO codes will be stored in the aux_codes[] array in the following format:
  aux_codes[0] | aux_codes[1] | aux_codes[2] | aux_codes[3] | aux_codes[4] | aux_codes[5] | aux_codes[6] | aux_codes[7] | .....
  --- | --- | --- | --- | --- | --- | --- | --- | ---
  IC1 GPIO1 | IC1 GPIO2 | IC1 GPIO3 | IC1 GPIO4 | IC1 GPIO5 | IC1 Vref2 | IC2 GPIO1 | IC2 GPIO2 | .....

Returns
  int8_t, PEC Status.

0: No PEC error detected

-1: PEC error detected, retry read

Definition at line 495 of file LTC68041.cpp.

## ◆ LTC6804_rdaux_reg()

void LTC6804_rdaux_reg | ( | uint8_t | reg,
|  | uint8_t | total_ic,
|  | uint8_t * | data
| ) |  |

Read the raw data from the LTC6804 auxiliary register.

The function reads a single GPIO voltage register and stores thre read data in the *data point as a byte array. This function is rarely used outside of the LTC6804_rdaux() command.

Parameters

  [in] | uint8_t | reg; This controls which GPIO voltage register is read back.
           1: Read back auxiliary group A

           2: Read back auxiliary group B
  [in] | uint8_t | total_ic; This is the number of ICs in the daisy chain
  [out] | uint8_t | *data; An array of the unparsed aux codes

## Command Code:

CMD[0:1] | 15 | 14 | 13 | 12 | 11 | 10 | 9 | 8 | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0
--- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | ---
RDAUXA: | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 1 | 0 | 0
RDAUXB: | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 1 | 1 | 0

The function reads a single GPIO voltage register and stores thre read data in the *data point as a byte array. This function is rarely used outside of the LTC6804_rdaux() command.

Parameters

  [in] | uint8_t | reg; This controls which GPIO voltage register is read back.
           1: Read back auxiliary group A

           2: Read back auxiliary group B
  [in] | uint8_t | total_ic; This is the number of ICs in the stack
  [out] | uint8_t | *data; An array of the unparsed aux codes

Definition at line 638 of file LTC68041.cpp.

## ◆ LTC6804_rdcfg()

int8_t LTC6804_rdcfg | ( | uint8_t | total_ic,
|  | uint8_t | r_config[][8]
| ) |  |

Reads configuration registers of a LTC6804 daisy chain

Parameters

  [in] | uint8_t | total_ic: number of ICs in the daisy chain
  [out] | uint8_t | r_config[][8] is a two dimensional array that the function stores the read configuration data. The configuration data for each IC is stored in blocks of 8 bytes with the configuration data of the lowest IC on the stack in the first 8 bytes block of the array, the second IC in the second 8 byte etc. Below is an table illustrating the array organization:

r_config[0][0] | r_config[0][1] | r_config[0][2] | r_config[0][3] | r_config[0][4] | r_config[0][5] | r_config[0][6] | r_config[0][7] | r_config[1][0] | r_config[1][1] | .....
--- | --- | --- | --- | --- | --- | --- | --- | --- | --- | ---
IC1 CFGR0 | IC1 CFGR1 | IC1 CFGR2 | IC1 CFGR3 | IC1 CFGR4 | IC1 CFGR5 | IC1 PEC High | IC1 PEC Low | IC2 CFGR0 | IC2 CFGR1 | .....

Returns
  int8_t, PEC Status.

0: Data read back has matching PEC

-1: Data read back has incorrect PEC

## Command Code:

CMD[0:1] | 15 | 14 | 13 | 12 | 11 | 10 | 9 | 8 | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0
--- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | ---
RDCFG: | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 1 | 0

Reads configuration registers of a LTC6804 stack

Parameters

  [in] | uint8_t | total_ic: number of ICs in the stack
  [out] | uint8_t | *r_config: array that the function will write configuration data to. The configuration data for each IC is stored in blocks of 8 bytes with the configuration data of the lowest IC on the stack in the first 8 bytes of the array, the second IC in the second 8 byte etc. Below is an table illustrating the array organization:

r_config[0] | r_config[1] | r_config[2] | r_config[3] | r_config[4] | r_config[5] | r_config[6] | r_config[7] | r_config[8] | r_config[9] | .....
--- | --- | --- | --- | --- | --- | --- | --- | --- | --- | ---
IC1 CFGR0 | IC1 CFGR1 | IC1 CFGR2 | IC1 CFGR3 | IC1 CFGR4 | IC1 CFGR5 | IC1 PEC High | IC1 PEC Low | IC2 CFGR0 | IC2 CFGR1 | .....

Returns
  int8_t PEC Status. 0: Data read back has matching PEC

-1: Data read back has incorrect PEC

Definition at line 891 of file LTC68041.cpp.

## ◆ LTC6804_rdcv()

uint8_t LTC6804_rdcv | ( | uint8_t | reg,
|  | uint8_t | total_ic,
|  | uint16_t | cell_codes[][12]
| ) |  |

Reads and parses the LTC6804 cell voltage registers.

The function is used to read the cell codes of the LTC6804. This function will send the requested read commands parse the data and store the cell voltages in cell_codes variable.

Parameters

  [in] | uint8_t | reg; This controls which cell voltage register is read back.
           0: Read back all Cell registers

           1: Read back cell group A

           2: Read back cell group B

           3: Read back cell group C

           4: Read back cell group D
  [in] | uint8_t | total_ic; This is the number of ICs in the daisy chain(-1 only)
  [out] | uint16_t | cell_codes[]; An array of the parsed cell codes from lowest to highest. The cell codes will be stored in the cell_codes[] array in the following format:
  cell_codes[0][0] | cell_codes[0][1] | cell_codes[0][2] | ..... | cell_codes[0][11] | cell_codes[1][0] | cell_codes[1][1] | .....
  --- | --- | --- | --- | --- | --- | --- | ---
  IC1 Cell 1 | IC1 Cell 2 | IC1 Cell 3 | ..... | IC1 Cell 12 | IC2 Cell 1 | IC2 Cell 2 | .....

Returns
  int8_t, PEC Status.

0: No PEC error detected

-1: PEC error detected, retry read

The function is used to read the cell codes of the LTC6804. This function will send the requested read commands parse the data and store the cell voltages in cell_codes variable.

Parameters

  [in] | uint8_t | reg; This controls which cell voltage register is read back.
            0: Read back all Cell registers

            1: Read back cell group A

            2: Read back cell group B

            3: Read back cell group C

            4: Read back cell group D
  [in] | uint8_t | total_ic; This is the number of ICs in the network
  [out] | uint16_t | cell_codes[]; An array of the parsed cell codes from lowest to highest. The cell codes will be stored in the cell_codes[] array in the following format:
  cell_codes[0] | cell_codes[1] | cell_codes[2] | ..... | cell_codes[11] | cell_codes[12] | cell_codes[13] | .....
  --- | --- | --- | --- | --- | --- | --- | ---
  IC1 Cell 1 | IC1 Cell 2 | IC1 Cell 3 | ..... | IC1 Cell 12 | IC2 Cell 1 | IC2 Cell 2 | .....

Returns
  int8_t, PEC Status.

0: No PEC error detected

-1: PEC error detected, retry read

Definition at line 268 of file LTC68041.cpp.

## ◆ LTC6804_rdcv_reg()

void LTC6804_rdcv_reg | ( | uint8_t | reg,
|  | uint8_t | total_ic,
|  | uint8_t * | data
| ) |  |

Read the raw data from the LTC6804 cell voltage register.

The function reads a single cell voltage register and stores the read data in the *data point as a byte array. This function is rarely used outside of the LTC6804_rdcv() command.

Parameters

  [in] | uint8_t | reg; This controls which cell voltage register is read back.
           1: Read back cell group A

           2: Read back cell group B

           3: Read back cell group C

           4: Read back cell group D
  [in] | uint8_t | total_ic; This is the number of ICs in the daisy chain(-1 only)
  [out] | uint8_t | *data; An array of the unparsed cell codes

## Command Code:

CMD[0:1] | 15 | 14 | 13 | 12 | 11 | 10 | 9 | 8 | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0
--- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | ---
RDCVA: | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0
RDCVB: | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 1 | 0
RDCVC: | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0
RDCVD: | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 1 | 0

The function reads a single cell voltage register and stores the read data in the *data point as a byte array. This function is rarely used outside of the LTC6804_rdcv() command.

Parameters

  [in] | uint8_t | reg; This controls which cell voltage register is read back.
           1: Read back cell group A

           2: Read back cell group B

           3: Read back cell group C

           4: Read back cell group D
  [in] | uint8_t | total_ic; This is the number of ICs in the network
  [out] | uint8_t | *data; An array of the unparsed cell codes

Definition at line 410 of file LTC68041.cpp.

## ◆ LTC6804_wrcfg()

void LTC6804_wrcfg | ( | uint8_t | total_ic,
|  | uint8_t | config[][6]
| ) |  |

Write the LTC6804 configuration register.

This command will write the configuration registers of the LTC6804-1s connected in a daisy chain stack. The configuration is written in descending order so the last device's configuration is written first.

Parameters

  [in] | uint8_t | total_ic; The number of ICs being written to.
  [in] | uint8_t | config[][6] is a two dimensional array of the configuration data that will be written, the array should contain the 6 bytes for each IC in the daisy chain. The lowest IC in the daisy chain should be the first 6 byte block in the array. The array should have the following format:
  config[0][0] | config[0][1] | config[0][2] | config[0][3] | config[0][4] | config[0][5] | config[1][0] | config[1][1] | config[1][2] | .....
  --- | --- | --- | --- | --- | --- | --- | --- | --- | ---
  IC1 CFGR0 | IC1 CFGR1 | IC1 CFGR2 | IC1 CFGR3 | IC1 CFGR4 | IC1 CFGR5 | IC2 CFGR0 | IC2 CFGR1 | IC2 CFGR2 | .....
  The function will calculate the needed PEC codes for the write data and then transmit data to the ICs on a daisy chain.

## Command Code:

| | CMD[0] | CMD[1] | |------------—|------------------------------------------------------------—|------------------------------------------------------------—|

CMD[0:1] | 15 | 14 | 13 | 12 | 11 | 10 | 9 | 8 | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0
--- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | ---
WRCFG: | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1

This command will write the configuration registers of the stacks connected in a stack stack. The configuration is written in descending order so the last device's configuration is written first.

Parameters

  [in] | uint8_t | total_ic; The number of ICs being written.
  [in] | uint8_t | *config an array of the configuration data that will be written, the array should contain the 6 bytes for each IC in the stack. The lowest IC in the stack should be the first 6 byte block in the array. The array should have the following format:
  config[0] | config[1] | config[2] | config[3] | config[4] | config[5] | config[6] | config[7] | config[8] | .....
  --- | --- | --- | --- | --- | --- | --- | --- | --- | ---
  IC1 CFGR0 | IC1 CFGR1 | IC1 CFGR2 | IC1 CFGR3 | IC1 CFGR4 | IC1 CFGR5 | IC2 CFGR0 | IC2 CFGR1 | IC2 CFGR2 | .....
  The function will calculate the needed PEC codes for the write data and then transmit data to the ICs on a stack.

Definition at line 805 of file LTC68041.cpp.

## ◆ pec15_calc()

uint16_t pec15_calc | ( | uint8_t | len,
|  | uint8_t * | data
| ) |  |

calaculates and returns the CRC15

Parameters

  [in] | uint8_t | len: the length of the data array being passed to the function
  [in] | uint8_t | data[] : the array of data that the PEC will be generated from

Returns
  The calculated pec15 as an unsigned int

calaculates and returns the CRC15

Parameters

  [in] | uint8_t | len: the length of the data array being passed to the function
  [in] | uint8_t | data[] : the array of data that the PEC will be generated from

Returns
  The calculated pec15 as an unsigned int16_t

Definition at line 985 of file LTC68041.cpp.

## ◆ set_adc()

void set_adc | ( | uint8_t | MD,
|  | uint8_t | DCP,
|  | uint8_t | CH,
|  | uint8_t | CHG
| ) |  |

Maps global ADC control variables to the appropriate control bytes for each of the different ADC commands

Parameters

  [in] | uint8_t | MD The adc conversion mode
  [in] | uint8_t | DCP Controls if Discharge is permitted during cell conversions
  [in] | uint8_t | CH Determines which cells are measured during an ADC conversion command
  [in] | uint8_t | CHG Determines which GPIO channels are measured during Auxiliary conversion command

## Command Code:

command | 15 | 14 | 13 | 12 | 11 | 10 | 9 | 8 | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0
--- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | ---
ADCV: | 0 | 0 | 0 | 0 | 0 | 0 | 1 | MD[1] | MD[2] | 1 | 1 | DCP | 0 | CH[2] | CH[1] | CH[0]
ADAX: | 0 | 0 | 0 | 0 | 0 | 1 | 0 | MD[1] | MD[2] | 1 | 1 | DCP | 0 | CHG[2] | CHG[1] | CHG[0]

Maps global ADC control variables to the appropriate control bytes for each of the different ADC commands

Parameters

  [in] | uint8_t | MD The adc conversion mode
  [in] | uint8_t | DCP Controls if Discharge is permitted during cell conversions
  [in] | uint8_t | CH Determines which cells are measured during an ADC conversion command
  [in] | uint8_t | CHG Determines which GPIO channels are measured during Auxiliary conversion command

Command Code:

command | 10 | 9 | 8 | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0
--- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | ---
ADCV: | 0 | 1 | MD[1] | MD[2] | 1 | 1 | DCP | 0 | CH[2] | CH[1] | CH[0]
ADAX: | 1 | 0 | MD[1] | MD[2] | 1 | 1 | DCP | 0 | CHG[2] | CHG[1] | CHG[0]

Definition at line 115 of file LTC68041.cpp.

## ◆ spi_write_array()

void spi_write_array | ( | uint8_t | length,
|  | uint8_t * | data
| ) |  |

## ◆ spi_write_read()

void spi_write_read | ( | uint8_t * | TxData,
|  | uint8_t | TXlen,
|  | uint8_t * | rx_data,
|  | uint8_t | RXlen
| ) |  |

## ◆ wakeup_idle()

void wakeup_idle | ( |  | ) |

Wake isoSPI up from idle state Generic wakeup commannd to wake isoSPI up out of idle

Definition at line 957 of file LTC68041.cpp.

## ◆ wakeup_sleep()

void wakeup_sleep | ( |  | ) |

Wake the LTC6804 from the sleep state

Generic wakeup commannd to wake the LTC6804 from sleep

Definition at line 969 of file LTC68041.cpp.

## Macro Definition Documentation

## ◆ AUX_CH_ALL

#define AUX_CH_ALL 0

CHG | Dec | Channels to convert
--- | --- | ---
000 | 0 | All GPIOS and 2nd Ref
001 | 1 | GPIO 1
010 | 2 | GPIO 2
011 | 3 | GPIO 3
100 | 4 | GPIO 4
101 | 5 | GPIO 5
110 | 6 | Vref2

Definition at line 164 of file LTC68041.h.

## ◆ AUX_CH_GPIO1

#define AUX_CH_GPIO1 1

Definition at line 165 of file LTC68041.h.

## ◆ AUX_CH_GPIO2

#define AUX_CH_GPIO2 2

Definition at line 166 of file LTC68041.h.

## ◆ AUX_CH_GPIO3

#define AUX_CH_GPIO3 3

Definition at line 167 of file LTC68041.h.

## ◆ AUX_CH_GPIO4

#define AUX_CH_GPIO4 4

Definition at line 168 of file LTC68041.h.

## ◆ AUX_CH_GPIO5

#define AUX_CH_GPIO5 5

Definition at line 169 of file LTC68041.h.

## ◆ AUX_CH_VREF2

#define AUX_CH_VREF2 6

Definition at line 170 of file LTC68041.h.

## ◆ CELL_CH_1and7

#define CELL_CH_1and7 1

Definition at line 143 of file LTC68041.h.

## ◆ CELL_CH_2and8

#define CELL_CH_2and8 2

Definition at line 144 of file LTC68041.h.

## ◆ CELL_CH_3and9

#define CELL_CH_3and9 3

Definition at line 145 of file LTC68041.h.

## ◆ CELL_CH_4and10

#define CELL_CH_4and10 4

Definition at line 146 of file LTC68041.h.

## ◆ CELL_CH_5and11

#define CELL_CH_5and11 5

Definition at line 147 of file LTC68041.h.

## ◆ CELL_CH_6and12

#define CELL_CH_6and12 6

Definition at line 148 of file LTC68041.h.

## ◆ CELL_CH_ALL

#define CELL_CH_ALL 0

CH | Dec | Channels to convert
--- | --- | ---
000 | 0 | All Cells
001 | 1 | Cell 1 and Cell 7
010 | 2 | Cell 2 and Cell 8
011 | 3 | Cell 3 and Cell 9
100 | 4 | Cell 4 and Cell 10
101 | 5 | Cell 5 and Cell 11
110 | 6 | Cell 6 and Cell 12

Definition at line 142 of file LTC68041.h.

## ◆ DCP_DISABLED

#define DCP_DISABLED 0

Controls if Discharging transitors are enabled or disabled during Cell conversions.

DCP | Discharge Permitted During conversion
--- | ---
0 | No - discharge is not permitted
1 | Yes - discharge is permitted

Definition at line 183 of file LTC68041.h.

## ◆ DCP_ENABLED

#define DCP_ENABLED 1

Definition at line 184 of file LTC68041.h.

## ◆ LTC6804_CS

#define LTC6804_CS QUIKEVAL_CS

Definition at line 55 of file LTC68041.h.

## ◆ MD_FAST

#define MD_FAST 1

MD | Dec | ADC Conversion Model
--- | --- | ---
01 | 1 | Fast
10 | 2 | Normal
11 | 3 | Filtered

Definition at line 125 of file LTC68041.h.

## ◆ MD_FILTERED

#define MD_FILTERED 3

Definition at line 127 of file LTC68041.h.

## ◆ MD_NORMAL

#define MD_NORMAL 2

Definition at line 126 of file LTC68041.h.

## Variable Documentation

## ◆ crc15Table

const unsigned int crc15Table[256]
| static

Initial value:
= {0x0,0xc599, 0xceab, 0xb32, 0xd8cf, 0x1d56, 0x1664, 0xd3fd, 0xf407, 0x319e, 0x3aac,
0xff35, 0x2cc8, 0xe951, 0xe263, 0x27fa, 0xad97, 0x680e, 0x633c, 0xa6a5, 0x7558, 0xb0c1,
0xbbf3, 0x7e6a, 0x5990, 0x9c09, 0x973b, 0x52a2, 0x815f, 0x44c6, 0x4ff4, 0x8a6d, 0x5b2e,
0x9eb7, 0x9585, 0x501c, 0x83e1, 0x4678, 0x4d4a, 0x88d3, 0xaf29, 0x6ab0, 0x6182, 0xa41b,
0x77e6, 0xb27f, 0xb94d, 0x7cd4, 0xf6b9, 0x3320, 0x3812, 0xfd8b, 0x2e76, 0xebef, 0xe0dd,
0x2544, 0x2be, 0xc727, 0xcc15, 0x98c, 0xda71, 0x1fe8, 0x14da, 0xd143, 0xf3c5, 0x365c,
0x3d6e, 0xf8f7,0x2b0a, 0xee93, 0xe5a1, 0x2038, 0x7c2, 0xc25b, 0xc969, 0xcf0, 0xdf0d,
0x1a94, 0x11a6, 0xd43f, 0x5e52, 0x9bcb, 0x90f9, 0x5560, 0x869d, 0x4304, 0x4836, 0x8daf,
0xaa55, 0x6fcc, 0x64fe, 0xa167, 0x729a, 0xb703, 0xbc31, 0x79a8, 0xa8eb, 0x6d72, 0x6640,
0xa3d9, 0x7024, 0xb5bd, 0xbe8f, 0x7b16, 0x5cec, 0x9975, 0x9247, 0x57de, 0x8423, 0x41ba,
0x4a88, 0x8f11, 0x57c, 0xc0e5, 0xcbd7, 0xe4e, 0xddb3, 0x182a, 0x1318, 0xd681, 0xf17b,
0x34e2, 0x3fd0, 0xfa49, 0x29b4, 0xec2d, 0xe71f, 0x2286, 0xa213, 0x678a, 0x6cb8, 0xa921,
0x7adc, 0xbf45, 0xb477, 0x71ee, 0x5614, 0x938d, 0x98bf, 0x5d26, 0x8edb, 0x4b42, 0x4070,
0x85e9, 0xf84, 0xca1d, 0xc12f, 0x4b6, 0xd74b, 0x12d2, 0x19e0, 0xdc79, 0xfb83, 0x3e1a, 0x3528,
0xf0b1, 0x234c, 0xe6d5, 0xede7, 0x287e, 0xf93d, 0x3ca4, 0x3796, 0xf20f, 0x21f2, 0xe46b, 0xef59,
0x2ac0, 0xd3a, 0xc8a3, 0xc391, 0x608, 0xd5f5, 0x106c, 0x1b5e, 0xdec7, 0x54aa, 0x9133, 0x9a01,
0x5f98, 0x8c65, 0x49fc, 0x42ce, 0x8757, 0xa0ad, 0x6534, 0x6e06, 0xab9f, 0x7862, 0xbdfb, 0xb6c9,
0x7350, 0x51d6, 0x944f, 0x9f7d, 0x5ae4, 0x8919, 0x4c80, 0x47b2, 0x822b, 0xa5d1, 0x6048, 0x6b7a,
0xaee3, 0x7d1e, 0xb887, 0xb3b5, 0x762c, 0xfc41, 0x39d8, 0x32ea, 0xf773, 0x248e, 0xe117, 0xea25,
0x2fbc, 0x846, 0xcddf, 0xc6ed, 0x374, 0xd089, 0x1510, 0x1e22, 0xdbbb, 0xaf8, 0xcf61, 0xc453,
0x1ca, 0xd237, 0x17ae, 0x1c9c, 0xd905, 0xfeff, 0x3b66, 0x3054, 0xf5cd, 0x2630, 0xe3a9, 0xe89b,
0x2d02, 0xa76f, 0x62f6, 0x69c4, 0xac5d, 0x7fa0, 0xba39, 0xb10b, 0x7492, 0x5368, 0x96f1, 0x9dc3,
0x585a, 0x8ba7, 0x4e3e, 0x450c, 0x8095
}

Definition at line 90 of file LTC68041.h.