LTC6811

Committer:
roger5641
Date:
Sun Nov 12 01:21:48 2017 +0000
Revision:
0:910d40021983
ver1

Who changed what in which revision?

UserRevisionLine numberNew contents of line
roger5641 0:910d40021983 1 /*!
roger5641 0:910d40021983 2 LTC6811-1: Multicell Battery Monitor
roger5641 0:910d40021983 3
roger5641 0:910d40021983 4 http://www.linear.com/product/LTC6811-1
roger5641 0:910d40021983 5
roger5641 0:910d40021983 6 http://www.linear.com/product/LTC6811-1#demoboards
roger5641 0:910d40021983 7
roger5641 0:910d40021983 8 REVISION HISTORY
roger5641 0:910d40021983 9 $Revision: 7139 $
roger5641 0:910d40021983 10 $Date: 2017-06-01 13:55:14 -0700 (Thu, 01 Jun 2017) $
roger5641 0:910d40021983 11
roger5641 0:910d40021983 12 Copyright (c) 2015, Linear Technology Corp.(LTC)
roger5641 0:910d40021983 13 All rights reserved.
roger5641 0:910d40021983 14
roger5641 0:910d40021983 15 Redistribution and use in source and binary forms, with or without
roger5641 0:910d40021983 16 modification, are permitted provided that the following conditions are met:
roger5641 0:910d40021983 17
roger5641 0:910d40021983 18 1. Redistributions of source code must retain the above copyright notice, this
roger5641 0:910d40021983 19 list of conditions and the following disclaimer.
roger5641 0:910d40021983 20 2. Redistributions in binary form must reproduce the above copyright notice,
roger5641 0:910d40021983 21 this list of conditions and the following disclaimer in the documentation
roger5641 0:910d40021983 22 and/or other materials provided with the distribution.
roger5641 0:910d40021983 23
roger5641 0:910d40021983 24 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
roger5641 0:910d40021983 25 ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
roger5641 0:910d40021983 26 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
roger5641 0:910d40021983 27 DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
roger5641 0:910d40021983 28 ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
roger5641 0:910d40021983 29 (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
roger5641 0:910d40021983 30 LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
roger5641 0:910d40021983 31 ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
roger5641 0:910d40021983 32 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
roger5641 0:910d40021983 33 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
roger5641 0:910d40021983 34
roger5641 0:910d40021983 35 The views and conclusions contained in the software and documentation are those
roger5641 0:910d40021983 36 of the authors and should not be interpreted as representing official policies,
roger5641 0:910d40021983 37 either expressed or implied, of Linear Technology Corp.
roger5641 0:910d40021983 38
roger5641 0:910d40021983 39 The Linear Technology Linduino is not affiliated with the official Arduino team.
roger5641 0:910d40021983 40 However, the Linduino is only possible because of the Arduino team's commitment
roger5641 0:910d40021983 41 to the open-source community. Please, visit http://www.arduino.cc and
roger5641 0:910d40021983 42 http://store.arduino.cc , and consider a purchase that will help fund their
roger5641 0:910d40021983 43 ongoing work.
roger5641 0:910d40021983 44
roger5641 0:910d40021983 45 Copyright 2017 Linear Technology Corp. (LTC)
roger5641 0:910d40021983 46 ***********************************************************/
roger5641 0:910d40021983 47
roger5641 0:910d40021983 48 /*! @file
roger5641 0:910d40021983 49 @ingroup LTC6811-1
roger5641 0:910d40021983 50 Header for LTC6811-1 Multicell Battery Monitor
roger5641 0:910d40021983 51 */
roger5641 0:910d40021983 52
roger5641 0:910d40021983 53 #ifndef LTC6811_H
roger5641 0:910d40021983 54 #define LTC6811_H
roger5641 0:910d40021983 55
roger5641 0:910d40021983 56 #include "LTC681x.h"
roger5641 0:910d40021983 57 #include "mbed.h"
roger5641 0:910d40021983 58 #include "LT_SPI.h"
roger5641 0:910d40021983 59 #include "bms_hardware.h"
roger5641 0:910d40021983 60
roger5641 0:910d40021983 61 #define CELL 1
roger5641 0:910d40021983 62 #define AUX 2
roger5641 0:910d40021983 63 #define STAT 3
roger5641 0:910d40021983 64
roger5641 0:910d40021983 65
roger5641 0:910d40021983 66 void LTC6811_init_reg_limits(uint8_t total_ic, cell_asic ic[]);
roger5641 0:910d40021983 67
roger5641 0:910d40021983 68
roger5641 0:910d40021983 69 /*! Starts the Mux Decoder diagnostic self test
roger5641 0:910d40021983 70
roger5641 0:910d40021983 71 Running this command will start the Mux Decoder Diagnostic Self Test
roger5641 0:910d40021983 72 This test takes roughly 1mS to complete. The MUXFAIL bit will be updated,
roger5641 0:910d40021983 73 the bit will be set to 1 for a failure and 0 if the test has been passed.
roger5641 0:910d40021983 74
roger5641 0:910d40021983 75 */
roger5641 0:910d40021983 76 void LTC6811_diagn();
roger5641 0:910d40021983 77
roger5641 0:910d40021983 78
roger5641 0:910d40021983 79 //! Sends the poll adc command
roger5641 0:910d40021983 80 //! @returns 1 byte read back after a pladc command. If the byte is not 0xFF ADC conversion has completed
roger5641 0:910d40021983 81 uint8_t LTC6811_pladc();
roger5641 0:910d40021983 82
roger5641 0:910d40021983 83
roger5641 0:910d40021983 84 //! This function will block operation until the ADC has finished it's conversion
roger5641 0:910d40021983 85 //! @returns the approximate time it took for the ADC function to complete.
roger5641 0:910d40021983 86 uint32_t LTC6811_pollAdc();
roger5641 0:910d40021983 87
roger5641 0:910d40021983 88 /*! Starts cell voltage conversion
roger5641 0:910d40021983 89 */
roger5641 0:910d40021983 90 void LTC6811_adcv(uint8_t MD, //!< ADC Conversion Mode
roger5641 0:910d40021983 91 uint8_t DCP, //!< Controls if Discharge is permitted during conversion
roger5641 0:910d40021983 92 uint8_t CH //!< Sets which Cell channels are converted
roger5641 0:910d40021983 93 );
roger5641 0:910d40021983 94
roger5641 0:910d40021983 95 /*! Starts cell voltage and GPIO 1&2 conversion
roger5641 0:910d40021983 96 */
roger5641 0:910d40021983 97 void LTC6811_adcvax(
roger5641 0:910d40021983 98 uint8_t MD, //!< ADC Conversion Mode
roger5641 0:910d40021983 99 uint8_t DCP //!< Controls if Discharge is permitted during conversion
roger5641 0:910d40021983 100 );
roger5641 0:910d40021983 101
roger5641 0:910d40021983 102
roger5641 0:910d40021983 103 /*! Starts cell voltage self test conversion
roger5641 0:910d40021983 104 */
roger5641 0:910d40021983 105 void LTC6811_cvst(
roger5641 0:910d40021983 106 uint8_t MD, //!< ADC Conversion Mode
roger5641 0:910d40021983 107 uint8_t ST //!< Self Test Mode
roger5641 0:910d40021983 108 );
roger5641 0:910d40021983 109
roger5641 0:910d40021983 110 /*! Starts cell voltage and SOC conversion
roger5641 0:910d40021983 111 */
roger5641 0:910d40021983 112 void LTC6811_adcvsc(
roger5641 0:910d40021983 113 uint8_t MD, //!< ADC Conversion Mode
roger5641 0:910d40021983 114 uint8_t DCP //!< Controls if Discharge is permitted during conversion
roger5641 0:910d40021983 115 );
roger5641 0:910d40021983 116 /*! Starts cell voltage overlap conversion
roger5641 0:910d40021983 117 */
roger5641 0:910d40021983 118 void LTC6811_adol(
roger5641 0:910d40021983 119 uint8_t MD, //!< ADC Conversion Mode
roger5641 0:910d40021983 120 uint8_t DCP //!< Discharge permitted during conversion
roger5641 0:910d40021983 121 );
roger5641 0:910d40021983 122
roger5641 0:910d40021983 123 /*! Start an open wire Conversion
roger5641 0:910d40021983 124 */
roger5641 0:910d40021983 125 void LTC6811_adow(
roger5641 0:910d40021983 126 uint8_t MD, //!< ADC Conversion Mode
roger5641 0:910d40021983 127 uint8_t PUP //!< Controls if Discharge is permitted during conversion
roger5641 0:910d40021983 128 );
roger5641 0:910d40021983 129
roger5641 0:910d40021983 130
roger5641 0:910d40021983 131 /*! Start a GPIO and Vref2 Conversion
roger5641 0:910d40021983 132 */
roger5641 0:910d40021983 133 void LTC6811_adax(
roger5641 0:910d40021983 134 uint8_t MD, //!< ADC Conversion Mode
roger5641 0:910d40021983 135 uint8_t CHG //!< Sets which GPIO channels are converted
roger5641 0:910d40021983 136 );
roger5641 0:910d40021983 137
roger5641 0:910d40021983 138 /*! Start an GPIO Redundancy test
roger5641 0:910d40021983 139 */
roger5641 0:910d40021983 140 void LTC6811_adaxd(
roger5641 0:910d40021983 141 uint8_t MD, //!< ADC Conversion Mode
roger5641 0:910d40021983 142 uint8_t CHG //!< Sets which GPIO channels are converted
roger5641 0:910d40021983 143 );
roger5641 0:910d40021983 144
roger5641 0:910d40021983 145 /*! Start an Auxiliary Register Self Test Conversion
roger5641 0:910d40021983 146 */
roger5641 0:910d40021983 147 void LTC6811_axst(
roger5641 0:910d40021983 148 uint8_t MD, //!< ADC Conversion Mode
roger5641 0:910d40021983 149 uint8_t ST //!< Sets if self test 1 or 2 is run
roger5641 0:910d40021983 150 );
roger5641 0:910d40021983 151
roger5641 0:910d40021983 152 /*! Start a Status ADC Conversion
roger5641 0:910d40021983 153 */
roger5641 0:910d40021983 154 void LTC6811_adstat(
roger5641 0:910d40021983 155 uint8_t MD, //!< ADC Conversion Mode
roger5641 0:910d40021983 156 uint8_t CHST //!< Sets which Stat channels are converted
roger5641 0:910d40021983 157 );
roger5641 0:910d40021983 158
roger5641 0:910d40021983 159 /*! Start a Status register redundancy test Conversion
roger5641 0:910d40021983 160 */
roger5641 0:910d40021983 161 void LTC6811_adstatd(
roger5641 0:910d40021983 162 uint8_t MD, //!< ADC Mode
roger5641 0:910d40021983 163 uint8_t CHST //!< Sets which Status channels are converted
roger5641 0:910d40021983 164 );
roger5641 0:910d40021983 165
roger5641 0:910d40021983 166
roger5641 0:910d40021983 167 /*! Start a Status Register Self Test Conversion
roger5641 0:910d40021983 168 */
roger5641 0:910d40021983 169 void LTC6811_statst(
roger5641 0:910d40021983 170 uint8_t MD, //!< ADC Conversion Mode
roger5641 0:910d40021983 171 uint8_t ST //!< Sets if self test 1 or 2 is run
roger5641 0:910d40021983 172 );
roger5641 0:910d40021983 173
roger5641 0:910d40021983 174 /*! Reads and parses the LTC6811 cell voltage registers.
roger5641 0:910d40021983 175
roger5641 0:910d40021983 176 @return int8_t, PEC Status.
roger5641 0:910d40021983 177 0: No PEC error detected
roger5641 0:910d40021983 178 -1: PEC error detected, retry read
roger5641 0:910d40021983 179 */
roger5641 0:910d40021983 180 uint8_t LTC6811_rdcv(uint8_t reg, //!< controls which cell voltage register is read back.
roger5641 0:910d40021983 181 uint8_t total_ic, //!< the number of ICs in the daisy chain(-1 only)
roger5641 0:910d40021983 182 cell_asic ic[] //!< array of the parsed cell codes from lowest to highest.
roger5641 0:910d40021983 183 );
roger5641 0:910d40021983 184
roger5641 0:910d40021983 185
roger5641 0:910d40021983 186
roger5641 0:910d40021983 187 /*! Reads and parses the LTC6811 auxiliary registers.
roger5641 0:910d40021983 188 @return int8_t, PEC Status
roger5641 0:910d40021983 189 0: No PEC error detected
roger5641 0:910d40021983 190 -1: PEC error detected, retry read
roger5641 0:910d40021983 191 */
roger5641 0:910d40021983 192 int8_t LTC6811_rdaux(uint8_t reg, //!< controls which GPIO voltage register is read back
roger5641 0:910d40021983 193 uint8_t nIC, //!< the number of ICs in the daisy chain
roger5641 0:910d40021983 194 cell_asic ic[] //!< A two dimensional array of the parsed gpio voltage codes
roger5641 0:910d40021983 195 );
roger5641 0:910d40021983 196
roger5641 0:910d40021983 197 /*! Reads and parses the LTC6811 stat registers.
roger5641 0:910d40021983 198
roger5641 0:910d40021983 199 @return int8_t, PEC Status
roger5641 0:910d40021983 200 0: No PEC error detected
roger5641 0:910d40021983 201 -1: PEC error detected, retry read
roger5641 0:910d40021983 202 */
roger5641 0:910d40021983 203 int8_t LTC6811_rdstat(uint8_t reg, //Determines which Stat register is read back.
roger5641 0:910d40021983 204 uint8_t total_ic,//the number of ICs in the system
roger5641 0:910d40021983 205 cell_asic ic[]
roger5641 0:910d40021983 206 );
roger5641 0:910d40021983 207
roger5641 0:910d40021983 208 /*! Clears the LTC6811 cell voltage registers
roger5641 0:910d40021983 209 */
roger5641 0:910d40021983 210 void LTC6811_clrcell();
roger5641 0:910d40021983 211
roger5641 0:910d40021983 212 /*! Clears the LTC6811 Auxiliary registers
roger5641 0:910d40021983 213 */
roger5641 0:910d40021983 214 void LTC6811_clraux();
roger5641 0:910d40021983 215
roger5641 0:910d40021983 216 /*! Clears the LTC6811 Stat registers
roger5641 0:910d40021983 217 */
roger5641 0:910d40021983 218 void LTC6811_clrstat();
roger5641 0:910d40021983 219
roger5641 0:910d40021983 220 /*! Clears the LTC6811 Sctrl registers
roger5641 0:910d40021983 221 */
roger5641 0:910d40021983 222 void LTC6811_clrsctrl();
roger5641 0:910d40021983 223
roger5641 0:910d40021983 224 /*! Write the LTC6811 configuration register
roger5641 0:910d40021983 225 */
roger5641 0:910d40021983 226 void LTC6811_wrcfg(uint8_t nIC, //!< The number of ICs being written
roger5641 0:910d40021983 227 cell_asic ic[] //!< a two dimensional array of the configuration data that will be written
roger5641 0:910d40021983 228 );
roger5641 0:910d40021983 229
roger5641 0:910d40021983 230 void LTC6811_wrcfgb(uint8_t nIC, //!< The number of ICs being written
roger5641 0:910d40021983 231 cell_asic ic[] //!< a two dimensional array of the configuration data that will be written
roger5641 0:910d40021983 232 );
roger5641 0:910d40021983 233 /*! Reads configuration registers of a LTC6811 daisy chain
roger5641 0:910d40021983 234 @return int8_t, PEC Status.
roger5641 0:910d40021983 235 0: Data read back has matching PEC
roger5641 0:910d40021983 236 -1: Data read back has incorrect PEC
roger5641 0:910d40021983 237 */
roger5641 0:910d40021983 238 int8_t LTC6811_rdcfg(uint8_t nIC, //!< number of ICs in the daisy chain
roger5641 0:910d40021983 239 cell_asic ic[] //!< a two dimensional array that the function stores the read configuration data
roger5641 0:910d40021983 240 );
roger5641 0:910d40021983 241
roger5641 0:910d40021983 242 int8_t LTC6811_rdcfgb(uint8_t nIC, //!< number of ICs in the daisy chain
roger5641 0:910d40021983 243 cell_asic ic[] //!< a two dimensional array that the function stores the read configuration data
roger5641 0:910d40021983 244 );
roger5641 0:910d40021983 245 /*! Write the LTC6811 PWM register
roger5641 0:910d40021983 246 */
roger5641 0:910d40021983 247 void LTC6811_wrpwm(uint8_t nIC, //!< number of ICs in the daisy chain
roger5641 0:910d40021983 248 uint8_t pwmReg,
roger5641 0:910d40021983 249 cell_asic ic[]
roger5641 0:910d40021983 250 );
roger5641 0:910d40021983 251
roger5641 0:910d40021983 252 /*! Reads pwm registers of a LTC6811 daisy chain
roger5641 0:910d40021983 253
roger5641 0:910d40021983 254 */
roger5641 0:910d40021983 255 int8_t LTC6811_rdpwm(uint8_t nIC, //!< number of ICs in the daisy chain
roger5641 0:910d40021983 256 uint8_t pwmReg,
roger5641 0:910d40021983 257 cell_asic ic[] //!< a two dimensional array that the function stores the read pwm data
roger5641 0:910d40021983 258 );
roger5641 0:910d40021983 259
roger5641 0:910d40021983 260 /*! Write the LTC6811 Sctrl register
roger5641 0:910d40021983 261 */
roger5641 0:910d40021983 262 void LTC6811_wrsctrl(uint8_t nIC, //!< number of ICs in the daisy chain
roger5641 0:910d40021983 263 uint8_t sctrl_reg,
roger5641 0:910d40021983 264 cell_asic ic[]
roger5641 0:910d40021983 265 );
roger5641 0:910d40021983 266
roger5641 0:910d40021983 267
roger5641 0:910d40021983 268 /*! Reads sctrl registers of a LTC6811 daisy chain
roger5641 0:910d40021983 269 @return int8_t, PEC Status.
roger5641 0:910d40021983 270 0: Data read back has matching PEC
roger5641 0:910d40021983 271 -1: Data read back has incorrect PEC
roger5641 0:910d40021983 272 */
roger5641 0:910d40021983 273 int8_t LTC6811_rdsctrl(uint8_t nIC, //!< number of ICs in the daisy chain
roger5641 0:910d40021983 274 uint8_t sctrl_reg,
roger5641 0:910d40021983 275 cell_asic ic[] //!< a two dimensional array that the function stores the read pwm data
roger5641 0:910d40021983 276 );
roger5641 0:910d40021983 277
roger5641 0:910d40021983 278
roger5641 0:910d40021983 279 /*! Start Sctrl data communication
roger5641 0:910d40021983 280 This command will start the sctrl pulse communication over the spins
roger5641 0:910d40021983 281 */
roger5641 0:910d40021983 282 void LTC6811_stsctrl();
roger5641 0:910d40021983 283
roger5641 0:910d40021983 284
roger5641 0:910d40021983 285 /*! Write the LTC6811 COMM register
roger5641 0:910d40021983 286 */
roger5641 0:910d40021983 287 void LTC6811_wrcomm(uint8_t total_ic, //!< Number of ICs in the daisy chain
roger5641 0:910d40021983 288 cell_asic ic[] //!< A two dimensional array of the comm data that will be written
roger5641 0:910d40021983 289 );
roger5641 0:910d40021983 290
roger5641 0:910d40021983 291 /*! Reads comm registers of a LTC6811 daisy chain
roger5641 0:910d40021983 292 @return int8_t, PEC Status.
roger5641 0:910d40021983 293
roger5641 0:910d40021983 294 0: Data read back has matching PEC
roger5641 0:910d40021983 295
roger5641 0:910d40021983 296 -1: Data read back has incorrect PEC
roger5641 0:910d40021983 297
roger5641 0:910d40021983 298 */
roger5641 0:910d40021983 299 int8_t LTC6811_rdcomm(uint8_t total_ic, //!< number of ICs in the daisy chain
roger5641 0:910d40021983 300 cell_asic ic[] //!< Two dimensional array that the function stores the read comm data.
roger5641 0:910d40021983 301 );
roger5641 0:910d40021983 302
roger5641 0:910d40021983 303 /*! issues a stcomm command and clocks data out of the COMM register */
roger5641 0:910d40021983 304 void LTC6811_stcomm();
roger5641 0:910d40021983 305
roger5641 0:910d40021983 306
roger5641 0:910d40021983 307 /*! @returns returns the register data pattern for a given ADC MD and Self test */
roger5641 0:910d40021983 308 uint16_t LTC6811_st_lookup(
roger5641 0:910d40021983 309 uint8_t MD, //!< ADC Conversion Mode
roger5641 0:910d40021983 310 uint8_t ST //!< Self test number
roger5641 0:910d40021983 311 );
roger5641 0:910d40021983 312
roger5641 0:910d40021983 313 void LTC6811_set_discharge(int Cell,
roger5641 0:910d40021983 314 uint8_t total_ic,
roger5641 0:910d40021983 315 cell_asic ic[]);
roger5641 0:910d40021983 316
roger5641 0:910d40021983 317 /*! Helper function that runs the ADC Self Tests*/
roger5641 0:910d40021983 318 int16_t LTC6811_run_cell_adc_st(uint8_t adc_reg,
roger5641 0:910d40021983 319 uint8_t total_ic,
roger5641 0:910d40021983 320 cell_asic ic[]);
roger5641 0:910d40021983 321
roger5641 0:910d40021983 322 /*! Helper function that runs the ADC Digital Redudancy commands and checks output for errors*/
roger5641 0:910d40021983 323 int16_t LTC6811_run_adc_redundancy_st(uint8_t adc_mode,
roger5641 0:910d40021983 324 uint8_t adc_reg,
roger5641 0:910d40021983 325 uint8_t total_ic,
roger5641 0:910d40021983 326 cell_asic ic[]);
roger5641 0:910d40021983 327
roger5641 0:910d40021983 328 /*! Helper function that runs the datasheet open wire algorithm*/
roger5641 0:910d40021983 329 void LTC6811_run_openwire(uint8_t total_ic,
roger5641 0:910d40021983 330 cell_asic ic[]);
roger5641 0:910d40021983 331
roger5641 0:910d40021983 332 void LTC6811_set_discharge(int Cell,
roger5641 0:910d40021983 333 uint8_t total_ic,
roger5641 0:910d40021983 334 cell_asic ic[]);
roger5641 0:910d40021983 335
roger5641 0:910d40021983 336 /*! Helper Function that runs the ADC Overlap test*/
roger5641 0:910d40021983 337 uint16_t LTC6811_run_adc_overlap(uint8_t total_ic,
roger5641 0:910d40021983 338 cell_asic ic[]);
roger5641 0:910d40021983 339
roger5641 0:910d40021983 340 /*! Helper Function that counts overall PEC errors and register/IC PEC errors*/
roger5641 0:910d40021983 341 void LTC6811_check_pec(uint8_t total_ic,
roger5641 0:910d40021983 342 uint8_t reg,
roger5641 0:910d40021983 343 cell_asic ic[]);
roger5641 0:910d40021983 344
roger5641 0:910d40021983 345 /*! Helper Function that resets the PEC error counters */
roger5641 0:910d40021983 346 void LTC6811_reset_crc_count(uint8_t total_ic,
roger5641 0:910d40021983 347 cell_asic ic[]);
roger5641 0:910d40021983 348
roger5641 0:910d40021983 349 /*! Helper Function to initialize the CFGR data structures*/
roger5641 0:910d40021983 350 void LTC6811_init_cfg(uint8_t total_ic,
roger5641 0:910d40021983 351 cell_asic ic[]);
roger5641 0:910d40021983 352
roger5641 0:910d40021983 353 /*! Helper function to set appropriate bits in CFGR register based on bit function*/
roger5641 0:910d40021983 354 void LTC6811_set_cfgr(uint8_t nIC,
roger5641 0:910d40021983 355 cell_asic ic[],
roger5641 0:910d40021983 356 bool refon,
roger5641 0:910d40021983 357 bool adcopt,
roger5641 0:910d40021983 358 bool gpio[5],
roger5641 0:910d40021983 359 bool dcc[12]);
roger5641 0:910d40021983 360
roger5641 0:910d40021983 361 /*! Helper function to turn the refon bit HIGH or LOW*/
roger5641 0:910d40021983 362 void LTC6811_set_cfgr_refon(uint8_t nIC,
roger5641 0:910d40021983 363 cell_asic ic[],
roger5641 0:910d40021983 364 bool refon);
roger5641 0:910d40021983 365
roger5641 0:910d40021983 366 /*! Helper function to turn the ADCOPT bit HIGH or LOW*/
roger5641 0:910d40021983 367 void LTC6811_set_cfgr_adcopt(uint8_t nIC,
roger5641 0:910d40021983 368 cell_asic ic[],
roger5641 0:910d40021983 369 bool adcopt);
roger5641 0:910d40021983 370
roger5641 0:910d40021983 371 /*! Helper function to turn the GPIO bits HIGH or LOW*/
roger5641 0:910d40021983 372 void LTC6811_set_cfgr_gpio(uint8_t nIC,
roger5641 0:910d40021983 373 cell_asic ic[],
roger5641 0:910d40021983 374 bool gpio[]);
roger5641 0:910d40021983 375
roger5641 0:910d40021983 376 /*! Helper function to turn the DCC bits HIGH or LOW*/
roger5641 0:910d40021983 377 void LTC6811_set_cfgr_dis(uint8_t nIC,
roger5641 0:910d40021983 378 cell_asic ic[],
roger5641 0:910d40021983 379 bool dcc[]);
roger5641 0:910d40021983 380 /*! Helper function to set uv field in CFGRA register*/
roger5641 0:910d40021983 381 void LTC6811_set_cfgr_uv(uint8_t nIC,
roger5641 0:910d40021983 382 cell_asic ic[],
roger5641 0:910d40021983 383 uint16_t uv);
roger5641 0:910d40021983 384
roger5641 0:910d40021983 385 /*! Helper function to set ov field in CFGRA register*/
roger5641 0:910d40021983 386 void LTC6811_set_cfgr_ov(uint8_t nIC,
roger5641 0:910d40021983 387 cell_asic ic[],
roger5641 0:910d40021983 388 uint16_t ov);
roger5641 0:910d40021983 389
roger5641 0:910d40021983 390 void LTC6811_init_max_min(uint8_t total_ic,
roger5641 0:910d40021983 391 cell_asic ic[],
roger5641 0:910d40021983 392 cell_asic ic_max[],
roger5641 0:910d40021983 393 cell_asic ic_min[]);
roger5641 0:910d40021983 394
roger5641 0:910d40021983 395 void LTC6811_max_min(uint8_t total_ic, cell_asic ic_cells[],
roger5641 0:910d40021983 396 cell_asic ic_min[],
roger5641 0:910d40021983 397 cell_asic ic_max[],
roger5641 0:910d40021983 398 cell_asic ic_delta[]);
roger5641 0:910d40021983 399 #endif