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