DC2100A  1.2.0
Bi-Directional Cell Balancer Using the LTC3300-1 and the LTC6804-2
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
EEPROM.c
Go to the documentation of this file.
1 /*
2  Linear Technology DC2100A Demonstration Board.
3  Reference Application File for EEPROM Data Storage through the LTC6804-2 Battery Monitor.
4 
5  @verbatim
6  This file provides access to reading, writing, and setting defaults for EEPROM data stored on each DC2100A PCB.
7 
8  See "EEPROM" Worksheet in DC2100A_Design.xlsm for map of Data in EEPROM.
9 
10  @endverbatim
11 
12  http://www.linear.com/solutions/5126
13 
14  REVISION HISTORY
15  $Revision: 542 $
16  $Date: 2014-07-31 11:57:59 -0400 (Thu, 31 Jul 2014) $
17 
18  Copyright (c) 2013, Linear Technology Corp.(LTC)
19  All rights reserved.
20 
21  Redistribution and use in source and binary forms, with or without
22  modification, are permitted provided that the following conditions are met:
23 
24  1. Redistributions of source code must retain the above copyright notice, this
25  list of conditions and the following disclaimer.
26  2. Redistributions in binary form must reproduce the above copyright notice,
27  this list of conditions and the following disclaimer in the documentation
28  and/or other materials provided with the distribution.
29 
30  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
31  ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
32  WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
33  DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
34  ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
35  (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
36  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
37  ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
38  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
39  SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
40 
41  The views and conclusions contained in the software and documentation are those
42  of the authors and should not be interpreted as representing official policies,
43  either expressed or implied, of Linear Technology Corp.
44 
45 */
46 
47 //! @defgroup EEPROM Reference Application File for Interface to 24AA64 EEPROM through the LTC6804-2 Battery Monitor on the DC2100A PCB.
48 
49 /*! @file
50  @ingroup EEPROM
51  Reference Application File for Interface to 24AA64 EEPROM through the LTC6804-2 Battery Monitor on the DC2100A PCB.
52 */
53 
54 //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
55 // Includes
56 //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
57 #include "Typedefs.h"
58 #include "DC2100A.h"
59 #include "Eeprom.h"
60 #include "24AA64.h"
61 #include "SOC.h" // For default capacities
62 #include "Balancer.h" // For default currents
63 #include "LTC6804-2.h" // PEC calculation for LTC6804 used To validate EEPROM
64 #include <string.h>
65 
66 //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
67 // Definitions
68 //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
69 
70 // Define addresses for EEPROM data
71 #define EEPROM_MFG_DATA_ADDRESS 0 // EEPROM address for first byte of Manufacturing Board ID Data
72 #define EEPROM_MFG_DATA_CRC_ADDRESS (EEPROM_MFG_DATA_ADDRESS + sizeof(EEPROM_MFG_DATA_TYPE))
73 #define EEPROM_MFG_DATA_END (EEPROM_MFG_DATA_CRC_ADDRESS + sizeof(int16) - 1)
74 
75 #define EEPROM_MFG_CAP_ADDRESS 32 // EEPROM address for first byte of Linear factory calibrated capacity values.
76 #define EEPROM_MFG_CAP_CRC_ADDRESS (EEPROM_MFG_CAP_ADDRESS + sizeof(EEPROM_CAP_TYPE))
77 #define EEPROM_MFG_CAP_END (EEPROM_MFG_CAP_CRC_ADDRESS + sizeof(int16) - 1)
78 #if EEPROM_MFG_CAP_ADDRESS <= EEPROM_MFG_DATA_END
79 #error "EEPROM_MFG_CAP_ADDRESS" overlaps "EEPROM_MFG_DATA_END"
80 #endif
81 
82 #define EEPROM_MFG_CURRENT_ADDRESS 80 // EEPROM address for first byte of Linear factory calibrated balance current values.
83 #define EEPROM_MFG_CURRENT_CRC_ADDRESS (EEPROM_MFG_CURRENT_ADDRESS + sizeof(EEPROM_CURRENT_TYPE))
84 #define EEPROM_MFG_CURRENT_END (EEPROM_MFG_CURRENT_CRC_ADDRESS + sizeof(int16) - 1)
85 #if EEPROM_MFG_CURRENT_ADDRESS <= EEPROM_MFG_CAP_END
86 #error "EEPROM_MFG_CURRENT_ADDRESS" overlaps "EEPROM_MFG_CAP_END"
87 #endif
88 
89 #define EEPROM_USER_CAP_ADDRESS 128 // EEPROM address for first byte of User entered capacity values.
90 #define EEPROM_USER_CAP_CRC_ADDRESS (EEPROM_USER_CAP_ADDRESS + sizeof(EEPROM_CAP_TYPE))
91 #define EEPROM_USER_CAP_END (EEPROM_USER_CAP_CRC_ADDRESS + sizeof(int16) - 1)
92 #if EEPROM_USER_CAP_ADDRESS <= EEPROM_MFG_CURRENT_END
93 #error "EEPROM_USER_CAP_ADDRESS" overlaps "EEPROM_MFG_CURRENT_END"
94 #endif
95 
96 #define EEPROM_USER_CURRENT_ADDRESS 176 // EEPROM address for first byte of User entered balance current values.
97 #define EEPROM_USER_CURRENT_CRC_ADDRESS (EEPROM_USER_CURRENT_ADDRESS + sizeof(EEPROM_CURRENT_TYPE))
98 #define EEPROM_USER_CURRENT_END (EEPROM_USER_CURRENT_CRC_ADDRESS + sizeof(int16) - 1)
99 #if EEPROM_USER_CURRENT_ADDRESS <= EEPROM_USER_CAP_END
100 #error "EEPROM_USER_CURRENT_ADDRESS" overlaps "EEPROM_USER_CAP_END"
101 #endif
102 
103 // Define interface to read from EEPROM hardware
104 #define eeprom_read(board_num, address, data_ptr, num_bytes) \
105  { \
106  Eeprom_24AA64_Read(board_num, address, data_ptr, num_bytes); \
107  eeprom_number_reads += num_bytes; \
108  }
109 
110 // Define interface to write to EEPROM hardware
111 #define eeprom_write(board_num, address, data_ptr, num_bytes) \
112  { \
113  Eeprom_24AA64_Write(board_num, address, data_ptr, num_bytes); \
114  eeprom_number_writes += num_bytes; \
115  }
116 
117 //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
118 // Global Data
119 //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
120 
121 // Shadow RAM for cell data stored in DC2100A EEPROM.
122 EEPROM_CAP_TYPE Eeprom_cap_values[DC2100A_MAX_BOARDS]; // Copy of capacity value allows quick SOC calculations.
123 EEPROM_CURRENT_TYPE Eeprom_current_values[DC2100A_MAX_BOARDS]; // Copy of balance currents values allows quick balance calculations.
124 
125 //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
126 // Local Data
127 //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
128 int16 eeprom_number_reads; // debug data - number of times eeprom has been read.
129 int16 eeprom_number_writes; // debug data - number of times eeprom has been written.
130 
131 //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
132 // Local Prototypes
133 //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
134 void eeprom_write_with_crc(int8 board_num, int8* data_ptr, int16 address, int16 num_bytes);
135 BOOLEAN eeprom_read_with_crc(int8 board_num, int8* data_ptr, int16 address, int16 num_bytes);
136 void eeprom_cap_use_defaults(int8 board_num);
137 void eeprom_current_use_defaults(int8 board_num);
138 
139 //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
140 // Global Functions
141 //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
142 
143 // Initializes the EEPROM code module.
144 void Eeprom_Init(void)
145 {
146 
147  // Init debug data
148  eeprom_number_reads = 0;
149  eeprom_number_writes = 0;
150 
151  memset(Eeprom_cap_values, 0, sizeof(Eeprom_cap_values));
152  memset(Eeprom_current_values, 0, sizeof(Eeprom_current_values));
153 }
154 
155 // Resets the EEPROM to blank values.
156 // Note this will take a long time!
157 BOOLEAN Eeprom_Reset(int8 board_num, char* reset_key)
158 {
159  char reset_string[EEPROM_RESET_KEY_SIZE] = EEPROM_RESET_KEY;
160 
161  if(memcmp(reset_key, reset_string, EEPROM_RESET_KEY_SIZE) == 0)
162  {
163  Eeprom_24AA64_Erase(board_num);
164  return TRUE;
165  }
166 
167  return FALSE;
168 }
169 
170 // Loads user cap values from EEPROM and uses if populated. If not populated, uses nominal values.
171 // If user values are not populated or if mfg code is specified, load the mfg values from EEPROM and use if they're populated.
172 // If mfg values are not populated, use nominal values.
173 void Eeprom_Cap_Load(int8 board_num, int8 mfg_key)
174 {
175  if((FALSE == eeprom_read_with_crc(board_num, &Eeprom_cap_values[board_num], EEPROM_USER_CAP_ADDRESS, sizeof(EEPROM_CAP_TYPE))) ||
176  (EEPROM_MFG_KEY == mfg_key))
177  {
178  if(FALSE == eeprom_read_with_crc(board_num, &Eeprom_cap_values[board_num], EEPROM_MFG_CAP_ADDRESS, sizeof(EEPROM_CAP_TYPE)))
179  {
180  eeprom_cap_use_defaults(board_num);
181  }
182  }
183 }
184 
185 // Loads user balance current values from EEPROM and use if they're populated. If not populated, uses nominal values.
186 // If user values are not populated or if mfg code is specified, load the mfg values from EEPROM and use if they're populated.
187 // If mfg values are not populated, use nominal values.
188 void Eeprom_Current_Load(int8 board_num, int8 mfg_key)
189 {
190  if((FALSE == eeprom_read_with_crc(board_num, &Eeprom_current_values[board_num], EEPROM_USER_CURRENT_ADDRESS, sizeof(EEPROM_CURRENT_TYPE))) ||
191  (EEPROM_MFG_KEY == mfg_key))
192  {
193  if(FALSE == eeprom_read_with_crc(board_num, &Eeprom_current_values[board_num], EEPROM_MFG_CURRENT_ADDRESS, sizeof(EEPROM_CURRENT_TYPE)))
194  {
195  eeprom_current_use_defaults(board_num);
196  }
197  }
198 }
199 
200 // Saves the capacity values to the eeprom
201 // If mfg code is specified, this is saved as mfg cap and user cap values.
202 // If mfg_key is not specified, this is saved as user cap values.
203 void Eeprom_Cap_Save(int8 board_num, int8 mfg_key)
204 {
205  if(EEPROM_MFG_KEY == mfg_key)
206  {
207  eeprom_write_with_crc(board_num, &Eeprom_cap_values[board_num], EEPROM_MFG_CAP_ADDRESS, sizeof(EEPROM_CAP_TYPE));
208  }
209  eeprom_write_with_crc(board_num, &Eeprom_cap_values[board_num], EEPROM_USER_CAP_ADDRESS, sizeof(EEPROM_CAP_TYPE));
210  Eeprom_Cap_Load(board_num, mfg_key); // Reload to verify that they were saved correctly.
211 }
212 
213 // Saves the balance current values to the eeprom
214 // If mfg code is specified, this is saved as mfg balance current and user balance current values.
215 // If mfg_key is not specified, this is saved as user balance current values.
216 void Eeprom_Current_Save(int8 board_num, int8 mfg_key)
217 {
218  if(EEPROM_MFG_KEY == mfg_key)
219  {
220  eeprom_write_with_crc(board_num, &Eeprom_current_values[board_num], EEPROM_MFG_CURRENT_ADDRESS, sizeof(EEPROM_CURRENT_TYPE));
221  }
222  eeprom_write_with_crc(board_num, &Eeprom_current_values[board_num], EEPROM_USER_CURRENT_ADDRESS, sizeof(EEPROM_CURRENT_TYPE));
223  Eeprom_Current_Load(board_num, mfg_key); // Reload to verify that they were saved correctly.
224 }
225 
226 // Loads (but does not save in the EEPROM) the capacity values to their defaults
227 // If mfg code is specified, the nominal capacity values are loaded.
228 // If mfg_key is not specified, the mfg capacity values are loaded.
229 void Eeprom_Cap_Load_Defaults(int8 board_num, int8 mfg_key)
230 {
231  if(EEPROM_MFG_KEY == mfg_key)
232  {
233  eeprom_cap_use_defaults(board_num);
234  }
235  else
236  {
237  Eeprom_Cap_Load(board_num, EEPROM_MFG_KEY);
238  }
239 }
240 
241 // Loads (but does not save in the EEPROM) the balance current values to their defaults
242 // If mfg code is specified, the nominal balance current values are loaded.
243 // If mfg_key is not specified, the mfg balance current values are loaded.
244 void Eeprom_Current_Load_Defaults(int8 board_num, int8 mfg_key)
245 {
246  if(EEPROM_MFG_KEY == mfg_key)
247  {
248  eeprom_current_use_defaults(board_num);
249  }
250  else
251  {
253  }
254 }
255 
256 // Sets and saves the capacity values to their defaults
257 // If mfg code is specified, the nominal capacity values are saved as the mfg and user capacity values.
258 // If mfg_key is not specified, the mfg capacity values are saved as the user capacity values.
259 void Eeprom_Cap_Save_Defaults(int8 board_num, int8 mfg_key)
260 {
261  if(EEPROM_MFG_KEY == mfg_key)
262  {
263  eeprom_cap_use_defaults(board_num);
264  Eeprom_Cap_Save(board_num, 0);
265  Eeprom_Cap_Save(board_num, EEPROM_MFG_KEY);
266  }
267  else
268  {
269  Eeprom_Cap_Load(board_num, EEPROM_MFG_KEY);
270  Eeprom_Cap_Save(board_num, 0);
271  }
272 }
273 
274 // Sets and saves the balance current values to their defaults
275 // If mfg code is specified, the nominal balance current values are saved as the mfg and user balance current values.
276 // If mfg_key is not specified, the mfg balance current values are saved as the user balance current values.
277 void Eeprom_Current_Save_Defaults(int8 board_num, int8 mfg_key)
278 {
279  if(EEPROM_MFG_KEY == mfg_key)
280  {
281  eeprom_current_use_defaults(board_num);
282  Eeprom_Current_Save(board_num, 0);
284  }
285  else
286  {
288  Eeprom_Current_Save(board_num, 0);
289  }
290 }
291 
292 // Loads the Manufacturing Board ID Data from EEPROM into global shadow RAM.
293 BOOLEAN Eeprom_Mfg_Data_Get(int8 board_num, EEPROM_MFG_DATA_TYPE* mfg_data)
294 {
295  return eeprom_read_with_crc(board_num, mfg_data, EEPROM_MFG_DATA_ADDRESS, sizeof(EEPROM_MFG_DATA_TYPE));
296 }
297 
298 // Saves the Manufacturing Board ID Data from global shadow RAM into EEPROM.
299 void Eeprom_Mfg_Data_Set(int8 board_num, EEPROM_MFG_DATA_TYPE* mfg_data)
300 {
301  eeprom_write_with_crc(board_num, mfg_data, EEPROM_MFG_DATA_ADDRESS, sizeof(EEPROM_MFG_DATA_TYPE));
302 }
303 
304 //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
305 // Local Functions
306 //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
307 
308 // Write a series of bytes to the EEPROM with crc to a DC2100A board
309 void eeprom_write_with_crc(int8 board_num, int8* data_ptr, int16 address, int16 num_bytes)
310 {
311  unsigned int16 crc;
312  unsigned int16 crc_address;
313 
314  eeprom_write(board_num, address, data_ptr, num_bytes);
315 
316  // write the crc at the end
317  crc = LTC6804_PEC_Calc(data_ptr, num_bytes); // todo - how much is gained by combining crc calc with eeprom_write loop?
318  crc_address = address + num_bytes;
319 
320  eeprom_write(board_num, crc_address, (int8*)&crc, sizeof(crc));
321 }
322 
323 // Read a series of bytes from the EEPROM with crc to a DC2100A board.
324 // Returns TRUE if crc matches, FALSE if crc does not match.
325 BOOLEAN eeprom_read_with_crc(int8 board_num, int8* data_ptr, int16 address, int16 num_bytes)
326 {
327  unsigned int16 crc_read, crc_calc;
328  unsigned int16 crc_address;
329 
330  eeprom_read(board_num, address, data_ptr, num_bytes);
331 
332  // verify the crc
333  crc_calc = LTC6804_PEC_Calc(data_ptr, num_bytes); // todo - how much is gained by combining with eeprom_read loop?
334  crc_address = address + num_bytes;
335  eeprom_read(board_num, crc_address, (int8*)&crc_read, sizeof(crc_read));
336 
337  if(crc_calc == crc_read)
338  {
339  return TRUE;
340  }
341  else
342  {
343  return FALSE;
344  }
345 }
346 // Sets the capacitance values to their defaults depending upon the model number and whether board was shipped as part of a cap demo.
347 // These are the valid combinations:
348 // DC2100A-A Cap Demo Board
349 // DC2100A-A, Not Cap Demo Board
350 // DC2100A-B, Not Cap Demo Board
351 // DC2100A-C Cap Demo Board
352 // DC2100A-C, Not Cap Demo Board
353 // DC2100A-D, Not Cap Demo Board
354 // todo - can probably optimize this for space better.
355 void eeprom_cap_use_defaults(int8 board_num)
356 {
357  int8 cell_num;
358 
359  if(System_Cap_Demo.demo_present == 1)
360  {
361  for (cell_num = 0; cell_num < DC2100A_NUM_CELLS; cell_num++)
362  {
363  Eeprom_cap_values[board_num].cap[cell_num] = SOC_CAP_DEMO_DEFAULT;
364 
365  }
366  Eeprom_cap_values[board_num].cap[5] = SOC_CAP_DEMO_CELL_6_DEFAULT;
367  Eeprom_cap_values[board_num].cap[6] = SOC_CAP_DEMO_CELL_7_DEFAULT;
368  }
369  else
370  {
371  if((System_Model[board_num] == 'A') || (System_Model[board_num] == 'B'))
372  {
373  for (cell_num = 0; cell_num < DC2100A_NUM_CELLS; cell_num++)
374  {
375  Eeprom_cap_values[board_num].cap[cell_num] = SOC_CAPACITY_AB_DEFAULT;
376  }
377 
378  }
379  else
380  {
381  for (cell_num = 0; cell_num < DC2100A_NUM_CELLS; cell_num++)
382  {
383  Eeprom_cap_values[board_num].cap[cell_num] = SOC_CAPACITY_CD_DEFAULT;
384  }
385  }
386  }
387 }
388 
389 // Sets the current values to their defaults depending upon the model number and whether board was shipped as part of a cap demo.
390 // These are the valid combinations:
391 // DC2100A-A Cap Demo Board
392 // DC2100A-A, Not Cap Demo Board
393 // DC2100A-B, Not Cap Demo Board
394 // DC2100A-C Cap Demo Board
395 // DC2100A-C, Not Cap Demo Board
396 // DC2100A-D, Not Cap Demo Board
397 void eeprom_current_use_defaults(int8 board_num)
398 {
399  int8 cell_num;
400  int8 charge_default_12cell;
401  int8 discharge_default_12cell;
402 
403  // The bottom of stack defaults, are for the charge/discharge currents for 12 cells.
404  if((System_Model[board_num] == 'A') || (System_Model[board_num] == 'B'))
405  {
408  }
409  else
410  {
413  }
414 
415  for (cell_num = 0; cell_num < DC2100A_NUM_CELLS / 2; cell_num++)
416  {
417  Eeprom_current_values[board_num].current[cell_num].charge = charge_default_12cell;
418  Eeprom_current_values[board_num].current[cell_num].discharge = discharge_default_12cell;
419  }
420 
421  // The bottom of stack defaults, are for the charge/discharge currents for 6 cells.
422  for (cell_num = DC2100A_NUM_CELLS / 2; cell_num < DC2100A_NUM_CELLS; cell_num++)
423  {
424  Eeprom_current_values[board_num].current[cell_num].charge = 0;
425  Eeprom_current_values[board_num].current[cell_num].discharge = 0;
426  }
427 
428 }
EEPROM_CURRENT_TYPE Eeprom_current_values[DC2100A_MAX_BOARDS]
Copy of balance currents values allows quick balance calculations.
Definition: EEPROM.c:123
struct EEPROM_CURRENT_TYPE::@0 current[DC2100A_NUM_CELLS]
current calibration factor in BALANCER_CURRENT_SCALE units
void Eeprom_Current_Load(int8 board_num, int8 mfg_key)
Loads the customer saved or Linear factory calibrated balance current values from EEPROM into global ...
Definition: EEPROM.c:188
#define BALANCER_AB_CURRENT_CHARGE_12CELL
in mA, nominal charge balance current for cells with 12 cell secondary connections on a DC2100A-A or ...
Definition: Balancer.h:117
Structure containing manufacturing data for one DC2100A PCB.
Definition: EEPROM.h:71
void Eeprom_Current_Save(int8 board_num, int8 mfg_key)
Saves the customer saved or Linear factory calibrated balance current values from global shadow RAM i...
Definition: EEPROM.c:216
Reference Application File for EEPROM Data specific to the LTC6804-2 Battery Monitor on the DC2100A P...
void Eeprom_24AA64_Erase(int8 board_num)
Erases the full contents of the 24AA64 EEPROM.
Definition: 24AA64.c:168
#define BALANCER_CD_CURRENT_CHARGE_12CELL
in mA, nominal charge balance current for cells with 12 cell secondary connections on a DC2100A-C or ...
Definition: Balancer.h:121
void Eeprom_Current_Save_Defaults(int8 board_num, int8 mfg_key)
Resets customer saved balance current values to Linear factory calibrated balance current values...
Definition: EEPROM.c:277
EEPROM_CAP_TYPE Eeprom_cap_values[DC2100A_MAX_BOARDS]
@ EEPROM Shadow RAMShadow RAM for cell data stored in DC2100A EEPROM.
Definition: EEPROM.c:122
API Header File for LTC6804-2 Multicell Battery Monitors.
Reference Application File for Interface to 24AA64 EEPROM through the LTC6804-2 Battery Monitor on th...
#define BALANCER_CD_CURRENT_CHARGE_6CELL
in mA, nominal charge balance current for cells with 6 cell secondary connections on a DC2100A-C or D...
Definition: Balancer.h:123
signed int8 charge
charge current calibration factor
Definition: EEPROM.h:85
void Eeprom_Init(void)
Initializes the EEPROM code module.
Definition: EEPROM.c:144
#define EEPROM_MFG_KEY
Key allows access for Linear factory calibrated values.
Definition: EEPROM.h:95
unsigned int16 LTC6804_PEC_Calc(char *data, int length)
Calculates the LTC6804 CRC over a string of bytes as per datasheet figure 22.
Definition: LTC6804-2.c:1009
void Eeprom_Mfg_Data_Set(int8 board_num, EEPROM_MFG_DATA_TYPE *mfg_data)
Saves the Manufacturing Board ID Data from global shadow RAM into EEPROM.
Definition: EEPROM.c:299
#define BALANCER_AB_CURRENT_DISCHARGE_6CELL
in mA, nominal discharge balance current for cells with 6 cell secondary connections on a DC2100A-A o...
Definition: Balancer.h:120
BOOLEAN Eeprom_Mfg_Data_Get(int8 board_num, EEPROM_MFG_DATA_TYPE *mfg_data)
Loads the Manufacturing Board ID Data from EEPROM into global shadow RAM.
Definition: EEPROM.c:293
#define BALANCER_AB_CURRENT_CHARGE_6CELL
in mA, nominal charge balance current for cells with 6 cell secondary connections on a DC2100A-A or D...
Definition: Balancer.h:119
signed int8 discharge
discharge current calibration factor
Definition: EEPROM.h:86
Structure containing balance current calibration factors for one DC2100A PCB.
Definition: EEPROM.h:83
unsigned int16 cap[DC2100A_NUM_CELLS]
cell capacity in SOC_CAP_SCALE_FACTOR units
Definition: EEPROM.h:79
void Eeprom_Cap_Load_Defaults(int8 board_num, int8 mfg_key)
Loads Linear factory calibrated or nominal capacity values.
Definition: EEPROM.c:229
void Eeprom_Current_Load_Defaults(int8 board_num, int8 mfg_key)
Loads Linear factory calibrated or nominal balance current values.
Definition: EEPROM.c:244
#define BALANCER_AB_CURRENT_DISCHARGE_12CELL
in mA, nominal discharge balance current for cells with 12 cell secondary connections on a DC2100A-A ...
Definition: Balancer.h:118
void Eeprom_Cap_Save(int8 board_num, int8 mfg_key)
Saves the customer saved or Linear factory calibrated capacity values from global shadow RAM into EEP...
Definition: EEPROM.c:203
Structure containing capacity data for one DC2100A PCB.
Definition: EEPROM.h:78
void Eeprom_Cap_Load(int8 board_num, int8 mfg_key)
Loads the customer saved or Linear factory calibrated capacity values from EEPROM into global shadow ...
Definition: EEPROM.c:173
BOOLEAN Eeprom_Reset(int8 board_num, char *reset_key)
Resets the EEPROM to blank values.
Definition: EEPROM.c:157
#define BALANCER_CD_CURRENT_DISCHARGE_12CELL
in mA, nominal discharge balance current for cells with 12 cell secondary connections on a DC2100A-C ...
Definition: Balancer.h:122
#define EEPROM_RESET_KEY
Key allows reset of EEPROM to blank values.
Definition: EEPROM.h:93
void Eeprom_Cap_Save_Defaults(int8 board_num, int8 mfg_key)
Resets customer saved capacity values to Linear factory calibrated capacity values, or factory calibrated capacity values to nominal.
Definition: EEPROM.c:259
Reference Application File for Controlling the LTC3300-1 Battery Balancers through the LTC6804-2 Batt...
#define BALANCER_CD_CURRENT_DISCHARGE_6CELL
in mA, nominal discharge balance current for cells with 6 cell secondary connections on a DC2100A-C o...
Definition: Balancer.h:124
#define BALANCER_CURRENT_SCALE_CALC(desired_current, base_current)
calculation of calibration current values
Definition: Balancer.h:127
#define EEPROM_RESET_KEY_SIZE
Size of EEPROM_RESET_KEY.
Definition: EEPROM.h:94