LTC681x
LTC681x.h@0:c1ea93720ab4, 2017-11-12 (annotated)
- Committer:
- roger5641
- Date:
- Sun Nov 12 01:21:42 2017 +0000
- Revision:
- 0:c1ea93720ab4
ver1
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
roger5641 | 0:c1ea93720ab4 | 1 | /************************************ |
roger5641 | 0:c1ea93720ab4 | 2 | REVISION HISTORY |
roger5641 | 0:c1ea93720ab4 | 3 | $Revision: 7139 $ |
roger5641 | 0:c1ea93720ab4 | 4 | $Date: 2017-4-4 |
roger5641 | 0:c1ea93720ab4 | 5 | |
roger5641 | 0:c1ea93720ab4 | 6 | Copyright (c) 2017, Linear Technology Corp.(LTC) |
roger5641 | 0:c1ea93720ab4 | 7 | All rights reserved. |
roger5641 | 0:c1ea93720ab4 | 8 | |
roger5641 | 0:c1ea93720ab4 | 9 | Redistribution and use in source and binary forms, with or without |
roger5641 | 0:c1ea93720ab4 | 10 | modification, are permitted provided that the following conditions are met: |
roger5641 | 0:c1ea93720ab4 | 11 | |
roger5641 | 0:c1ea93720ab4 | 12 | 1. Redistributions of source code must retain the above copyright notice, this |
roger5641 | 0:c1ea93720ab4 | 13 | list of conditions and the following disclaimer. |
roger5641 | 0:c1ea93720ab4 | 14 | 2. Redistributions in binary form must reproduce the above copyright notice, |
roger5641 | 0:c1ea93720ab4 | 15 | this list of conditions and the following disclaimer in the documentation |
roger5641 | 0:c1ea93720ab4 | 16 | and/or other materials provided with the distribution. |
roger5641 | 0:c1ea93720ab4 | 17 | |
roger5641 | 0:c1ea93720ab4 | 18 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND |
roger5641 | 0:c1ea93720ab4 | 19 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
roger5641 | 0:c1ea93720ab4 | 20 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
roger5641 | 0:c1ea93720ab4 | 21 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR |
roger5641 | 0:c1ea93720ab4 | 22 | ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
roger5641 | 0:c1ea93720ab4 | 23 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
roger5641 | 0:c1ea93720ab4 | 24 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND |
roger5641 | 0:c1ea93720ab4 | 25 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
roger5641 | 0:c1ea93720ab4 | 26 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
roger5641 | 0:c1ea93720ab4 | 27 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
roger5641 | 0:c1ea93720ab4 | 28 | |
roger5641 | 0:c1ea93720ab4 | 29 | The views and conclusions contained in the software and documentation are those |
roger5641 | 0:c1ea93720ab4 | 30 | of the authors and should not be interpreted as representing official policies, |
roger5641 | 0:c1ea93720ab4 | 31 | either expressed or implied, of Linear Technology Corp. |
roger5641 | 0:c1ea93720ab4 | 32 | |
roger5641 | 0:c1ea93720ab4 | 33 | The Linear Technology Linduino is not affiliated with the official Arduino team. |
roger5641 | 0:c1ea93720ab4 | 34 | However, the Linduino is only possible because of the Arduino team's commitment |
roger5641 | 0:c1ea93720ab4 | 35 | to the open-source community. Please, visit http://www.arduino.cc and |
roger5641 | 0:c1ea93720ab4 | 36 | http://store.arduino.cc , and consider a purchase that will help fund their |
roger5641 | 0:c1ea93720ab4 | 37 | ongoing work. |
roger5641 | 0:c1ea93720ab4 | 38 | |
roger5641 | 0:c1ea93720ab4 | 39 | Copyright 2015 Linear Technology Corp. (LTC) |
roger5641 | 0:c1ea93720ab4 | 40 | ***********************************************************/ |
roger5641 | 0:c1ea93720ab4 | 41 | |
roger5641 | 0:c1ea93720ab4 | 42 | #ifndef LTC681X_H |
roger5641 | 0:c1ea93720ab4 | 43 | #define LTC681X_H |
roger5641 | 0:c1ea93720ab4 | 44 | |
roger5641 | 0:c1ea93720ab4 | 45 | #include "mbed.h" |
roger5641 | 0:c1ea93720ab4 | 46 | #include "bms_hardware.h" |
roger5641 | 0:c1ea93720ab4 | 47 | #include "LT_SPI.h" |
roger5641 | 0:c1ea93720ab4 | 48 | |
roger5641 | 0:c1ea93720ab4 | 49 | #define IC_LTC6811 |
roger5641 | 0:c1ea93720ab4 | 50 | |
roger5641 | 0:c1ea93720ab4 | 51 | #define MD_422HZ_1KHZ 0 |
roger5641 | 0:c1ea93720ab4 | 52 | #define MD_27KHZ_14KHZ 1 |
roger5641 | 0:c1ea93720ab4 | 53 | #define MD_7KHZ_3KHZ 2 |
roger5641 | 0:c1ea93720ab4 | 54 | #define MD_26HZ_2KHZ 3 |
roger5641 | 0:c1ea93720ab4 | 55 | |
roger5641 | 0:c1ea93720ab4 | 56 | #define ADC_OPT_ENABLED 1 |
roger5641 | 0:c1ea93720ab4 | 57 | #define ADC_OPT_DISABLED 0 |
roger5641 | 0:c1ea93720ab4 | 58 | |
roger5641 | 0:c1ea93720ab4 | 59 | #define CELL_CH_ALL 0 |
roger5641 | 0:c1ea93720ab4 | 60 | #define CELL_CH_1and7 1 |
roger5641 | 0:c1ea93720ab4 | 61 | #define CELL_CH_2and8 2 |
roger5641 | 0:c1ea93720ab4 | 62 | #define CELL_CH_3and9 3 |
roger5641 | 0:c1ea93720ab4 | 63 | #define CELL_CH_4and10 4 |
roger5641 | 0:c1ea93720ab4 | 64 | #define CELL_CH_5and11 5 |
roger5641 | 0:c1ea93720ab4 | 65 | #define CELL_CH_6and12 6 |
roger5641 | 0:c1ea93720ab4 | 66 | |
roger5641 | 0:c1ea93720ab4 | 67 | #define SELFTEST_1 1 |
roger5641 | 0:c1ea93720ab4 | 68 | #define SELFTEST_2 2 |
roger5641 | 0:c1ea93720ab4 | 69 | |
roger5641 | 0:c1ea93720ab4 | 70 | #define AUX_CH_ALL 0 |
roger5641 | 0:c1ea93720ab4 | 71 | #define AUX_CH_GPIO1 1 |
roger5641 | 0:c1ea93720ab4 | 72 | #define AUX_CH_GPIO2 2 |
roger5641 | 0:c1ea93720ab4 | 73 | #define AUX_CH_GPIO3 3 |
roger5641 | 0:c1ea93720ab4 | 74 | #define AUX_CH_GPIO4 4 |
roger5641 | 0:c1ea93720ab4 | 75 | #define AUX_CH_GPIO5 5 |
roger5641 | 0:c1ea93720ab4 | 76 | #define AUX_CH_VREF2 6 |
roger5641 | 0:c1ea93720ab4 | 77 | |
roger5641 | 0:c1ea93720ab4 | 78 | #define STAT_CH_ALL 0 |
roger5641 | 0:c1ea93720ab4 | 79 | #define STAT_CH_SOC 1 |
roger5641 | 0:c1ea93720ab4 | 80 | #define STAT_CH_ITEMP 2 |
roger5641 | 0:c1ea93720ab4 | 81 | #define STAT_CH_VREGA 3 |
roger5641 | 0:c1ea93720ab4 | 82 | #define STAT_CH_VREGD 4 |
roger5641 | 0:c1ea93720ab4 | 83 | |
roger5641 | 0:c1ea93720ab4 | 84 | #define DCP_DISABLED 0 |
roger5641 | 0:c1ea93720ab4 | 85 | #define DCP_ENABLED 1 |
roger5641 | 0:c1ea93720ab4 | 86 | |
roger5641 | 0:c1ea93720ab4 | 87 | #define PULL_UP_CURRENT 1 |
roger5641 | 0:c1ea93720ab4 | 88 | #define PULL_DOWN_CURRENT 0 |
roger5641 | 0:c1ea93720ab4 | 89 | |
roger5641 | 0:c1ea93720ab4 | 90 | #define NUM_RX_BYT 8 |
roger5641 | 0:c1ea93720ab4 | 91 | #define CELL 1 |
roger5641 | 0:c1ea93720ab4 | 92 | #define AUX 2 |
roger5641 | 0:c1ea93720ab4 | 93 | #define STAT 3 |
roger5641 | 0:c1ea93720ab4 | 94 | #define CFGR 0 |
roger5641 | 0:c1ea93720ab4 | 95 | #define CFGRB 4 |
roger5641 | 0:c1ea93720ab4 | 96 | DigitalOut CS_PIN(A3); //chip select |
roger5641 | 0:c1ea93720ab4 | 97 | |
roger5641 | 0:c1ea93720ab4 | 98 | |
roger5641 | 0:c1ea93720ab4 | 99 | //! Cell Voltage data structure. |
roger5641 | 0:c1ea93720ab4 | 100 | typedef struct |
roger5641 | 0:c1ea93720ab4 | 101 | { |
roger5641 | 0:c1ea93720ab4 | 102 | uint16_t c_codes[18];//!< Cell Voltage Codes |
roger5641 | 0:c1ea93720ab4 | 103 | uint8_t pec_match[6];//!< If a PEC error was detected during most recent read cmd |
roger5641 | 0:c1ea93720ab4 | 104 | } cv; |
roger5641 | 0:c1ea93720ab4 | 105 | |
roger5641 | 0:c1ea93720ab4 | 106 | //! AUX Reg Voltage Data |
roger5641 | 0:c1ea93720ab4 | 107 | typedef struct |
roger5641 | 0:c1ea93720ab4 | 108 | { |
roger5641 | 0:c1ea93720ab4 | 109 | uint16_t a_codes[9];//!< Aux Voltage Codes |
roger5641 | 0:c1ea93720ab4 | 110 | uint8_t pec_match[4];//!< If a PEC error was detected during most recent read cmd |
roger5641 | 0:c1ea93720ab4 | 111 | } ax; |
roger5641 | 0:c1ea93720ab4 | 112 | |
roger5641 | 0:c1ea93720ab4 | 113 | typedef struct |
roger5641 | 0:c1ea93720ab4 | 114 | { |
roger5641 | 0:c1ea93720ab4 | 115 | uint16_t stat_codes[4];//!< A two dimensional array of the stat voltage codes. |
roger5641 | 0:c1ea93720ab4 | 116 | uint8_t flags[3]; //!< byte array that contains the uv/ov flag data |
roger5641 | 0:c1ea93720ab4 | 117 | uint8_t mux_fail[1]; //!< Mux self test status flag |
roger5641 | 0:c1ea93720ab4 | 118 | uint8_t thsd[1]; //!< Thermal shutdown status |
roger5641 | 0:c1ea93720ab4 | 119 | uint8_t pec_match[2];//!< If a PEC error was detected during most recent read cmd |
roger5641 | 0:c1ea93720ab4 | 120 | } st; |
roger5641 | 0:c1ea93720ab4 | 121 | |
roger5641 | 0:c1ea93720ab4 | 122 | typedef struct |
roger5641 | 0:c1ea93720ab4 | 123 | { |
roger5641 | 0:c1ea93720ab4 | 124 | uint8_t tx_data[6]; |
roger5641 | 0:c1ea93720ab4 | 125 | uint8_t rx_data[8]; |
roger5641 | 0:c1ea93720ab4 | 126 | uint8_t rx_pec_match;//!< If a PEC error was detected during most recent read cmd |
roger5641 | 0:c1ea93720ab4 | 127 | } ic_register; |
roger5641 | 0:c1ea93720ab4 | 128 | |
roger5641 | 0:c1ea93720ab4 | 129 | typedef struct |
roger5641 | 0:c1ea93720ab4 | 130 | { |
roger5641 | 0:c1ea93720ab4 | 131 | uint16_t pec_count; |
roger5641 | 0:c1ea93720ab4 | 132 | uint16_t cfgr_pec; |
roger5641 | 0:c1ea93720ab4 | 133 | uint16_t cell_pec[6]; |
roger5641 | 0:c1ea93720ab4 | 134 | uint16_t aux_pec[4]; |
roger5641 | 0:c1ea93720ab4 | 135 | uint16_t stat_pec[2]; |
roger5641 | 0:c1ea93720ab4 | 136 | } pec_counter; |
roger5641 | 0:c1ea93720ab4 | 137 | |
roger5641 | 0:c1ea93720ab4 | 138 | typedef struct |
roger5641 | 0:c1ea93720ab4 | 139 | { |
roger5641 | 0:c1ea93720ab4 | 140 | uint8_t cell_channels; |
roger5641 | 0:c1ea93720ab4 | 141 | uint8_t stat_channels; |
roger5641 | 0:c1ea93720ab4 | 142 | uint8_t aux_channels; |
roger5641 | 0:c1ea93720ab4 | 143 | uint8_t num_cv_reg; |
roger5641 | 0:c1ea93720ab4 | 144 | uint8_t num_gpio_reg; |
roger5641 | 0:c1ea93720ab4 | 145 | uint8_t num_stat_reg; |
roger5641 | 0:c1ea93720ab4 | 146 | } register_cfg; |
roger5641 | 0:c1ea93720ab4 | 147 | |
roger5641 | 0:c1ea93720ab4 | 148 | typedef struct |
roger5641 | 0:c1ea93720ab4 | 149 | { |
roger5641 | 0:c1ea93720ab4 | 150 | |
roger5641 | 0:c1ea93720ab4 | 151 | ic_register config; |
roger5641 | 0:c1ea93720ab4 | 152 | ic_register configb; |
roger5641 | 0:c1ea93720ab4 | 153 | cv cells; |
roger5641 | 0:c1ea93720ab4 | 154 | ax aux; |
roger5641 | 0:c1ea93720ab4 | 155 | st stat; |
roger5641 | 0:c1ea93720ab4 | 156 | ic_register com; |
roger5641 | 0:c1ea93720ab4 | 157 | ic_register pwm; |
roger5641 | 0:c1ea93720ab4 | 158 | ic_register pwmb; |
roger5641 | 0:c1ea93720ab4 | 159 | ic_register sctrl; |
roger5641 | 0:c1ea93720ab4 | 160 | ic_register sctrlb; |
roger5641 | 0:c1ea93720ab4 | 161 | bool isospi_reverse; |
roger5641 | 0:c1ea93720ab4 | 162 | pec_counter crc_count; |
roger5641 | 0:c1ea93720ab4 | 163 | register_cfg ic_reg; |
roger5641 | 0:c1ea93720ab4 | 164 | long system_open_wire; |
roger5641 | 0:c1ea93720ab4 | 165 | } cell_asic; |
roger5641 | 0:c1ea93720ab4 | 166 | |
roger5641 | 0:c1ea93720ab4 | 167 | |
roger5641 | 0:c1ea93720ab4 | 168 | |
roger5641 | 0:c1ea93720ab4 | 169 | |
roger5641 | 0:c1ea93720ab4 | 170 | /*! calculates and returns the CRC15 |
roger5641 | 0:c1ea93720ab4 | 171 | @returns The calculated pec15 as an unsigned int |
roger5641 | 0:c1ea93720ab4 | 172 | */ |
roger5641 | 0:c1ea93720ab4 | 173 | uint16_t pec15_calc(uint8_t len, //!< the length of the data array being passed to the function |
roger5641 | 0:c1ea93720ab4 | 174 | uint8_t *data //!< the array of data that the PEC will be generated from |
roger5641 | 0:c1ea93720ab4 | 175 | ); |
roger5641 | 0:c1ea93720ab4 | 176 | |
roger5641 | 0:c1ea93720ab4 | 177 | /*! Wake isoSPI up from idle state */ |
roger5641 | 0:c1ea93720ab4 | 178 | void wakeup_idle(uint8_t total_ic);//!< number of ICs in the daisy chain |
roger5641 | 0:c1ea93720ab4 | 179 | |
roger5641 | 0:c1ea93720ab4 | 180 | /*! Wake the LTC6813 from the sleep state */ |
roger5641 | 0:c1ea93720ab4 | 181 | void wakeup_sleep(uint8_t total_ic); //!< number of ICs in the daisy chain |
roger5641 | 0:c1ea93720ab4 | 182 | |
roger5641 | 0:c1ea93720ab4 | 183 | /*! Sense a command to the bms IC. This code will calculate the PEC code for the transmitted command*/ |
roger5641 | 0:c1ea93720ab4 | 184 | void cmd_68(uint8_t tx_cmd[2]); //!< 2 Byte array containing the BMS command to be sent |
roger5641 | 0:c1ea93720ab4 | 185 | |
roger5641 | 0:c1ea93720ab4 | 186 | //! Writes an array of data to the daisy chain |
roger5641 | 0:c1ea93720ab4 | 187 | void write_68(uint8_t total_ic , //!< number of ICs in the daisy chain |
roger5641 | 0:c1ea93720ab4 | 188 | uint8_t tx_cmd[2], //!< 2 Byte array containing the BMS command to be sent |
roger5641 | 0:c1ea93720ab4 | 189 | uint8_t data[] //!< Array containing the data to be written to the BMS ICs |
roger5641 | 0:c1ea93720ab4 | 190 | ); |
roger5641 | 0:c1ea93720ab4 | 191 | //! Issues a command onto the daisy chain and reads back 6*total_ic data in the rx_data array |
roger5641 | 0:c1ea93720ab4 | 192 | int8_t read_68( uint8_t total_ic, //!< number of ICs in the daisy chain |
roger5641 | 0:c1ea93720ab4 | 193 | uint8_t tx_cmd[2], //!< 2 Byte array containing the BMS command to be sent |
roger5641 | 0:c1ea93720ab4 | 194 | uint8_t *rx_data); //!< Array that the read back data will be stored. |
roger5641 | 0:c1ea93720ab4 | 195 | |
roger5641 | 0:c1ea93720ab4 | 196 | /*! Starts the Mux Decoder diagnostic self test |
roger5641 | 0:c1ea93720ab4 | 197 | |
roger5641 | 0:c1ea93720ab4 | 198 | Running this command will start the Mux Decoder Diagnostic Self Test |
roger5641 | 0:c1ea93720ab4 | 199 | This test takes roughly 1mS to complete. The MUXFAIL bit will be updated, |
roger5641 | 0:c1ea93720ab4 | 200 | the bit will be set to 1 for a failure and 0 if the test has been passed. |
roger5641 | 0:c1ea93720ab4 | 201 | */ |
roger5641 | 0:c1ea93720ab4 | 202 | void LTC681x_diagn(); |
roger5641 | 0:c1ea93720ab4 | 203 | |
roger5641 | 0:c1ea93720ab4 | 204 | //! Sends the poll adc command |
roger5641 | 0:c1ea93720ab4 | 205 | //! @returns 1 byte read back after a pladc command. If the byte is not 0xFF ADC conversion has completed |
roger5641 | 0:c1ea93720ab4 | 206 | uint8_t LTC681x_pladc(); |
roger5641 | 0:c1ea93720ab4 | 207 | |
roger5641 | 0:c1ea93720ab4 | 208 | //! This function will block operation until the ADC has finished it's conversion |
roger5641 | 0:c1ea93720ab4 | 209 | //! @returns the approximate time it took for the ADC function to complete. |
roger5641 | 0:c1ea93720ab4 | 210 | uint32_t LTC681x_pollAdc(); |
roger5641 | 0:c1ea93720ab4 | 211 | |
roger5641 | 0:c1ea93720ab4 | 212 | /*! Starts cell voltage conversion |
roger5641 | 0:c1ea93720ab4 | 213 | |
roger5641 | 0:c1ea93720ab4 | 214 | Starts ADC conversions of the LTC6811 Cpin inputs. |
roger5641 | 0:c1ea93720ab4 | 215 | The type of ADC conversion executed can be changed by setting the following parameters: |
roger5641 | 0:c1ea93720ab4 | 216 | */ |
roger5641 | 0:c1ea93720ab4 | 217 | void LTC681x_adcv(uint8_t MD, //!< ADC Conversion Mode |
roger5641 | 0:c1ea93720ab4 | 218 | uint8_t DCP, //!< Controls if Discharge is permitted during conversion |
roger5641 | 0:c1ea93720ab4 | 219 | uint8_t CH //!< Sets which Cell channels are converted |
roger5641 | 0:c1ea93720ab4 | 220 | ); |
roger5641 | 0:c1ea93720ab4 | 221 | |
roger5641 | 0:c1ea93720ab4 | 222 | /*! Starts cell voltage and GPIO 1&2 conversion |
roger5641 | 0:c1ea93720ab4 | 223 | */ |
roger5641 | 0:c1ea93720ab4 | 224 | void LTC681x_adcvax( |
roger5641 | 0:c1ea93720ab4 | 225 | uint8_t MD, //!< ADC Conversion Mode |
roger5641 | 0:c1ea93720ab4 | 226 | uint8_t DCP //!< Controls if Discharge is permitted during conversion |
roger5641 | 0:c1ea93720ab4 | 227 | ); |
roger5641 | 0:c1ea93720ab4 | 228 | |
roger5641 | 0:c1ea93720ab4 | 229 | |
roger5641 | 0:c1ea93720ab4 | 230 | /*! Starts cell voltage self test conversion |
roger5641 | 0:c1ea93720ab4 | 231 | */ |
roger5641 | 0:c1ea93720ab4 | 232 | void LTC681x_cvst( |
roger5641 | 0:c1ea93720ab4 | 233 | uint8_t MD, //!< ADC Conversion Mode |
roger5641 | 0:c1ea93720ab4 | 234 | uint8_t ST //!< Self Test Mode |
roger5641 | 0:c1ea93720ab4 | 235 | ); |
roger5641 | 0:c1ea93720ab4 | 236 | |
roger5641 | 0:c1ea93720ab4 | 237 | /*! Starts cell voltage and SOC conversion |
roger5641 | 0:c1ea93720ab4 | 238 | */ |
roger5641 | 0:c1ea93720ab4 | 239 | void LTC681x_adcvsc( |
roger5641 | 0:c1ea93720ab4 | 240 | uint8_t MD, //!< ADC Conversion Mode |
roger5641 | 0:c1ea93720ab4 | 241 | uint8_t DCP //!< Controls if Discharge is permitted during conversion |
roger5641 | 0:c1ea93720ab4 | 242 | ); |
roger5641 | 0:c1ea93720ab4 | 243 | /*! Starts cell voltage overlap conversion |
roger5641 | 0:c1ea93720ab4 | 244 | */ |
roger5641 | 0:c1ea93720ab4 | 245 | void LTC681x_adol( |
roger5641 | 0:c1ea93720ab4 | 246 | uint8_t MD, //!< ADC Conversion Mode |
roger5641 | 0:c1ea93720ab4 | 247 | uint8_t DCP //!< Discharge permitted during conversion |
roger5641 | 0:c1ea93720ab4 | 248 | ); |
roger5641 | 0:c1ea93720ab4 | 249 | |
roger5641 | 0:c1ea93720ab4 | 250 | /*! Start an open wire Conversion |
roger5641 | 0:c1ea93720ab4 | 251 | */ |
roger5641 | 0:c1ea93720ab4 | 252 | void LTC681x_adow( |
roger5641 | 0:c1ea93720ab4 | 253 | uint8_t MD, //!< ADC Conversion Mode |
roger5641 | 0:c1ea93720ab4 | 254 | uint8_t PUP //!< Controls if Discharge is permitted during conversion |
roger5641 | 0:c1ea93720ab4 | 255 | ); |
roger5641 | 0:c1ea93720ab4 | 256 | |
roger5641 | 0:c1ea93720ab4 | 257 | |
roger5641 | 0:c1ea93720ab4 | 258 | /*! Start a GPIO and Vref2 Conversion |
roger5641 | 0:c1ea93720ab4 | 259 | */ |
roger5641 | 0:c1ea93720ab4 | 260 | void LTC681x_adax( |
roger5641 | 0:c1ea93720ab4 | 261 | uint8_t MD, //!< ADC Conversion Mode |
roger5641 | 0:c1ea93720ab4 | 262 | uint8_t CHG //!< Sets which GPIO channels are converted |
roger5641 | 0:c1ea93720ab4 | 263 | ); |
roger5641 | 0:c1ea93720ab4 | 264 | |
roger5641 | 0:c1ea93720ab4 | 265 | /*! Start an GPIO Redundancy test |
roger5641 | 0:c1ea93720ab4 | 266 | */ |
roger5641 | 0:c1ea93720ab4 | 267 | void LTC681x_adaxd( |
roger5641 | 0:c1ea93720ab4 | 268 | uint8_t MD, //!< ADC Conversion Mode |
roger5641 | 0:c1ea93720ab4 | 269 | uint8_t CHG //!< Sets which GPIO channels are converted |
roger5641 | 0:c1ea93720ab4 | 270 | ); |
roger5641 | 0:c1ea93720ab4 | 271 | |
roger5641 | 0:c1ea93720ab4 | 272 | /*! Start an Auxiliary Register Self Test Conversion |
roger5641 | 0:c1ea93720ab4 | 273 | */ |
roger5641 | 0:c1ea93720ab4 | 274 | void LTC681x_axst( |
roger5641 | 0:c1ea93720ab4 | 275 | uint8_t MD, //!< ADC Conversion Mode |
roger5641 | 0:c1ea93720ab4 | 276 | uint8_t ST //!< Sets if self test 1 or 2 is run |
roger5641 | 0:c1ea93720ab4 | 277 | ); |
roger5641 | 0:c1ea93720ab4 | 278 | |
roger5641 | 0:c1ea93720ab4 | 279 | |
roger5641 | 0:c1ea93720ab4 | 280 | |
roger5641 | 0:c1ea93720ab4 | 281 | /*! Start a Status ADC Conversion |
roger5641 | 0:c1ea93720ab4 | 282 | */ |
roger5641 | 0:c1ea93720ab4 | 283 | void LTC681x_adstat( |
roger5641 | 0:c1ea93720ab4 | 284 | uint8_t MD, //!< ADC Conversion Mode |
roger5641 | 0:c1ea93720ab4 | 285 | uint8_t CHST //!< Sets which Stat channels are converted |
roger5641 | 0:c1ea93720ab4 | 286 | ); |
roger5641 | 0:c1ea93720ab4 | 287 | |
roger5641 | 0:c1ea93720ab4 | 288 | /*! Start a Status register redundancy test Conversion |
roger5641 | 0:c1ea93720ab4 | 289 | */ |
roger5641 | 0:c1ea93720ab4 | 290 | void LTC681x_adstatd( |
roger5641 | 0:c1ea93720ab4 | 291 | uint8_t MD, //!< ADC Mode |
roger5641 | 0:c1ea93720ab4 | 292 | uint8_t CHST //!< Sets which Status channels are converted |
roger5641 | 0:c1ea93720ab4 | 293 | ); |
roger5641 | 0:c1ea93720ab4 | 294 | |
roger5641 | 0:c1ea93720ab4 | 295 | |
roger5641 | 0:c1ea93720ab4 | 296 | /*! Start a Status Register Self Test Conversion |
roger5641 | 0:c1ea93720ab4 | 297 | */ |
roger5641 | 0:c1ea93720ab4 | 298 | void LTC681x_statst( |
roger5641 | 0:c1ea93720ab4 | 299 | uint8_t MD, //!< ADC Conversion Mode |
roger5641 | 0:c1ea93720ab4 | 300 | uint8_t ST //!< Sets if self test 1 or 2 is run |
roger5641 | 0:c1ea93720ab4 | 301 | ); |
roger5641 | 0:c1ea93720ab4 | 302 | |
roger5641 | 0:c1ea93720ab4 | 303 | void LTC681x_rdcv_reg(uint8_t reg, //!<Determines which cell voltage register is read back |
roger5641 | 0:c1ea93720ab4 | 304 | uint8_t total_ic, //!<the number of ICs in the |
roger5641 | 0:c1ea93720ab4 | 305 | uint8_t *data //!<An array of the unparsed cell codes |
roger5641 | 0:c1ea93720ab4 | 306 | ); |
roger5641 | 0:c1ea93720ab4 | 307 | /*! helper function that parses voltage measurement registers |
roger5641 | 0:c1ea93720ab4 | 308 | */ |
roger5641 | 0:c1ea93720ab4 | 309 | int8_t parse_cells(uint8_t current_ic, |
roger5641 | 0:c1ea93720ab4 | 310 | uint8_t cell_reg, |
roger5641 | 0:c1ea93720ab4 | 311 | uint8_t cell_data[], |
roger5641 | 0:c1ea93720ab4 | 312 | uint16_t *cell_codes, |
roger5641 | 0:c1ea93720ab4 | 313 | uint8_t *ic_pec); |
roger5641 | 0:c1ea93720ab4 | 314 | |
roger5641 | 0:c1ea93720ab4 | 315 | /*! Read the raw data from the LTC681x auxiliary register |
roger5641 | 0:c1ea93720ab4 | 316 | |
roger5641 | 0:c1ea93720ab4 | 317 | The function reads a single GPIO voltage register and stores thre read data |
roger5641 | 0:c1ea93720ab4 | 318 | in the *data point as a byte array. This function is rarely used outside of |
roger5641 | 0:c1ea93720ab4 | 319 | the LTC681x_rdaux() command. |
roger5641 | 0:c1ea93720ab4 | 320 | */ |
roger5641 | 0:c1ea93720ab4 | 321 | void LTC681x_rdaux_reg( uint8_t reg, //Determines which GPIO voltage register is read back |
roger5641 | 0:c1ea93720ab4 | 322 | uint8_t total_ic, //The number of ICs in the system |
roger5641 | 0:c1ea93720ab4 | 323 | uint8_t *data //Array of the unparsed auxiliary codes |
roger5641 | 0:c1ea93720ab4 | 324 | ); |
roger5641 | 0:c1ea93720ab4 | 325 | /*! Read the raw data from the LTC681x stat register |
roger5641 | 0:c1ea93720ab4 | 326 | |
roger5641 | 0:c1ea93720ab4 | 327 | The function reads a single GPIO voltage register and stores thre read data |
roger5641 | 0:c1ea93720ab4 | 328 | in the *data point as a byte array. This function is rarely used outside of |
roger5641 | 0:c1ea93720ab4 | 329 | the LTC681x_rdstat() command. |
roger5641 | 0:c1ea93720ab4 | 330 | */ |
roger5641 | 0:c1ea93720ab4 | 331 | void LTC681x_rdstat_reg(uint8_t reg, //Determines which stat register is read back |
roger5641 | 0:c1ea93720ab4 | 332 | uint8_t total_ic, //The number of ICs in the system |
roger5641 | 0:c1ea93720ab4 | 333 | uint8_t *data //Array of the unparsed stat codes |
roger5641 | 0:c1ea93720ab4 | 334 | ); |
roger5641 | 0:c1ea93720ab4 | 335 | |
roger5641 | 0:c1ea93720ab4 | 336 | /*! Clears the LTC681x cell voltage registers |
roger5641 | 0:c1ea93720ab4 | 337 | |
roger5641 | 0:c1ea93720ab4 | 338 | The command clears the cell voltage registers and initializes |
roger5641 | 0:c1ea93720ab4 | 339 | all values to 1. The register will read back hexadecimal 0xFF |
roger5641 | 0:c1ea93720ab4 | 340 | after the command is sent. |
roger5641 | 0:c1ea93720ab4 | 341 | */ |
roger5641 | 0:c1ea93720ab4 | 342 | void LTC681x_clrcell(); |
roger5641 | 0:c1ea93720ab4 | 343 | /*! Clears the LTC681x Auxiliary registers |
roger5641 | 0:c1ea93720ab4 | 344 | |
roger5641 | 0:c1ea93720ab4 | 345 | The command clears the Auxiliary registers and initializes |
roger5641 | 0:c1ea93720ab4 | 346 | all values to 1. The register will read back hexadecimal 0xFF |
roger5641 | 0:c1ea93720ab4 | 347 | after the command is sent. |
roger5641 | 0:c1ea93720ab4 | 348 | */ |
roger5641 | 0:c1ea93720ab4 | 349 | void LTC681x_clraux(); |
roger5641 | 0:c1ea93720ab4 | 350 | |
roger5641 | 0:c1ea93720ab4 | 351 | /*! Clears the LTC681x Stat registers |
roger5641 | 0:c1ea93720ab4 | 352 | |
roger5641 | 0:c1ea93720ab4 | 353 | The command clears the Stat registers and initializes |
roger5641 | 0:c1ea93720ab4 | 354 | all values to 1. The register will read back hexadecimal 0xFF |
roger5641 | 0:c1ea93720ab4 | 355 | after the command is sent. |
roger5641 | 0:c1ea93720ab4 | 356 | */ |
roger5641 | 0:c1ea93720ab4 | 357 | void LTC681x_clrstat(); |
roger5641 | 0:c1ea93720ab4 | 358 | |
roger5641 | 0:c1ea93720ab4 | 359 | /*! Clears the LTC681x SCTRL registers |
roger5641 | 0:c1ea93720ab4 | 360 | |
roger5641 | 0:c1ea93720ab4 | 361 | The command clears the SCTRL registers and initializes |
roger5641 | 0:c1ea93720ab4 | 362 | all values to 0. The register will read back hexadecimal 0x00 |
roger5641 | 0:c1ea93720ab4 | 363 | after the command is sent. |
roger5641 | 0:c1ea93720ab4 | 364 | */ |
roger5641 | 0:c1ea93720ab4 | 365 | void LTC681x_clrsctrl(); |
roger5641 | 0:c1ea93720ab4 | 366 | |
roger5641 | 0:c1ea93720ab4 | 367 | /*! Starts the Mux Decoder diagnostic self test |
roger5641 | 0:c1ea93720ab4 | 368 | |
roger5641 | 0:c1ea93720ab4 | 369 | Running this command will start the Mux Decoder Diagnostic Self Test |
roger5641 | 0:c1ea93720ab4 | 370 | This test takes roughly 1mS to complete. The MUXFAIL bit will be updated, |
roger5641 | 0:c1ea93720ab4 | 371 | the bit will be set to 1 for a failure and 0 if the test has been passed. |
roger5641 | 0:c1ea93720ab4 | 372 | */ |
roger5641 | 0:c1ea93720ab4 | 373 | void LTC681x_diagn(); |
roger5641 | 0:c1ea93720ab4 | 374 | |
roger5641 | 0:c1ea93720ab4 | 375 | /*! Reads and parses the LTC681x cell voltage registers. |
roger5641 | 0:c1ea93720ab4 | 376 | |
roger5641 | 0:c1ea93720ab4 | 377 | The function is used to read the cell codes of the LTC6811. |
roger5641 | 0:c1ea93720ab4 | 378 | This function will send the requested read commands parse the data |
roger5641 | 0:c1ea93720ab4 | 379 | and store the cell voltages in the cell_asic structure. |
roger5641 | 0:c1ea93720ab4 | 380 | */ |
roger5641 | 0:c1ea93720ab4 | 381 | uint8_t LTC681x_rdcv(uint8_t reg, // Controls which cell voltage register is read back. |
roger5641 | 0:c1ea93720ab4 | 382 | uint8_t total_ic, // the number of ICs in the system |
roger5641 | 0:c1ea93720ab4 | 383 | cell_asic ic[] // Array of the parsed cell codes |
roger5641 | 0:c1ea93720ab4 | 384 | ); |
roger5641 | 0:c1ea93720ab4 | 385 | |
roger5641 | 0:c1ea93720ab4 | 386 | /*! Reads and parses the LTC681x auxiliary registers. |
roger5641 | 0:c1ea93720ab4 | 387 | |
roger5641 | 0:c1ea93720ab4 | 388 | The function is used to read the parsed GPIO codes of the LTC6811. This function will send the requested |
roger5641 | 0:c1ea93720ab4 | 389 | read commands parse the data and store the gpio voltages in the cell_asic structure. |
roger5641 | 0:c1ea93720ab4 | 390 | */ |
roger5641 | 0:c1ea93720ab4 | 391 | int8_t LTC681x_rdaux(uint8_t reg, //Determines which GPIO voltage register is read back. |
roger5641 | 0:c1ea93720ab4 | 392 | uint8_t total_ic,//the number of ICs in the system |
roger5641 | 0:c1ea93720ab4 | 393 | cell_asic ic[]//!< Measurement Data Structure |
roger5641 | 0:c1ea93720ab4 | 394 | ); |
roger5641 | 0:c1ea93720ab4 | 395 | |
roger5641 | 0:c1ea93720ab4 | 396 | /*! Reads and parses the LTC681x stat registers. |
roger5641 | 0:c1ea93720ab4 | 397 | |
roger5641 | 0:c1ea93720ab4 | 398 | The function is used to read the parsed status codes of the LTC6811. This function will send the requested |
roger5641 | 0:c1ea93720ab4 | 399 | read commands parse the data and store the status voltages in the cell_asic structure |
roger5641 | 0:c1ea93720ab4 | 400 | */ |
roger5641 | 0:c1ea93720ab4 | 401 | int8_t LTC681x_rdstat( uint8_t reg, //!<Determines which Stat register is read back. |
roger5641 | 0:c1ea93720ab4 | 402 | uint8_t total_ic,//!<the number of ICs in the system |
roger5641 | 0:c1ea93720ab4 | 403 | cell_asic ic[]//!< Measurement Data Structure |
roger5641 | 0:c1ea93720ab4 | 404 | ); |
roger5641 | 0:c1ea93720ab4 | 405 | /*! Write the LTC681x CFGRA |
roger5641 | 0:c1ea93720ab4 | 406 | |
roger5641 | 0:c1ea93720ab4 | 407 | This command will write the configuration registers of the LTC681xs |
roger5641 | 0:c1ea93720ab4 | 408 | connected in a daisy chain stack. The configuration is written in descending |
roger5641 | 0:c1ea93720ab4 | 409 | order so the last device's configuration is written first. |
roger5641 | 0:c1ea93720ab4 | 410 | */ |
roger5641 | 0:c1ea93720ab4 | 411 | void LTC681x_wrcfg(uint8_t total_ic, //The number of ICs being written to |
roger5641 | 0:c1ea93720ab4 | 412 | cell_asic ic[] //A two dimensional array of the configuration data that will be written |
roger5641 | 0:c1ea93720ab4 | 413 | ); |
roger5641 | 0:c1ea93720ab4 | 414 | /*! Write the LTC681x CFGRB register |
roger5641 | 0:c1ea93720ab4 | 415 | |
roger5641 | 0:c1ea93720ab4 | 416 | This command will write the configuration registers of the LTC681xs |
roger5641 | 0:c1ea93720ab4 | 417 | connected in a daisy chain stack. The configuration is written in descending |
roger5641 | 0:c1ea93720ab4 | 418 | order so the last device's configuration is written first. |
roger5641 | 0:c1ea93720ab4 | 419 | */ |
roger5641 | 0:c1ea93720ab4 | 420 | void LTC681x_wrcfgb(uint8_t total_ic, //The number of ICs being written to |
roger5641 | 0:c1ea93720ab4 | 421 | cell_asic ic[] //A two dimensional array of the configuration data that will be written |
roger5641 | 0:c1ea93720ab4 | 422 | ); |
roger5641 | 0:c1ea93720ab4 | 423 | /*! Reads the LTC681x CFGRA register |
roger5641 | 0:c1ea93720ab4 | 424 | */ |
roger5641 | 0:c1ea93720ab4 | 425 | int8_t LTC681x_rdcfg(uint8_t total_ic, //Number of ICs in the system |
roger5641 | 0:c1ea93720ab4 | 426 | cell_asic ic[] //A two dimensional array that the function stores the read configuration data. |
roger5641 | 0:c1ea93720ab4 | 427 | ); |
roger5641 | 0:c1ea93720ab4 | 428 | |
roger5641 | 0:c1ea93720ab4 | 429 | /*! Reads the LTC681x CFGRB register |
roger5641 | 0:c1ea93720ab4 | 430 | */ |
roger5641 | 0:c1ea93720ab4 | 431 | int8_t LTC681x_rdcfgb(uint8_t total_ic, //Number of ICs in the system |
roger5641 | 0:c1ea93720ab4 | 432 | cell_asic ic[] //A two dimensional array that the function stores the read configuration data. |
roger5641 | 0:c1ea93720ab4 | 433 | ); |
roger5641 | 0:c1ea93720ab4 | 434 | |
roger5641 | 0:c1ea93720ab4 | 435 | |
roger5641 | 0:c1ea93720ab4 | 436 | /*! Reads pwm registers of a LTC6811 daisy chain |
roger5641 | 0:c1ea93720ab4 | 437 | */ |
roger5641 | 0:c1ea93720ab4 | 438 | int8_t LTC681x_rdpwm(uint8_t total_ic, //!<Number of ICs in the system |
roger5641 | 0:c1ea93720ab4 | 439 | uint8_t pwmReg, //!< The PWM Register to be written A or B |
roger5641 | 0:c1ea93720ab4 | 440 | cell_asic ic[] //!< ASIC Variable |
roger5641 | 0:c1ea93720ab4 | 441 | ); |
roger5641 | 0:c1ea93720ab4 | 442 | |
roger5641 | 0:c1ea93720ab4 | 443 | /*! Write the LTC681x PWM register |
roger5641 | 0:c1ea93720ab4 | 444 | |
roger5641 | 0:c1ea93720ab4 | 445 | This command will write the pwm registers of the LTC681x |
roger5641 | 0:c1ea93720ab4 | 446 | connected in a daisy chain stack. The pwm is written in descending |
roger5641 | 0:c1ea93720ab4 | 447 | order so the last device's pwm is written first. |
roger5641 | 0:c1ea93720ab4 | 448 | */ |
roger5641 | 0:c1ea93720ab4 | 449 | void LTC681x_wrpwm(uint8_t total_ic, //!< The number of ICs being written to |
roger5641 | 0:c1ea93720ab4 | 450 | uint8_t pwmReg, //!< The PWM Register to be written |
roger5641 | 0:c1ea93720ab4 | 451 | cell_asic ic[] //!< ASIC Variable |
roger5641 | 0:c1ea93720ab4 | 452 | ); |
roger5641 | 0:c1ea93720ab4 | 453 | |
roger5641 | 0:c1ea93720ab4 | 454 | /*! issues a stcomm command and clocks data out of the COMM register */ |
roger5641 | 0:c1ea93720ab4 | 455 | void LTC681x_stcomm(); |
roger5641 | 0:c1ea93720ab4 | 456 | |
roger5641 | 0:c1ea93720ab4 | 457 | /*! Reads comm registers of a LTC681x daisy chain |
roger5641 | 0:c1ea93720ab4 | 458 | */ |
roger5641 | 0:c1ea93720ab4 | 459 | int8_t LTC681x_rdcomm(uint8_t total_ic, //!< Number of ICs in the system |
roger5641 | 0:c1ea93720ab4 | 460 | cell_asic ic[] //!< ASIC Variable |
roger5641 | 0:c1ea93720ab4 | 461 | ); |
roger5641 | 0:c1ea93720ab4 | 462 | |
roger5641 | 0:c1ea93720ab4 | 463 | /*! Write the LTC681x COMM register |
roger5641 | 0:c1ea93720ab4 | 464 | |
roger5641 | 0:c1ea93720ab4 | 465 | This command will write the comm registers of the LTC681x |
roger5641 | 0:c1ea93720ab4 | 466 | connected in a daisy chain stack. The comm is written in descending |
roger5641 | 0:c1ea93720ab4 | 467 | order so the last device's configuration is written first. |
roger5641 | 0:c1ea93720ab4 | 468 | */ |
roger5641 | 0:c1ea93720ab4 | 469 | void LTC681x_wrcomm(uint8_t total_ic, //!< The number of ICs being written to |
roger5641 | 0:c1ea93720ab4 | 470 | cell_asic ic[] ///!< ASIC Variable |
roger5641 | 0:c1ea93720ab4 | 471 | ); |
roger5641 | 0:c1ea93720ab4 | 472 | |
roger5641 | 0:c1ea93720ab4 | 473 | /*! Selft Test Helper Function*/ |
roger5641 | 0:c1ea93720ab4 | 474 | uint16_t LTC681x_st_lookup( |
roger5641 | 0:c1ea93720ab4 | 475 | uint8_t MD, //ADC Mode |
roger5641 | 0:c1ea93720ab4 | 476 | uint8_t ST //Self Test |
roger5641 | 0:c1ea93720ab4 | 477 | ); |
roger5641 | 0:c1ea93720ab4 | 478 | |
roger5641 | 0:c1ea93720ab4 | 479 | /*! Helper Function to clear DCC bits in the CFGR Registers*/ |
roger5641 | 0:c1ea93720ab4 | 480 | void clear_discharge(uint8_t total_ic, |
roger5641 | 0:c1ea93720ab4 | 481 | cell_asic ic[]); |
roger5641 | 0:c1ea93720ab4 | 482 | |
roger5641 | 0:c1ea93720ab4 | 483 | /*! Helper function that runs the ADC Self Tests*/ |
roger5641 | 0:c1ea93720ab4 | 484 | int16_t LTC681x_run_cell_adc_st(uint8_t adc_reg, |
roger5641 | 0:c1ea93720ab4 | 485 | uint8_t total_ic, |
roger5641 | 0:c1ea93720ab4 | 486 | cell_asic ic[]); |
roger5641 | 0:c1ea93720ab4 | 487 | |
roger5641 | 0:c1ea93720ab4 | 488 | /*! Helper function that runs the ADC Digital Redudancy commands and checks output for errors*/ |
roger5641 | 0:c1ea93720ab4 | 489 | int16_t LTC681x_run_adc_redundancy_st(uint8_t adc_mode, |
roger5641 | 0:c1ea93720ab4 | 490 | uint8_t adc_reg, |
roger5641 | 0:c1ea93720ab4 | 491 | uint8_t total_ic, |
roger5641 | 0:c1ea93720ab4 | 492 | cell_asic ic[]); |
roger5641 | 0:c1ea93720ab4 | 493 | |
roger5641 | 0:c1ea93720ab4 | 494 | /*! Helper function that runs the datasheet open wire algorithm*/ |
roger5641 | 0:c1ea93720ab4 | 495 | void LTC681x_run_openwire(uint8_t total_ic, |
roger5641 | 0:c1ea93720ab4 | 496 | cell_asic ic[]); |
roger5641 | 0:c1ea93720ab4 | 497 | |
roger5641 | 0:c1ea93720ab4 | 498 | /*! Helper Function that runs the ADC Overlap test*/ |
roger5641 | 0:c1ea93720ab4 | 499 | uint16_t LTC681x_run_adc_overlap(uint8_t total_ic, |
roger5641 | 0:c1ea93720ab4 | 500 | cell_asic ic[]); |
roger5641 | 0:c1ea93720ab4 | 501 | /*! Helper Function that counts overall PEC errors and register/IC PEC errors*/ |
roger5641 | 0:c1ea93720ab4 | 502 | void LTC681x_check_pec(uint8_t total_ic, |
roger5641 | 0:c1ea93720ab4 | 503 | uint8_t reg, |
roger5641 | 0:c1ea93720ab4 | 504 | cell_asic ic[]); |
roger5641 | 0:c1ea93720ab4 | 505 | |
roger5641 | 0:c1ea93720ab4 | 506 | /*! Helper Function that resets the PEC error counters */ |
roger5641 | 0:c1ea93720ab4 | 507 | void LTC681x_reset_crc_count(uint8_t total_ic, |
roger5641 | 0:c1ea93720ab4 | 508 | cell_asic ic[]); |
roger5641 | 0:c1ea93720ab4 | 509 | |
roger5641 | 0:c1ea93720ab4 | 510 | /*! Helper Function to initialize the CFGR data structures*/ |
roger5641 | 0:c1ea93720ab4 | 511 | void LTC681x_init_cfg(uint8_t total_ic, |
roger5641 | 0:c1ea93720ab4 | 512 | cell_asic ic[]); |
roger5641 | 0:c1ea93720ab4 | 513 | |
roger5641 | 0:c1ea93720ab4 | 514 | /*! Helper function to set appropriate bits in CFGR register based on bit function*/ |
roger5641 | 0:c1ea93720ab4 | 515 | void LTC681x_set_cfgr(uint8_t nIC, |
roger5641 | 0:c1ea93720ab4 | 516 | cell_asic ic[], |
roger5641 | 0:c1ea93720ab4 | 517 | bool refon, |
roger5641 | 0:c1ea93720ab4 | 518 | bool adcopt, |
roger5641 | 0:c1ea93720ab4 | 519 | bool gpio[5], |
roger5641 | 0:c1ea93720ab4 | 520 | bool dcc[12]); |
roger5641 | 0:c1ea93720ab4 | 521 | |
roger5641 | 0:c1ea93720ab4 | 522 | /*! Helper function to turn the refon bit HIGH or LOW*/ |
roger5641 | 0:c1ea93720ab4 | 523 | void LTC681x_set_cfgr_refon(uint8_t nIC, |
roger5641 | 0:c1ea93720ab4 | 524 | cell_asic ic[], |
roger5641 | 0:c1ea93720ab4 | 525 | bool refon); |
roger5641 | 0:c1ea93720ab4 | 526 | |
roger5641 | 0:c1ea93720ab4 | 527 | /*! Helper function to turn the ADCOPT bit HIGH or LOW*/ |
roger5641 | 0:c1ea93720ab4 | 528 | void LTC681x_set_cfgr_adcopt(uint8_t nIC, |
roger5641 | 0:c1ea93720ab4 | 529 | cell_asic ic[], |
roger5641 | 0:c1ea93720ab4 | 530 | bool adcopt); |
roger5641 | 0:c1ea93720ab4 | 531 | |
roger5641 | 0:c1ea93720ab4 | 532 | /*! Helper function to turn the GPIO bits HIGH or LOW*/ |
roger5641 | 0:c1ea93720ab4 | 533 | void LTC681x_set_cfgr_gpio(uint8_t nIC, |
roger5641 | 0:c1ea93720ab4 | 534 | cell_asic ic[], |
roger5641 | 0:c1ea93720ab4 | 535 | bool gpio[]); |
roger5641 | 0:c1ea93720ab4 | 536 | |
roger5641 | 0:c1ea93720ab4 | 537 | /*! Helper function to turn the DCC bits HIGH or LOW*/ |
roger5641 | 0:c1ea93720ab4 | 538 | void LTC681x_set_cfgr_dis(uint8_t nIC, |
roger5641 | 0:c1ea93720ab4 | 539 | cell_asic ic[], |
roger5641 | 0:c1ea93720ab4 | 540 | bool dcc[]); |
roger5641 | 0:c1ea93720ab4 | 541 | /*! Helper function to set uv field in CFGRA register*/ |
roger5641 | 0:c1ea93720ab4 | 542 | void LTC681x_set_cfgr_uv(uint8_t nIC, |
roger5641 | 0:c1ea93720ab4 | 543 | cell_asic ic[], |
roger5641 | 0:c1ea93720ab4 | 544 | uint16_t uv); |
roger5641 | 0:c1ea93720ab4 | 545 | |
roger5641 | 0:c1ea93720ab4 | 546 | /*! Helper function to set ov field in CFGRA register*/ |
roger5641 | 0:c1ea93720ab4 | 547 | void LTC681x_set_cfgr_ov(uint8_t nIC, |
roger5641 | 0:c1ea93720ab4 | 548 | cell_asic ic[], |
roger5641 | 0:c1ea93720ab4 | 549 | uint16_t ov); |
roger5641 | 0:c1ea93720ab4 | 550 | |
roger5641 | 0:c1ea93720ab4 | 551 | |
roger5641 | 0:c1ea93720ab4 | 552 | |
roger5641 | 0:c1ea93720ab4 | 553 | //This needs a PROGMEM = when using with a LINDUINO |
roger5641 | 0:c1ea93720ab4 | 554 | const uint16_t crc15Table[256] {0x0,0xc599, 0xceab, 0xb32, 0xd8cf, 0x1d56, 0x1664, 0xd3fd, 0xf407, 0x319e, 0x3aac, //!<precomputed CRC15 Table |
roger5641 | 0:c1ea93720ab4 | 555 | 0xff35, 0x2cc8, 0xe951, 0xe263, 0x27fa, 0xad97, 0x680e, 0x633c, 0xa6a5, 0x7558, 0xb0c1, |
roger5641 | 0:c1ea93720ab4 | 556 | 0xbbf3, 0x7e6a, 0x5990, 0x9c09, 0x973b, 0x52a2, 0x815f, 0x44c6, 0x4ff4, 0x8a6d, 0x5b2e, |
roger5641 | 0:c1ea93720ab4 | 557 | 0x9eb7, 0x9585, 0x501c, 0x83e1, 0x4678, 0x4d4a, 0x88d3, 0xaf29, 0x6ab0, 0x6182, 0xa41b, |
roger5641 | 0:c1ea93720ab4 | 558 | 0x77e6, 0xb27f, 0xb94d, 0x7cd4, 0xf6b9, 0x3320, 0x3812, 0xfd8b, 0x2e76, 0xebef, 0xe0dd, |
roger5641 | 0:c1ea93720ab4 | 559 | 0x2544, 0x2be, 0xc727, 0xcc15, 0x98c, 0xda71, 0x1fe8, 0x14da, 0xd143, 0xf3c5, 0x365c, |
roger5641 | 0:c1ea93720ab4 | 560 | 0x3d6e, 0xf8f7,0x2b0a, 0xee93, 0xe5a1, 0x2038, 0x7c2, 0xc25b, 0xc969, 0xcf0, 0xdf0d, |
roger5641 | 0:c1ea93720ab4 | 561 | 0x1a94, 0x11a6, 0xd43f, 0x5e52, 0x9bcb, 0x90f9, 0x5560, 0x869d, 0x4304, 0x4836, 0x8daf, |
roger5641 | 0:c1ea93720ab4 | 562 | 0xaa55, 0x6fcc, 0x64fe, 0xa167, 0x729a, 0xb703, 0xbc31, 0x79a8, 0xa8eb, 0x6d72, 0x6640, |
roger5641 | 0:c1ea93720ab4 | 563 | 0xa3d9, 0x7024, 0xb5bd, 0xbe8f, 0x7b16, 0x5cec, 0x9975, 0x9247, 0x57de, 0x8423, 0x41ba, |
roger5641 | 0:c1ea93720ab4 | 564 | 0x4a88, 0x8f11, 0x57c, 0xc0e5, 0xcbd7, 0xe4e, 0xddb3, 0x182a, 0x1318, 0xd681, 0xf17b, |
roger5641 | 0:c1ea93720ab4 | 565 | 0x34e2, 0x3fd0, 0xfa49, 0x29b4, 0xec2d, 0xe71f, 0x2286, 0xa213, 0x678a, 0x6cb8, 0xa921, |
roger5641 | 0:c1ea93720ab4 | 566 | 0x7adc, 0xbf45, 0xb477, 0x71ee, 0x5614, 0x938d, 0x98bf, 0x5d26, 0x8edb, 0x4b42, 0x4070, |
roger5641 | 0:c1ea93720ab4 | 567 | 0x85e9, 0xf84, 0xca1d, 0xc12f, 0x4b6, 0xd74b, 0x12d2, 0x19e0, 0xdc79, 0xfb83, 0x3e1a, 0x3528, |
roger5641 | 0:c1ea93720ab4 | 568 | 0xf0b1, 0x234c, 0xe6d5, 0xede7, 0x287e, 0xf93d, 0x3ca4, 0x3796, 0xf20f, 0x21f2, 0xe46b, 0xef59, |
roger5641 | 0:c1ea93720ab4 | 569 | 0x2ac0, 0xd3a, 0xc8a3, 0xc391, 0x608, 0xd5f5, 0x106c, 0x1b5e, 0xdec7, 0x54aa, 0x9133, 0x9a01, |
roger5641 | 0:c1ea93720ab4 | 570 | 0x5f98, 0x8c65, 0x49fc, 0x42ce, 0x8757, 0xa0ad, 0x6534, 0x6e06, 0xab9f, 0x7862, 0xbdfb, 0xb6c9, |
roger5641 | 0:c1ea93720ab4 | 571 | 0x7350, 0x51d6, 0x944f, 0x9f7d, 0x5ae4, 0x8919, 0x4c80, 0x47b2, 0x822b, 0xa5d1, 0x6048, 0x6b7a, |
roger5641 | 0:c1ea93720ab4 | 572 | 0xaee3, 0x7d1e, 0xb887, 0xb3b5, 0x762c, 0xfc41, 0x39d8, 0x32ea, 0xf773, 0x248e, 0xe117, 0xea25, |
roger5641 | 0:c1ea93720ab4 | 573 | 0x2fbc, 0x846, 0xcddf, 0xc6ed, 0x374, 0xd089, 0x1510, 0x1e22, 0xdbbb, 0xaf8, 0xcf61, 0xc453, |
roger5641 | 0:c1ea93720ab4 | 574 | 0x1ca, 0xd237, 0x17ae, 0x1c9c, 0xd905, 0xfeff, 0x3b66, 0x3054, 0xf5cd, 0x2630, 0xe3a9, 0xe89b, |
roger5641 | 0:c1ea93720ab4 | 575 | 0x2d02, 0xa76f, 0x62f6, 0x69c4, 0xac5d, 0x7fa0, 0xba39, 0xb10b, 0x7492, 0x5368, 0x96f1, 0x9dc3, |
roger5641 | 0:c1ea93720ab4 | 576 | 0x585a, 0x8ba7, 0x4e3e, 0x450c, 0x8095 |
roger5641 | 0:c1ea93720ab4 | 577 | }; |
roger5641 | 0:c1ea93720ab4 | 578 | |
roger5641 | 0:c1ea93720ab4 | 579 | |
roger5641 | 0:c1ea93720ab4 | 580 | #endif |