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