Linduino  1.3.0
Linear Technology Arduino-Compatible Demonstration Board

Library for LTC6804-2 Multicell Battery Monitor. More...

Detailed Description

Library for LTC6804-2 Multicell Battery Monitor.

Definition in file LTC68042.cpp.

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 total_ic, uint8_t *data)
 Read the raw data from the LTC6804 cell voltage register. More...
 
int8_t LTC6804_rdaux (uint8_t reg, uint8_t total_ic, uint16_t aux_codes[][6])
 Reads and parses the LTC6804 auxiliary registers. More...
 
void LTC6804_rdaux_reg (uint8_t reg, uint8_t total_ic, 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 total_ic, uint8_t config[][6])
 Write the LTC6804 configuration register. More...
 
int8_t LTC6804_rdcfg (uint8_t total_ic, 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 len, uint8_t data[])
 Writes an array of bytes out of the SPI port. More...
 
void spi_write_read (uint8_t tx_Data[], uint8_t tx_len, uint8_t *rx_data, uint8_t rx_len)
 Writes and read a set number of bytes using the SPI port. More...
 

Variables

uint8_t ADCV [2]
 6804 conversion command variables. More...
 
uint8_t ADAX [2]
 GPIO conversion command. More...
 

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 done is set using the associated global variables:

VariableFunction
MD Determines the filter corner of the ADC
CHG Determines which GPIO channels are converted

Definition at line 195 of file LTC68042.cpp.

◆ LTC6804_adcv()

void LTC6804_adcv ( )


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:

VariableFunction
MD Determines the filter corner of the ADC
CH Determines which cell channels are converted
DCP Determines if Discharge is Permitted

Definition at line 150 of file LTC68042.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.

Definition at line 667 of file LTC68042.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.

Definition at line 628 of file LTC68042.cpp.

◆ LTC6804_initialize()

void LTC6804_initialize ( )

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

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 96 of file LTC68042.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_treg; 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_ttotal_ic; This is the number of ICs in the network
[out]uint8_taux_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 459 of file LTC68042.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_treg; This controls which GPIO voltage register is read back.
     1: Read back auxiliary group A

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

Definition at line 570 of file LTC68042.cpp.

◆ LTC6804_rdcfg()

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


Reads configuration registers of a LTC6804 stack

Parameters
[in]uint8_ttotal_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 798 of file LTC68042.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_treg; 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_ttotal_ic; This is the number of ICs in the network
[out]uint16_tcell_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 257 of file LTC68042.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_treg; 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_ttotal_ic; This is the number of ICs in the network
[out]uint8_t*data; An array of the unparsed cell codes

Definition at line 371 of file LTC68042.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 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_ttotal_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 718 of file LTC68042.cpp.

◆ pec15_calc()

uint16_t pec15_calc ( uint8_t  len,
uint8_t *  data 
)


Calculates and returns the CRC15.

calaculates and returns the CRC15

Parameters
[in]uint8_tlen: the length of the data array being passed to the function
[in]uint8_tdata[] : the array of data that the PEC will be generated from
Returns
The calculated pec15 as an unsigned int16_t
Parameters
lenThe length of the data array being passed to the function
dataThe array of data that the PEC will be generated from

Definition at line 891 of file LTC68042.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_tMD The adc conversion mode
[in]uint8_tDCP Controls if Discharge is permitted during cell conversions
[in]uint8_tCH Determines which cells are measured during an ADC conversion command
[in]uint8_tCHG 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 117 of file LTC68042.cpp.

◆ spi_write_array()

void spi_write_array ( uint8_t  len,
uint8_t  data[] 
)

Writes an array of bytes out of the SPI port.

Parameters
[in]uint8_tlen length of the data array being written on the SPI port
[in]uint8_tdata[] the data array to be written on the SPI port

Definition at line 912 of file LTC68042.cpp.

◆ spi_write_read()

void spi_write_read ( uint8_t  tx_Data[],
uint8_t  tx_len,
uint8_t *  rx_data,
uint8_t  rx_len 
)

Writes and read a set number of bytes using the SPI port.

Parameters
[in]uint8_ttx_data[] array of data to be written on the SPI port
[in]uint8_ttx_len length of the tx_data array
[out]uint8_trx_data array that read data will be written too.
[in]uint8_trx_len number of bytes to be read from the SPI port.

Definition at line 931 of file LTC68042.cpp.

◆ wakeup_idle()

void wakeup_idle ( )


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

Definition at line 862 of file LTC68042.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 874 of file LTC68042.cpp.

Variable Documentation

◆ ADAX

uint8_t ADAX[2]

GPIO conversion command.

Definition at line 86 of file LTC68042.cpp.

◆ ADCV

uint8_t ADCV[2]

6804 conversion command variables.

Cell Voltage conversion command.

Definition at line 85 of file LTC68042.cpp.