![]() |
DC2100A
1.2.0
Bi-Directional Cell Balancer Using the LTC3300-1 and the LTC6804-2
|
API Header File for LTC6804-2 Multicell Battery Monitors. More...
Go to the source code of this file.
API Header File for LTC6804-2 Multicell Battery Monitors.
Definition in file LTC6804-2.h.
Functions | |
void | LTC6804_Init (void) |
Initializes the LTC6804-2 code module. More... | |
BOOLEAN | LTC6804_Revision_Get (int8 board_num, unsigned int8 *revision) |
Gets the LTC6804 revision. More... | |
void | LTC6804_GPIO_Set (int8 board_num, int8 gpio_bitmap) |
Sets the LTC6804 GPIO Pull Downs. More... | |
BOOLEAN | LTC6804_Refon_Get (int8 board_num, int8 *refon) |
Gets the LTC6804 ADC Reference status, where 1 = ON and 0 = OFF. More... | |
void | LTC6804_Refon_Set (int8 board_num, BOOLEAN refon) |
Turns the LTC6804 ADC Reference on and off. More... | |
void | LTC6804_Dischargers_Set (int8 board_num, int16 discharge_bitmap, int16 timeout_value) |
Sets the LTC6804 discharger pin levels and timeout values. More... | |
void | LTC6804_UVOV_Thresholds_Set (int8 board_num, int16 vuv_value, int16 vov_value) |
Sets the LTC6804 under-voltage and over-voltage thresholds in LTC6804_UVOV_RESOLUTION units. More... | |
BOOLEAN | LTC6804_UVOV_Thresholds_Get (int8 board_num, unsigned int16 *vuv_value, unsigned int16 *vov_value) |
Gets the LTC6804 under-voltage and over-voltage thresholds in LTC6804_UVOV_RESOLUTION units. More... | |
BOOLEAN | LTC6804_UVOV_Flags_Get (int8 board_num, int16 *vuv_flags, int16 *vov_flags) |
Gets the LTC6804 flags indicating under-voltage and over-voltage conditions are present. More... | |
void | LTC6804_Cell_ADC_Clear (int8 board_num) |
Clears the LTC6804 Cell Voltage ADC registers. More... | |
void | LTC6804_Cell_ADC_Start (int8 board_num, LTC6804_CONVERSION_MODE_T mode, LTC6804_CH_CELL_TYPE cell_select, BOOLEAN discharge_permitted) |
Starts the LTC6804 Cell Voltage ADC conversion at the specified conversion mode. More... | |
BOOLEAN | LTC6804_Cell_ADC_Read (int8 board_num, LTC6804_CH_CELL_TYPE cell_select, unsigned int16 *adc_value_ptr) |
Reads the LTC6804 Cell Voltage ADC conversion results. More... | |
void | LTC6804_GPIO_ADC_Clear (int8 board_num) |
Clears the LTC6804 GPIO ADC registers. More... | |
void | LTC6804_GPIO_ADC_Start (int8 board_num, LTC6804_CONVERSION_MODE_T mode, LTC6804_CHG_GPIO_TYPE gpio_select) |
Starts the specified LTC6804 GPIO ADC conversion at the specified conversion mode. More... | |
BOOLEAN | LTC6804_GPIO_ADC_Read (int8 board_num, LTC6804_CHG_GPIO_TYPE gpio_select, int16 *adc_value_ptr) |
Reads the specified LTC6804 GPIO ADC conversion results. More... | |
void | LTC6804_I2C_Write (int8 board_num, BOOLEAN start, BOOLEAN stop, int8 *data_ptr, int16 num_bytes, int16 baud_khz) |
Writes a string of bytes to the LTC6804 I2C port implemented on its GPIO pins. More... | |
BOOLEAN | LTC6804_I2C_Read (int8 board_num, BOOLEAN start, BOOLEAN stop, int8 *data_ptr, int16 num_bytes, int16 baud_khz) |
Writes one byte, and then reads a string of bytes to the LTC6804 I2C port implemented on its GPIO pins. More... | |
void | LTC6804_SPI_Write (int8 board_num, BOOLEAN start, BOOLEAN stop, int8 *data_ptr, int16 num_bytes, int16 baud_khz) |
Writes a string of bytes to the LTC6804 SPI port implemented on its GPIO pins. More... | |
BOOLEAN | LTC6804_SPI_Read (int8 board_num, BOOLEAN start, BOOLEAN stop, int8 *data_ptr, int16 num_bytes, int16 baud_khz) |
Writes one byte, and then reads a string of bytes to the LTC6804 SPI port implemented on its GPIO pins. More... | |
unsigned int16 | LTC6804_PEC_Calc (char *data, int length) |
Calculates the LTC6804 CRC over a string of bytes as per datasheet figure 22. More... | |
Macros | |
#define | LTC6804_REGISTER_GROUP_TIME |
LTC6804-2 Driver Properties | |
#define | LTC6804_MAX_BOARDS 16 |
The maximum number of addresses available to the LTC6804-2. More... | |
#define | LTC6804_BROADCAST LTC6804_MAX_BOARDS |
Code for application code to indicate an LTC6804 command is to be broadcast to all boards. More... | |
#define | LTC6804_NUM_CELLV_ADC 12 |
Number of cell voltage ADC measurements. More... | |
#define | LTC6804_NUM_GPIO 5 |
Number of GPIO pins available on LTC6804. More... | |
#define | LTC6804_NUM_AUX_ADC 6 |
Number of auxiliary ADC measurements. More... | |
#define | LTC6804_ADC_CLEAR 0xFFFF |
ADC Value returned when results are cleared, but not retaken. More... | |
Conversion Delays | |
Reference wakeup time from datasheet Electrical Characteristics page 7. Time for ADC results for one channel to be ready, from Table 6 (t1C). Time for ADC results for all channels to be ready, from Table 5 (t6C). | |
#define | LTC6804_TREFUP 4400 |
in us, max reference wakeup time. More... | |
#define | LTC6804_CONVERSION_27KHZ_DELAY 201 |
in us, delay between sampling and reading ADC in 27kHz conversion mode More... | |
#define | LTC6804_CONVERSION_14KHZ_DELAY 230 |
in us, delay between sampling and reading ADC in 14kHz conversion mode More... | |
#define | LTC6804_CONVERSION_7KHZ_DELAY 405 |
in us, delay between sampling and reading ADC in 7kHz conversion mode More... | |
#define | LTC6804_CONVERSION_3KHZ_DELAY 501 |
in us, delay between sampling and reading ADC in 3kHz conversion mode More... | |
#define | LTC6804_CONVERSION_2KHZ_DELAY 754 |
in us, delay between sampling and reading ADC in 2kHz conversion mode More... | |
#define | LTC6804_CONVERSION_26HZ_DELAY 34 |
in ms, delay between sampling and reading ADC in 26Hz conversion mode More... | |
#define | LTC6804_CONVERSIONS_ALL_27KHZ_DELAY 11130 |
in us, delay between sampling and reading ADC in 27kHz conversion mode More... | |
#define | LTC6804_CONVERSIONS_ALL_14KHZ_DELAY 1288 |
in us, delay between sampling and reading ADC in 14kHz conversion mode More... | |
#define | LTC6804_CONVERSIONS_ALL_7KHZ_DELAY 2335 |
in us, delay between sampling and reading ADC in 7kHz conversion mode More... | |
#define | LTC6804_CONVERSIONS_ALL_3KHZ_DELAY 3033 |
in us, delay between sampling and reading ADC in 3kHz conversion mode More... | |
#define | LTC6804_CONVERSIONS_ALL_2KHZ_DELAY 4430 |
in us, delay between sampling and reading ADC in 2kHz conversion mode More... | |
#define | LTC6804_CONVERSIONS_ALL_26HZ_DELAY 202 |
in ms, delay between sampling and reading ADC in 26Hz conversion mode More... | |
Voltage Resolution | |
Voltage resolutions from Table 46 (t6C) | |
#define | LTC6804_VOLTAGE_RESOLUTION 100 |
uV per bit (CxV), cell voltage resolution. More... | |
#define | LTC6804_UVOV_RESOLUTION (16*100) |
uV per bit (VUV and VOV), under-voltage and over-voltage resolution. More... | |
#define | LTC6804_SOC_RESOLUTION (20*100) |
uV per bit (SOC), sum-of-cells resolution. More... | |
#define | LTC6804_V_SUPPLY_VOLTAGE 11000 |
mV per bit, Minimum supply voltage from datasheet page 7. More... | |
Communication Protocol Constants | |
Communication Protocol Message Sizes, not including PEC, as specified by datasheet Table 26. Baud Rate from from datasheet page 8 | |
#define | LTC6804_COMMAND_SIZE 2 |
bytes per command More... | |
#define | LTC6804_REGISTER_GROUP_SIZE 6 |
bytes per register group More... | |
#define | LTC6804_PEC_SIZE sizeof(int16) |
15 bit PEC, requires int16 data type More... | |
#define | LTC6804_ADC_SIZE sizeof(int16) |
16 bit ADC results More... | |
#define | LTC6804_BAUD_RATE 1000 |
in kHz, Max input SPI Frequency (1/tCLK from datasheet) More... | |
#define | LTC6804_COMMAND_TIME |
minimum time necessary to send a command in us More... | |
void LTC6804_Cell_ADC_Clear | ( | int8 | board_num | ) |
Clears the LTC6804 Cell Voltage ADC registers.
This is useful to detect if the conversion was started properly when the results are read.
board_num | The logical address for the PCB containing this LTC6804-2 IC. |
Definition at line 447 of file LTC6804-2.c.
BOOLEAN LTC6804_Cell_ADC_Read | ( | int8 | board_num, |
LTC6804_CH_CELL_TYPE | cell_select, | ||
unsigned int16 * | adc_value_ptr | ||
) |
Reads the LTC6804 Cell Voltage ADC conversion results.
board_num | The logical address for the PCB containing this LTC6804-2 IC. |
cell_select | The cells that were converted. |
adc_value_ptr | Pointer where up to LTC6804_NUM_CELLV_ADC cell voltages will be returned. |
Definition at line 502 of file LTC6804-2.c.
void LTC6804_Cell_ADC_Start | ( | int8 | board_num, |
LTC6804_CONVERSION_MODE_T | mode, | ||
LTC6804_CH_CELL_TYPE | cell_select, | ||
BOOLEAN | discharge_permitted | ||
) |
Starts the LTC6804 Cell Voltage ADC conversion at the specified conversion mode.
Note function always permits discharge.
board_num | The logical address for the PCB containing this LTC6804-2 IC. |
mode | The mode to use for ADC conversion. |
cell_select | The cells to convert. |
discharge_permitted | True if discharge is to be permitted during this cell voltage conversion. |
Definition at line 468 of file LTC6804-2.c.
void LTC6804_Dischargers_Set | ( | int8 | board_num, |
int16 | discharge_bitmap, | ||
int16 | timeout_value | ||
) |
Sets the LTC6804 discharger pin levels and timeout values.
board_num | The logical address for the PCB containing this LTC6804-2 IC. |
discharge_bitmap | bitmap for discharger, bit0 = cell 0. |
timeout_value | timeout value for dischargers. |
Definition at line 256 of file LTC6804-2.c.
void LTC6804_GPIO_ADC_Clear | ( | int8 | board_num | ) |
Clears the LTC6804 GPIO ADC registers.
This is useful to detect if the conversion was started properly when the results are read.
board_num | The logical address for the PCB containing this LTC6804-2 IC. |
Definition at line 578 of file LTC6804-2.c.
BOOLEAN LTC6804_GPIO_ADC_Read | ( | int8 | board_num, |
LTC6804_CHG_GPIO_TYPE | gpio_select, | ||
int16 * | adc_value_ptr | ||
) |
Reads the specified LTC6804 GPIO ADC conversion results.
board_num | The logical address for the PCB containing this LTC6804-2 IC. |
gpio_select | The gpio that was converted. |
adc_value_ptr | Pointer where up to LTC6804_NUM_GPIO GPIO ADC results will be returned. |
Definition at line 633 of file LTC6804-2.c.
void LTC6804_GPIO_ADC_Start | ( | int8 | board_num, |
LTC6804_CONVERSION_MODE_T | mode, | ||
LTC6804_CHG_GPIO_TYPE | gpio_select | ||
) |
Starts the specified LTC6804 GPIO ADC conversion at the specified conversion mode.
board_num | The logical address for the PCB containing this LTC6804-2 IC. |
mode | The mode to use for ADC conversion. |
gpio_select | The gpio to convert from LTC6804_CHG GPIO Selections. |
Definition at line 599 of file LTC6804-2.c.
void LTC6804_GPIO_Set | ( | int8 | board_num, |
int8 | gpio_bitmap | ||
) |
Sets the LTC6804 GPIO Pull Downs.
Write: 0 -> GPIOx Pin Pull-Down ON; 1-> GPIOx Pin Pull-Down OFF
board_num | The logical address for the PCB containing this LTC6804-2 IC. |
gpio_bitmap | bitmap for GPIO pull-downs, bit0 = GPIO 0 |
Definition at line 185 of file LTC6804-2.c.
BOOLEAN LTC6804_I2C_Read | ( | int8 | board_num, |
BOOLEAN | start, | ||
BOOLEAN | stop, | ||
int8 * | data_ptr, | ||
int16 | num_bytes, | ||
int16 | baud_khz | ||
) |
Writes one byte, and then reads a string of bytes to the LTC6804 I2C port implemented on its GPIO pins.
board_num | The logical address for the PCB containing this LTC6804-2 IC. |
start | TRUE if this read would be started by an I2C Start Condition. |
stop | TRUE if this read would be ended with an I2C Stop Condition. |
data_ptr | Pointer to a byte to first write to the I2C Bus, and where to store the data read from the I2C Bus. |
num_bytes | The number of bytes to read to the I2C Bus. |
baud_khz | The baud rate at which the I2C Bus should be clocked. |
Definition at line 763 of file LTC6804-2.c.
void LTC6804_I2C_Write | ( | int8 | board_num, |
BOOLEAN | start, | ||
BOOLEAN | stop, | ||
int8 * | data_ptr, | ||
int16 | num_bytes, | ||
int16 | baud_khz | ||
) |
Writes a string of bytes to the LTC6804 I2C port implemented on its GPIO pins.
board_num | The logical address for the PCB containing this LTC6804-2 IC. |
start | TRUE if this write would be started by an I2C Start Condition. |
stop | TRUE if this write would be ended with an I2C Stop Condition. |
data_ptr | Pointer to the data to write to the I2C Bus. |
num_bytes | The number of bytes to write to the I2C Bus. |
baud_khz | The baud rate at which the I2C Bus should be clocked. |
Definition at line 703 of file LTC6804-2.c.
void LTC6804_Init | ( | void | ) |
unsigned int16 LTC6804_PEC_Calc | ( | char * | data, |
int | length | ||
) |
Calculates the LTC6804 CRC over a string of bytes as per datasheet figure 22.
data | Pointer to the data to over which to calculate the CRC. |
length | The number of bytes over which to calculate the CRC. |
Definition at line 1009 of file LTC6804-2.c.
BOOLEAN LTC6804_Refon_Get | ( | int8 | board_num, |
int8 * | refon | ||
) |
Gets the LTC6804 ADC Reference status, where 1 = ON and 0 = OFF.
board_num | The logical address for the PCB containing this LTC6804-2 IC. |
refon | location where to return the ADC Reference status. |
Definition at line 406 of file LTC6804-2.c.
void LTC6804_Refon_Set | ( | int8 | board_num, |
BOOLEAN | refon | ||
) |
Turns the LTC6804 ADC Reference on and off.
board_num | The logical address for the PCB containing this LTC6804-2 IC. |
refon | TRUE to turn on the reference, FALSE to turn it off. |
Definition at line 206 of file LTC6804-2.c.
BOOLEAN LTC6804_Revision_Get | ( | int8 | board_num, |
unsigned int8 * | revision | ||
) |
Gets the LTC6804 revision.
board_num | The logical address for the PCB containing this LTC6804-2 IC. |
revision | Pointer where to return revision. |
Definition at line 373 of file LTC6804-2.c.
BOOLEAN LTC6804_SPI_Read | ( | int8 | board_num, |
BOOLEAN | start, | ||
BOOLEAN | stop, | ||
int8 * | data_ptr, | ||
int16 | num_bytes, | ||
int16 | baud_khz | ||
) |
Writes one byte, and then reads a string of bytes to the LTC6804 SPI port implemented on its GPIO pins.
board_num | The logical address for the PCB containing this LTC6804-2 IC. |
start | TRUE if the CS should be raised at the start of SPI communication. |
stop | TRUE if the CS should be lowered at the end of SPI communication. |
data_ptr | Pointer to a byte to first write to the SPI Bus, and where to store the data read from the SPI Bus. |
num_bytes | The number of bytes to write to the SPI Bus. |
baud_khz | The baud rate at which the SPI Bus should be clocked. |
Definition at line 912 of file LTC6804-2.c.
void LTC6804_SPI_Write | ( | int8 | board_num, |
BOOLEAN | start, | ||
BOOLEAN | stop, | ||
int8 * | data_ptr, | ||
int16 | num_bytes, | ||
int16 | baud_khz | ||
) |
Writes a string of bytes to the LTC6804 SPI port implemented on its GPIO pins.
board_num | The logical address for the PCB containing this LTC6804-2 IC. |
start | TRUE if the CS should be raised at the start of SPI communication. |
stop | TRUE if the CS should be lowered at the end of SPI communication. |
data_ptr | Pointer to the data to write to the SPI Bus. |
num_bytes | The number of bytes to write to the SPI Bus. |
baud_khz | The baud rate at which the SPI Bus should be clocked. |
Definition at line 861 of file LTC6804-2.c.
BOOLEAN LTC6804_UVOV_Flags_Get | ( | int8 | board_num, |
int16 * | vuv_flags, | ||
int16 * | vov_flags | ||
) |
Gets the LTC6804 flags indicating under-voltage and over-voltage conditions are present.
board_num | The logical address for the PCB containing this LTC6804-2 IC. |
vuv_flags | Pointer where to return under-voltage flags in a bitmap with bit 0 = cell 0. |
vov_flags | Pointer where to return over-voltage flags in a bitmap with bit 0 = cell 0. |
Definition at line 316 of file LTC6804-2.c.
BOOLEAN LTC6804_UVOV_Thresholds_Get | ( | int8 | board_num, |
unsigned int16 * | vuv_value, | ||
unsigned int16 * | vov_value | ||
) |
Gets the LTC6804 under-voltage and over-voltage thresholds in LTC6804_UVOV_RESOLUTION units.
board_num | The logical address for the PCB containing this LTC6804-2 IC. |
vuv_value | Pointer where to return under-voltage value. |
vov_value | Pointer where to return over-voltage value. |
Definition at line 282 of file LTC6804-2.c.
void LTC6804_UVOV_Thresholds_Set | ( | int8 | board_num, |
int16 | vuv_value, | ||
int16 | vov_value | ||
) |
Sets the LTC6804 under-voltage and over-voltage thresholds in LTC6804_UVOV_RESOLUTION units.
board_num | The logical address for the PCB containing this LTC6804-2 IC. |
vuv_value | Under-voltage value. |
vov_value | Over-voltage value. |
Definition at line 230 of file LTC6804-2.c.
#define LTC6804_ADC_CLEAR 0xFFFF |
ADC Value returned when results are cleared, but not retaken.
Definition at line 93 of file LTC6804-2.h.
#define LTC6804_ADC_SIZE sizeof(int16) |
16 bit ADC results
Definition at line 189 of file LTC6804-2.h.
#define LTC6804_BAUD_RATE 1000 |
in kHz, Max input SPI Frequency (1/tCLK from datasheet)
Definition at line 190 of file LTC6804-2.h.
#define LTC6804_BROADCAST LTC6804_MAX_BOARDS |
Code for application code to indicate an LTC6804 command is to be broadcast to all boards.
Definition at line 89 of file LTC6804-2.h.
#define LTC6804_COMMAND_SIZE 2 |
bytes per command
Definition at line 186 of file LTC6804-2.h.
#define LTC6804_COMMAND_TIME |
minimum time necessary to send a command in us
Definition at line 191 of file LTC6804-2.h.
#define LTC6804_CONVERSION_14KHZ_DELAY 230 |
in us, delay between sampling and reading ADC in 14kHz conversion mode
Definition at line 160 of file LTC6804-2.h.
#define LTC6804_CONVERSION_26HZ_DELAY 34 |
in ms, delay between sampling and reading ADC in 26Hz conversion mode
Definition at line 164 of file LTC6804-2.h.
#define LTC6804_CONVERSION_27KHZ_DELAY 201 |
in us, delay between sampling and reading ADC in 27kHz conversion mode
Definition at line 159 of file LTC6804-2.h.
#define LTC6804_CONVERSION_2KHZ_DELAY 754 |
in us, delay between sampling and reading ADC in 2kHz conversion mode
Definition at line 163 of file LTC6804-2.h.
#define LTC6804_CONVERSION_3KHZ_DELAY 501 |
in us, delay between sampling and reading ADC in 3kHz conversion mode
Definition at line 162 of file LTC6804-2.h.
#define LTC6804_CONVERSION_7KHZ_DELAY 405 |
in us, delay between sampling and reading ADC in 7kHz conversion mode
Definition at line 161 of file LTC6804-2.h.
#define LTC6804_CONVERSIONS_ALL_14KHZ_DELAY 1288 |
in us, delay between sampling and reading ADC in 14kHz conversion mode
Definition at line 166 of file LTC6804-2.h.
#define LTC6804_CONVERSIONS_ALL_26HZ_DELAY 202 |
in ms, delay between sampling and reading ADC in 26Hz conversion mode
Definition at line 170 of file LTC6804-2.h.
#define LTC6804_CONVERSIONS_ALL_27KHZ_DELAY 11130 |
in us, delay between sampling and reading ADC in 27kHz conversion mode
Definition at line 165 of file LTC6804-2.h.
#define LTC6804_CONVERSIONS_ALL_2KHZ_DELAY 4430 |
in us, delay between sampling and reading ADC in 2kHz conversion mode
Definition at line 169 of file LTC6804-2.h.
#define LTC6804_CONVERSIONS_ALL_3KHZ_DELAY 3033 |
in us, delay between sampling and reading ADC in 3kHz conversion mode
Definition at line 168 of file LTC6804-2.h.
#define LTC6804_CONVERSIONS_ALL_7KHZ_DELAY 2335 |
in us, delay between sampling and reading ADC in 7kHz conversion mode
Definition at line 167 of file LTC6804-2.h.
#define LTC6804_MAX_BOARDS 16 |
The maximum number of addresses available to the LTC6804-2.
Definition at line 88 of file LTC6804-2.h.
#define LTC6804_NUM_AUX_ADC 6 |
Number of auxiliary ADC measurements.
Definition at line 92 of file LTC6804-2.h.
#define LTC6804_NUM_CELLV_ADC 12 |
Number of cell voltage ADC measurements.
Definition at line 90 of file LTC6804-2.h.
#define LTC6804_NUM_GPIO 5 |
Number of GPIO pins available on LTC6804.
Definition at line 91 of file LTC6804-2.h.
#define LTC6804_PEC_SIZE sizeof(int16) |
15 bit PEC, requires int16 data type
Definition at line 188 of file LTC6804-2.h.
#define LTC6804_REGISTER_GROUP_SIZE 6 |
bytes per register group
Definition at line 187 of file LTC6804-2.h.
#define LTC6804_REGISTER_GROUP_TIME |
#define LTC6804_SOC_RESOLUTION (20*100) |
uV per bit (SOC), sum-of-cells resolution.
Definition at line 178 of file LTC6804-2.h.
#define LTC6804_TREFUP 4400 |
in us, max reference wakeup time.
Definition at line 158 of file LTC6804-2.h.
#define LTC6804_UVOV_RESOLUTION (16*100) |
uV per bit (VUV and VOV), under-voltage and over-voltage resolution.
Definition at line 177 of file LTC6804-2.h.
#define LTC6804_V_SUPPLY_VOLTAGE 11000 |
mV per bit, Minimum supply voltage from datasheet page 7.
Definition at line 179 of file LTC6804-2.h.
#define LTC6804_VOLTAGE_RESOLUTION 100 |
uV per bit (CxV), cell voltage resolution.
Definition at line 176 of file LTC6804-2.h.
enum LTC6804_CH_CELL_TYPE |
Definition at line 99 of file LTC6804-2.h.
Definition at line 114 of file LTC6804-2.h.
enum LTC6804_CHST_TYPE |
Enumerator | |
---|---|
LTC6804_CHST_ALL |
SOC, ITMP, VA, VD. |
LTC6804_CHST_SOC |
SOC. |
LTC6804_CHST_ITMP |
ITMP. |
LTC6804_CHST_VA |
VA. |
LTC6804_CHST_VD |
VD. |
Definition at line 129 of file LTC6804-2.h.
Definition at line 142 of file LTC6804-2.h.