![]() |
DC2100A
1.2.0
Bi-Directional Cell Balancer Using the LTC3300-1 and the LTC6804-2
|
Driver File for LTC6804-2 Multicell Battery Monitors. More...
Go to the source code of this file.
Driver File for LTC6804-2 Multicell Battery Monitors.
Definition in file LTC6804-2.c.
Functions | |
void | ltc6804_wakeup (void) |
void | ltc6804_get_adcopt_and_md (int8 conversion_mode, int8 *adcopt_ptr, int8 *md_ptr) |
void | ltc6804_adc_opt_set (int8 board_num, int8 adcopt) |
void | ltc6804_command_code_send (int16 command_code, BOOLEAN reg_group_command) |
void | ltc6804_register_group_write (int8 *register_group) |
BOOLEAN | ltc6804_register_group_read (int8 *register_group) |
void | ltc6804_cfgr_modify (int8 board_num, int8 *register_mask_ptr, int8 *register_value_ptr) |
void | ltc6804_clock_out (int16 bytes_to_send, int16 baud_khz) |
unsigned int16 | ltc6804_pec_lookup (char data, unsigned int16 remainder) |
void | LTC6804_Init (void) |
Initializes the LTC6804-2 code module. More... | |
void | LTC6804_GPIO_Set (int8 board_num, int8 gpio_bitmap) |
Sets the LTC6804 GPIO Pull Downs. More... | |
void | LTC6804_Refon_Set (int8 board_num, BOOLEAN refon) |
Turns the LTC6804 ADC Reference on and off. 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... | |
void | LTC6804_Dischargers_Set (int8 board_num, int16 discharge_bitmap, int16 timeout_value) |
Sets the LTC6804 discharger pin levels and timeout values. 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... | |
BOOLEAN | LTC6804_Revision_Get (int8 board_num, unsigned int8 *revision) |
Gets the LTC6804 revision. 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_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_TWAKE 300 |
#define | LTC6804_TSLEEP 1800 |
#define | LTC6804_TREADY 10 |
#define | LTC6804_TIDLE 4300 |
#define | LTC6804_TDWELL 1 |
#define | LTC6804_NUM_CELLV_ADC_PER_REGISTER_GROUP (LTC6804_REGISTER_GROUP_SIZE / LTC6804_ADC_SIZE) |
#define | LTC6804_NUM_REGISTER_GROUP_READS_FOR_ALL_CELLV (LTC6804_NUM_CELLV_ADC / LTC6804_NUM_CELLV_ADC_PER_REGISTER_GROUP) |
#define | LTC6804_NUM_REGISTER_GROUP_READS_FOR_TWO_CELLV (2) |
#define | LTC6804_NUM_AUX_ADC_PER_REGISTER_GROUP (LTC6804_REGISTER_GROUP_SIZE / LTC6804_ADC_SIZE) |
#define | LTC6804_NUM_COMM_BYTES_PER_REGISTER_GROUP 3 |
#define | LTC6804_SPI_CLOCK_CYCLES_PER_STCOMM_BYTE 24 |
#define | LTC6804_SPI_BYTES_PER_STCOMM_BYTE (LTC6804_SPI_CLOCK_CYCLES_PER_STCOMM_BYTE/BITS_PER_BYTE) |
#define | LTC6804_BAUD_RATE_DIVISOR 2 |
Variables | |
const unsigned int16 | ltc6804_pec_seed_value = 16 |
const unsigned int16 | ltc6804_pec_table [256] |
unsigned int8 | ltc6804_gpio_pulldown |
int8 | ltc6804_adcopt |
unsigned int32 | ltc6804_wakeup_timestamp |
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.
const unsigned int16 ltc6804_pec_table[256] |
Definition at line 118 of file LTC6804-2.c.