![]() |
Linduino
1.3.0
Linear Technology Arduino-Compatible Demonstration Board
|
General BMS Library. More...
General BMS Library.
Library for LTC681x Multi-cell Battery Monitor.
Copyright 2019(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:
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.
Definition in file LTC681x.cpp.
Go to the source code of this file.
Functions | |
void | wakeup_idle (uint8_t total_ic) |
Wake isoSPI up from IDlE state and enters the READY state. More... | |
void | wakeup_sleep (uint8_t total_ic) |
Wake the LTC681x from the sleep state. More... | |
void | cmd_68 (uint8_t tx_cmd[2]) |
Sends a command to the BMS IC. More... | |
void | write_68 (uint8_t total_ic, uint8_t tx_cmd[2], uint8_t data[]) |
Writes an array of data to the daisy chain. More... | |
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. More... | |
uint16_t | pec15_calc (uint8_t len, uint8_t *data) |
More... | |
void | LTC681x_wrcfg (uint8_t total_ic, cell_asic ic[]) |
void | LTC681x_wrcfgb (uint8_t total_ic, cell_asic ic[]) |
int8_t | LTC681x_rdcfg (uint8_t total_ic, cell_asic ic[]) |
int8_t | LTC681x_rdcfgb (uint8_t total_ic, cell_asic ic[]) |
void | LTC681x_adcv (uint8_t MD, uint8_t DCP, uint8_t CH) |
Starts cell voltage conversion Starts ADC conversions of the LTC681x Cpin inputs. More... | |
void | LTC681x_adax (uint8_t MD, uint8_t CHG) |
Start a GPIO and Vref2 Conversion. More... | |
void | LTC681x_adstat (uint8_t MD, uint8_t CHST) |
Start a Status ADC Conversion. More... | |
void | LTC681x_adcvsc (uint8_t MD, uint8_t DCP) |
Starts cell voltage and SOC conversion. More... | |
void | LTC681x_adcvax (uint8_t MD, uint8_t DCP) |
Starts cell voltage and GPIO 1&2 conversion. More... | |
uint8_t | LTC681x_rdcv (uint8_t reg, uint8_t total_ic, cell_asic *ic) |
Reads and parses the LTC681x cell voltage registers. More... | |
int8_t | LTC681x_rdaux (uint8_t reg, uint8_t total_ic, cell_asic *ic) |
Reads and parses the LTC681x auxiliary registers. More... | |
int8_t | LTC681x_rdstat (uint8_t reg, uint8_t total_ic, cell_asic *ic) |
Reads and parses the LTC681x stat registers. More... | |
void | LTC681x_rdcv_reg (uint8_t reg, uint8_t total_ic, uint8_t *data) |
Reads the raw cell voltage register data. More... | |
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 register and stores the read data in the *data point as a byte array. More... | |
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 stores the read data in the *data point as a byte array. More... | |
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. More... | |
uint8_t | LTC681x_pladc () |
Sends the poll ADC command. More... | |
uint32_t | LTC681x_pollAdc () |
This function will block operation until the ADC has finished it's conversion. More... | |
void | LTC681x_clrcell () |
Clears the LTC681x Cell voltage registers The command clears the cell voltage registers and initializes all values to 1. More... | |
void | LTC681x_clraux () |
Clears the LTC681x Auxiliary registers The command clears the Auxiliary registers and initializes all values to 1. More... | |
void | LTC681x_clrstat () |
Clears the LTC681x Stat registers The command clears the Stat registers and initializes all values to 1. More... | |
void | LTC681x_diagn () |
Starts the Mux Decoder diagnostic self test Running this command will start the Mux Decoder Diagnostic Self Test This test takes roughly 1ms to complete. More... | |
void | LTC681x_cvst (uint8_t MD, uint8_t ST) |
Starts cell voltage self test conversion. More... | |
void | LTC681x_axst (uint8_t MD, uint8_t ST) |
Start an Auxiliary Register Self Test Conversion. More... | |
void | LTC681x_statst (uint8_t MD, uint8_t ST) |
Start a Status Register Self Test Conversion. More... | |
void | LTC681x_adol (uint8_t MD, uint8_t DCP) |
Starts cell voltage overlap conversion. More... | |
void | LTC681x_adaxd (uint8_t MD, uint8_t CHG) |
Start an GPIO Redundancy test. More... | |
void | LTC681x_adstatd (uint8_t MD, uint8_t CHST) |
Start a Status register redundancy test Conversion. More... | |
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. More... | |
uint16_t | LTC681x_run_adc_overlap (uint8_t total_ic, cell_asic *ic) |
Helper Function that runs the ADC Overlap test. More... | |
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. More... | |
uint16_t | LTC681x_st_lookup (uint8_t MD, uint8_t ST, bool adcopt) |
Self Test Helper Function. More... | |
void | LTC681x_adow (uint8_t MD, uint8_t PUP, uint8_t CH, uint8_t DCP) |
Start an open wire Conversion. More... | |
void | LTC681x_axow (uint8_t MD, uint8_t PUP) |
Start GPIOs open wire ADC conversion. More... | |
void | LTC681x_run_openwire_single (uint8_t total_ic, cell_asic ic[]) |
void | LTC681x_run_openwire_multi (uint8_t total_ic, cell_asic ic[]) |
void | LTC681x_run_gpio_openwire (uint8_t total_ic, cell_asic ic[]) |
void | LTC681x_clear_discharge (uint8_t total_ic, cell_asic *ic) |
Helper Function to clear DCC bits in the CFGR Registers. More... | |
void | LTC681x_wrpwm (uint8_t total_ic, uint8_t pwmReg, cell_asic ic[]) |
int8_t | LTC681x_rdpwm (uint8_t total_ic, uint8_t pwmReg, cell_asic ic[]) |
void | LTC681x_wrsctrl (uint8_t total_ic, uint8_t sctrl_reg, cell_asic *ic) |
Write the LTC681x Sctrl register. More... | |
int8_t | LTC681x_rdsctrl (uint8_t total_ic, uint8_t sctrl_reg, cell_asic *ic) |
Reads sctrl registers of a LTC681x daisy chain. More... | |
void | LTC681x_stsctrl () |
Start Sctrl data communication This command will start the sctrl pulse communication over the spins. More... | |
void | LTC681x_clrsctrl () |
Clears the LTC681x SCTRL registers The command clears the SCTRL registers and initializes all values to 0. More... | |
void | LTC681x_wrcomm (uint8_t total_ic, cell_asic ic[]) |
int8_t | LTC681x_rdcomm (uint8_t total_ic, cell_asic ic[]) |
void | LTC681x_stcomm (uint8_t len) |
Issues a stcomm command and clocks data out of the COMM register. More... | |
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. More... | |
void | LTC681x_reset_crc_count (uint8_t total_ic, cell_asic *ic) |
Helper Function that resets the PEC error counters. More... | |
void | LTC681x_init_cfg (uint8_t total_ic, cell_asic *ic) |
Helper Function to initialize the CFGR data structures. More... | |
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. More... | |
void | LTC681x_set_cfgr_refon (uint8_t nIC, cell_asic *ic, bool refon) |
Helper function to turn the REFON bit HIGH or LOW. More... | |
void | LTC681x_set_cfgr_adcopt (uint8_t nIC, cell_asic *ic, bool adcopt) |
Helper function to turn the ADCOPT bit HIGH or LOW. More... | |
void | LTC681x_set_cfgr_gpio (uint8_t nIC, cell_asic *ic, bool gpio[5]) |
void | LTC681x_set_cfgr_dis (uint8_t nIC, cell_asic *ic, bool dcc[12]) |
void | LTC681x_set_cfgr_dcto (uint8_t nIC, cell_asic *ic, bool dcto[4]) |
void | LTC681x_set_cfgr_uv (uint8_t nIC, cell_asic *ic, uint16_t uv) |
Helper function to set uv field in CFGRA register. More... | |
void | LTC681x_set_cfgr_ov (uint8_t nIC, cell_asic *ic, uint16_t ov) |
Helper function to set ov field in CFGRA register. More... | |
void cmd_68 | ( | uint8_t | tx_cmd[2] | ) |
Sends a command to the BMS IC.
This code will calculate the PEC code for the transmitted command
Definition at line 77 of file LTC681x.cpp.
void LTC681x_adax | ( | uint8_t | MD, |
uint8_t | CHG | ||
) |
Start a GPIO and Vref2 Conversion.
MD | ADC Conversion Mode |
CHG | Sets which GPIO channels are converted |
Definition at line 367 of file LTC681x.cpp.
void LTC681x_adaxd | ( | uint8_t | MD, |
uint8_t | CHG | ||
) |
Start an GPIO Redundancy test.
MD | ADC Conversion Mode |
CHG | Sets which GPIO channels are converted |
Definition at line 1038 of file LTC681x.cpp.
void LTC681x_adcv | ( | uint8_t | MD, |
uint8_t | DCP, | ||
uint8_t | CH | ||
) |
Starts cell voltage conversion Starts ADC conversions of the LTC681x Cpin inputs.
The type of ADC conversion executed can be changed by setting the following parameters:
MD | ADC conversion Mode |
DCP | Controls if Discharge is permitted during conversion |
CH | Sets which Cell channels are converted |
Definition at line 350 of file LTC681x.cpp.
void LTC681x_adcvax | ( | uint8_t | MD, |
uint8_t | DCP | ||
) |
Starts cell voltage and GPIO 1&2 conversion.
MD | ADC Conversion Mode |
DCP | Controls if Discharge is permitted during conversion |
Definition at line 415 of file LTC681x.cpp.
void LTC681x_adcvsc | ( | uint8_t | MD, |
uint8_t | DCP | ||
) |
Starts cell voltage and SOC conversion.
MD | ADC Conversion Mode |
DCP | Controls if Discharge is permitted during conversion |
Definition at line 399 of file LTC681x.cpp.
void LTC681x_adol | ( | uint8_t | MD, |
uint8_t | DCP | ||
) |
Starts cell voltage overlap conversion.
MD | ADC Conversion Mode |
DCP | Discharge permitted during conversion |
Definition at line 1022 of file LTC681x.cpp.
void LTC681x_adow | ( | uint8_t | MD, |
uint8_t | PUP, | ||
uint8_t | CH, | ||
uint8_t | DCP | ||
) |
Start an open wire Conversion.
MD | ADC Conversion Mode |
PUP | Pull up/Pull down current |
CH | Channels |
DCP | Discharge Permit |
Definition at line 1292 of file LTC681x.cpp.
void LTC681x_adstat | ( | uint8_t | MD, |
uint8_t | CHST | ||
) |
Start a Status ADC Conversion.
MD | ADC Conversion Mode |
CHST | Sets which Stat channels are converted |
Definition at line 383 of file LTC681x.cpp.
void LTC681x_adstatd | ( | uint8_t | MD, |
uint8_t | CHST | ||
) |
Start a Status register redundancy test Conversion.
MD | ADC Mode |
CHST | Sets which Status channels are converted |
Definition at line 1054 of file LTC681x.cpp.
void LTC681x_axow | ( | uint8_t | MD, |
uint8_t | PUP | ||
) |
Start GPIOs open wire ADC conversion.
MD | ADC Mode |
PUP | Pull up/Pull down current |
Definition at line 1310 of file LTC681x.cpp.
void LTC681x_axst | ( | uint8_t | MD, |
uint8_t | ST | ||
) |
Start an Auxiliary Register Self Test Conversion.
MD | ADC Conversion Mode |
ST | Sets if self test 1 or 2 is run |
Definition at line 990 of file LTC681x.cpp.
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.
total_ic | Number of ICs in the daisy chain |
reg | Type of register |
ic | A two dimensional array that will store the data |
Definition at line 1999 of file LTC681x.cpp.
void LTC681x_clear_discharge | ( | uint8_t | total_ic, |
cell_asic * | ic | ||
) |
Helper Function to clear DCC bits in the CFGR Registers.
total_ic | Number of ICs in the daisy chain |
ic | A two dimensional array that will store the data |
Definition at line 1682 of file LTC681x.cpp.
void LTC681x_clraux | ( | ) |
Clears the LTC681x Auxiliary registers The command clears the Auxiliary registers and initializes all values to 1.
The register will read back hexadecimal 0xFF after the command is sent.
Definition at line 948 of file LTC681x.cpp.
void LTC681x_clrcell | ( | ) |
Clears the LTC681x Cell voltage registers The command clears the cell voltage registers and initializes all values to 1.
The register will read back hexadecimal 0xFF after the command is sent.
Definition at line 937 of file LTC681x.cpp.
void LTC681x_clrsctrl | ( | ) |
Clears the LTC681x SCTRL registers The command clears the SCTRL registers and initializes all values to 0.
The register will read back hexadecimal 0x00 after the command is sent.
Definition at line 1900 of file LTC681x.cpp.
void LTC681x_clrstat | ( | ) |
Clears the LTC681x Stat registers The command clears the Stat registers and initializes all values to 1.
The register will read back hexadecimal 0xFF after the command is sent.
Definition at line 960 of file LTC681x.cpp.
void LTC681x_cvst | ( | uint8_t | MD, |
uint8_t | ST | ||
) |
Starts cell voltage self test conversion.
MD | ADC Conversion Mode |
ST | Sets if self test 1 or 2 is run |
Definition at line 974 of file LTC681x.cpp.
void LTC681x_diagn | ( | ) |
Starts the Mux Decoder diagnostic self test Running this command will start the Mux Decoder Diagnostic Self Test This test takes roughly 1ms to complete.
The MUXFAIL bit will be updated, the bit will be set to 1 for a failure and 0 if the test has been passed.
Definition at line 967 of file LTC681x.cpp.
void LTC681x_init_cfg | ( | uint8_t | total_ic, |
cell_asic * | ic | ||
) |
Helper Function to initialize the CFGR data structures.
total_ic | Number of ICs in the daisy chain |
ic | A two dimensional array that will store the data |
Definition at line 2084 of file LTC681x.cpp.
uint8_t LTC681x_pladc | ( | ) |
Sends the poll ADC command.
Definition at line 878 of file LTC681x.cpp.
uint32_t LTC681x_pollAdc | ( | ) |
This function will block operation until the ADC has finished it's conversion.
Definition at line 899 of file LTC681x.cpp.
int8_t LTC681x_rdaux | ( | uint8_t | reg, |
uint8_t | total_ic, | ||
cell_asic * | ic | ||
) |
Reads and parses the LTC681x auxiliary registers.
The function is used to read the parsed GPIO codes of the LTC681x. This function will send the requested read commands parse the data and store the gpio voltages in the cell_asic structure.
reg | Determines which GPIO voltage register is read back. |
total_ic | the number of ICs in the system |
ic | Array of the parsed aux codes |
Definition at line 498 of file LTC681x.cpp.
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 register and stores the read data in the *data point as a byte array.
This function is rarely used outside of the LTC681x_rdaux() command.
reg | Determines which GPIO voltage register is read back |
total_ic | The number of ICs in the system |
data | Array of the unparsed auxiliary codes |
Definition at line 748 of file LTC681x.cpp.
int8_t LTC681x_rdcfg | ( | uint8_t | total_ic, |
cell_asic | ic[] | ||
) |
Definition at line 264 of file LTC681x.cpp.
int8_t LTC681x_rdcfgb | ( | uint8_t | total_ic, |
cell_asic | ic[] | ||
) |
Definition at line 307 of file LTC681x.cpp.
int8_t LTC681x_rdcomm | ( | uint8_t | total_ic, |
cell_asic | ic[] | ||
) |
Definition at line 1936 of file LTC681x.cpp.
uint8_t LTC681x_rdcv | ( | uint8_t | reg, |
uint8_t | total_ic, | ||
cell_asic * | ic | ||
) |
Reads and parses the LTC681x cell voltage registers.
The function is used to read the cell codes of the LTC681x. This function will send the requested read commands parse the data and store the cell voltages in the cell_asic structure.
reg | Controls which cell voltage register is read back. |
total_ic | The number of ICs in the system |
ic | Array of the parsed cell codes |
Definition at line 436 of file LTC681x.cpp.
void LTC681x_rdcv_reg | ( | uint8_t | reg, |
uint8_t | total_ic, | ||
uint8_t * | data | ||
) |
Reads the raw cell voltage register data.
reg | Determines which cell voltage register is read back |
total_ic | The number of ICs in the |
data | An array of the unparsed cell codes |
Definition at line 694 of file LTC681x.cpp.
int8_t LTC681x_rdpwm | ( | uint8_t | total_ic, |
uint8_t | pwmReg, | ||
cell_asic | ic[] | ||
) |
Definition at line 1738 of file LTC681x.cpp.
int8_t LTC681x_rdsctrl | ( | uint8_t | total_ic, |
uint8_t | sctrl_reg, | ||
cell_asic * | ic | ||
) |
Reads sctrl registers of a LTC681x daisy chain.
total_ic | Number of ICs in the daisy chain |
sctrl_reg | The Sctrl Register to be written A or B |
ic | A two dimensional array that the function stores the read data |
Definition at line 1827 of file LTC681x.cpp.
int8_t LTC681x_rdstat | ( | uint8_t | reg, |
uint8_t | total_ic, | ||
cell_asic * | ic | ||
) |
Reads and parses the LTC681x stat registers.
The function is used to read the parsed status codes of the LTC681x. This function will send the requested read commands parse the data and store the status voltages in the cell_asic structure
reg | Determines which Stat register is read back. |
total_ic | The number of ICs in the system |
ic | Array of the parsed stat codes |
Definition at line 560 of file LTC681x.cpp.
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 stores the read data in the *data point as a byte array.
This function is rarely used outside of the LTC681x_rdstat() command.
reg | Determines which stat register is read back |
total_ic | The number of ICs in the system |
data | Array of the unparsed stat codes |
Definition at line 797 of file LTC681x.cpp.
void LTC681x_reset_crc_count | ( | uint8_t | total_ic, |
cell_asic * | ic | ||
) |
Helper Function that resets the PEC error counters.
total_ic | Number of ICs in the daisy chain |
ic | A two dimensional array that will store the data |
Definition at line 2059 of file LTC681x.cpp.
uint16_t LTC681x_run_adc_overlap | ( | uint8_t | total_ic, |
cell_asic * | ic | ||
) |
Helper Function that runs the ADC Overlap test.
total_ic | Number of ICs in the daisy chain |
ic | A two dimensional array that will store the data |
Definition at line 1158 of file LTC681x.cpp.
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.
adc_mode | ADC Mode |
adc_reg | Type of register |
total_ic | Number of ICs in the daisy chain |
ic | A two dimensional array that will store the data |
Definition at line 1188 of file LTC681x.cpp.
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.
adc_reg | Type of register |
total_ic | Number of ICs in the daisy chain |
ic | A two dimensional array that will store the data |
md | ADC Mode |
adcopt | ADCOPT bit in the configuration register |
Definition at line 1070 of file LTC681x.cpp.
void LTC681x_run_gpio_openwire | ( | uint8_t | total_ic, |
cell_asic | ic[] | ||
) |
Definition at line 1590 of file LTC681x.cpp.
void LTC681x_run_openwire_multi | ( | uint8_t | total_ic, |
cell_asic | ic[] | ||
) |
Definition at line 1416 of file LTC681x.cpp.
void LTC681x_run_openwire_single | ( | uint8_t | total_ic, |
cell_asic | ic[] | ||
) |
Definition at line 1326 of file LTC681x.cpp.
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.
nIC | Current IC |
ic | A two dimensional array that will store the data |
refon | The REFON bit |
adcopt | The ADCOPT bit |
gpio | The GPIO bits |
dcc | The DCC bits |
dcto | The Dcto bits |
uv | The UV value |
ov | The OV value |
Definition at line 2098 of file LTC681x.cpp.
void LTC681x_set_cfgr_adcopt | ( | uint8_t | nIC, |
cell_asic * | ic, | ||
bool | adcopt | ||
) |
Helper function to turn the ADCOPT bit HIGH or LOW.
nIC | Current IC |
ic | A two dimensional array that will store the data |
adcopt | The ADCOPT bit |
Definition at line 2126 of file LTC681x.cpp.
void LTC681x_set_cfgr_dcto | ( | uint8_t | nIC, |
cell_asic * | ic, | ||
bool | dcto[4] | ||
) |
Definition at line 2158 of file LTC681x.cpp.
void LTC681x_set_cfgr_dis | ( | uint8_t | nIC, |
cell_asic * | ic, | ||
bool | dcc[12] | ||
) |
Definition at line 2143 of file LTC681x.cpp.
void LTC681x_set_cfgr_gpio | ( | uint8_t | nIC, |
cell_asic * | ic, | ||
bool | gpio[5] | ||
) |
Definition at line 2133 of file LTC681x.cpp.
void LTC681x_set_cfgr_ov | ( | uint8_t | nIC, |
cell_asic * | ic, | ||
uint16_t | ov | ||
) |
Helper function to set ov field in CFGRA register.
nIC | Current IC |
ic | A two dimensional array that will store the data |
ov | The OV value |
Definition at line 2177 of file LTC681x.cpp.
void LTC681x_set_cfgr_refon | ( | uint8_t | nIC, |
cell_asic * | ic, | ||
bool | refon | ||
) |
Helper function to turn the REFON bit HIGH or LOW.
nIC | Current IC |
ic | A two dimensional array that will store the data |
refon | The REFON bit |
Definition at line 2119 of file LTC681x.cpp.
void LTC681x_set_cfgr_uv | ( | uint8_t | nIC, |
cell_asic * | ic, | ||
uint16_t | uv | ||
) |
Helper function to set uv field in CFGRA register.
nIC | Current IC |
ic | A two dimensional array that will store the data |
uv | The UV value |
Definition at line 2168 of file LTC681x.cpp.
uint16_t LTC681x_st_lookup | ( | uint8_t | MD, |
uint8_t | ST, | ||
bool | adcopt | ||
) |
Self Test Helper Function.
MD | ADC Mode |
ST | Self Test |
adcopt | ADCOPT bit in the configuration register |
Definition at line 1245 of file LTC681x.cpp.
void LTC681x_statst | ( | uint8_t | MD, |
uint8_t | ST | ||
) |
Start a Status Register Self Test Conversion.
MD | ADC Conversion Mode |
ST | Sets if self test 1 or 2 is run |
Definition at line 1006 of file LTC681x.cpp.
void LTC681x_stcomm | ( | uint8_t | len | ) |
Issues a stcomm command and clocks data out of the COMM register.
len | Length of data to be transmitted |
Definition at line 1978 of file LTC681x.cpp.
void LTC681x_stsctrl | ( | ) |
Start Sctrl data communication This command will start the sctrl pulse communication over the spins.
Definition at line 1879 of file LTC681x.cpp.
void LTC681x_wrcfg | ( | uint8_t | total_ic, |
cell_asic | ic[] | ||
) |
Definition at line 204 of file LTC681x.cpp.
void LTC681x_wrcfgb | ( | uint8_t | total_ic, |
cell_asic | ic[] | ||
) |
Definition at line 234 of file LTC681x.cpp.
void LTC681x_wrcomm | ( | uint8_t | total_ic, |
cell_asic | ic[] | ||
) |
Definition at line 1907 of file LTC681x.cpp.
void LTC681x_wrpwm | ( | uint8_t | total_ic, |
uint8_t | pwmReg, | ||
cell_asic | ic[] | ||
) |
Definition at line 1696 of file LTC681x.cpp.
void LTC681x_wrsctrl | ( | uint8_t | total_ic, |
uint8_t | sctrl_reg, | ||
cell_asic * | ic | ||
) |
Write the LTC681x Sctrl register.
total_ic | Number of ICs in the daisy chain |
sctrl_reg | The Sctrl Register to be written A or B |
ic | A two dimensional array that will store the data to be written |
Definition at line 1791 of file LTC681x.cpp.
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.
current_ic | Current IC |
cell_reg | Type of register |
cell_data | Unparsed data |
cell_codes | Parsed data |
ic_pec | PEC error |
Definition at line 833 of file LTC681x.cpp.
uint16_t pec15_calc | ( | uint8_t | len, |
uint8_t * | data | ||
) |
Calculates and returns the CRC15.
calaculates and returns the CRC15
[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 |
calaculates and returns the CRC15
[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 |
len | The length of the data array being passed to the function |
data | The array of data that the PEC will be generated from |
Definition at line 183 of file LTC681x.cpp.
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.
total_ic | Number of ICs in the daisy chain |
tx_cmd | 2 byte array containing the BMS command to be sent |
Definition at line 140 of file LTC681x.cpp.
void wakeup_idle | ( | uint8_t | total_ic | ) |
Wake isoSPI up from IDlE state and enters the READY state.
Definition at line 54 of file LTC681x.cpp.
void wakeup_sleep | ( | uint8_t | total_ic | ) |
Wake the LTC681x from the sleep state.
Definition at line 65 of file LTC681x.cpp.
void write_68 | ( | uint8_t | total_ic, |
uint8_t | tx_cmd[2], | ||
uint8_t | data[] | ||
) |
Writes an array of data to the daisy chain.
total_ic | Number of ICs in the daisy chain |
tx_cmd | 2 byte array containing the BMS command to be sent |
data | Array containing the data to be written to the BMS ICs |
Definition at line 98 of file LTC681x.cpp.