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.h
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  The items that are stored in the EEPROM are: Manufacturing (Mfg) Board ID Data, Cell Capacity Values, and Balancer Current Values.
9 
10  Some items have two copies in the EEPROM: The Mfg value is written in the Linear factory when the board is manufactured, and the User value is available for general use.
11 
12  Data is checked for consistency when it is retrieved from the EEPROM. If invalid data is retrieved, it is replaced in this order:
13  User EEPROM values are replaced by Linear factory calibrated EERPOM values, which is then replaced by nominal values from Flash.
14 
15  @endverbatim
16 
17  http://www.linear.com/solutions/5126
18 
19  REVISION HISTORY
20  $Revision: 542 $
21  $Date: 2014-07-31 11:57:59 -0400 (Thu, 31 Jul 2014) $
22 
23  Copyright (c) 2013, Linear Technology Corp.(LTC)
24  All rights reserved.
25 
26  Redistribution and use in source and binary forms, with or without
27  modification, are permitted provided that the following conditions are met:
28 
29  1. Redistributions of source code must retain the above copyright notice, this
30  list of conditions and the following disclaimer.
31  2. Redistributions in binary form must reproduce the above copyright notice,
32  this list of conditions and the following disclaimer in the documentation
33  and/or other materials provided with the distribution.
34 
35  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
36  ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
37  WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
38  DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
39  ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
40  (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
41  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
42  ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
43  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
44  SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
45 
46  The views and conclusions contained in the software and documentation are those
47  of the authors and should not be interpreted as representing official policies,
48  either expressed or implied, of Linear Technology Corp.
49 
50 */
51 
52 /*! @file
53  @ingroup EEPROM
54  Reference Application File for EEPROM Data specific to the LTC6804-2 Battery Monitor on the DC2100A PCB.
55 */
56 
57 #ifndef __EEPROM_H__
58 #define __EEPROM_H__
59 
60 //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
61 // Includes
62 //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
63 #include "Typedefs.h"
64 #include "DC2100A.h"
65 
66 //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
67 // Definitions
68 //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
69 
70 //! Structure containing manufacturing data for one DC2100A PCB
71 typedef struct {
72  char model_num[DC2100A_MODEL_NUM_SIZE]; //!< DC2100A model number
73  char cap_demo; //!< True if DC2100A was manufactured into a SuperCap Demo System
74  char serial_num[DC2100A_SERIAL_NUM_SIZE]; //!< DC2100A serial number
76 
77 //! Structure containing capacity data for one DC2100A PCB
78 typedef struct {
79  unsigned int16 cap[DC2100A_NUM_CELLS]; //!< cell capacity in SOC_CAP_SCALE_FACTOR units
81 
82 //! Structure containing balance current calibration factors for one DC2100A PCB
83 typedef struct {
84  struct {
85  signed int8 charge; //!< charge current calibration factor
86  signed int8 discharge; //!< discharge current calibration factor
87  } current [DC2100A_NUM_CELLS]; //!< current calibration factor in BALANCER_CURRENT_SCALE units
89 
90 //! @name EEPROM Keys
91 //! @{
92 //! Keys used to restrict special operations on the EEPROM.
93 #define EEPROM_RESET_KEY "EEPROM_RESET" //!< Key allows reset of EEPROM to blank values.
94 #define EEPROM_RESET_KEY_SIZE (sizeof(EEPROM_RESET_KEY) - 1) //!< Size of EEPROM_RESET_KEY
95 #define EEPROM_MFG_KEY 0x86 //!< Key allows access for Linear factory calibrated values.
96 //! @}
97 
98 //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
99 // Global Data
100 //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
101 
102 //! @ EEPROM Shadow RAM
103 //! @{
104 //! Shadow RAM for cell data stored in DC2100A EEPROM.
105 extern EEPROM_CAP_TYPE Eeprom_cap_values[DC2100A_MAX_BOARDS]; //!< Copy of capacity value allows quick SOC calculations.
106 extern EEPROM_CURRENT_TYPE Eeprom_current_values[DC2100A_MAX_BOARDS]; //!< Copy of balance currents values allows quick balance calculations.
107 //! @}
108 
109 //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
110 // Global Prototypes
111 //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
112 
113 //! Initializes the EEPROM code module.
114 //! @return void
115 void Eeprom_Init(void);
116 
117 //! Resets the EEPROM to blank values.
118 //! @return TRUE if the board is reset.
119 BOOLEAN Eeprom_Reset(int8 board_num, //!< The logical address for the PCB containing this EEPROM data.
120  char* reset_key //!< Key allows reset of EEPROM to blank values.
121  );
122 
123 //! Loads the customer saved or Linear factory calibrated capacity values from EEPROM into global shadow RAM.
124 //! @return void
125 void Eeprom_Cap_Load(int8 board_num, //!< The logical address for the PCB containing this EEPROM data.
126  int8 mfg_key //!< Key allows access for Linear factory calibrated values.
127  );
128 
129 //! Saves the customer saved or Linear factory calibrated capacity values from global shadow RAM into EEPROM.
130 //! @return void
131 void Eeprom_Cap_Save(int8 board_num, //!< The logical address for the PCB containing this EEPROM data.
132  int8 mfg_key //!< Key allows access for Linear factory calibrated values.
133  );
134 
135 //! Loads Linear factory calibrated or nominal capacity values.
136 //! @return void
137 void Eeprom_Cap_Load_Defaults(int8 board_num, //!< The logical address for the PCB containing this EEPROM data.
138  int8 mfg_key //!< Key allows access for Linear factory calibrated values.
139  );
140 
141 //! Resets customer saved capacity values to Linear factory calibrated capacity values, or factory calibrated capacity values to nominal.
142 //! @return void
143 void Eeprom_Cap_Save_Defaults(int8 board_num, //!< The logical address for the PCB containing this EEPROM data.
144  int8 mfg_key //!< Key allows access for Linear factory calibrated values.
145  );
146 
147 //! Loads the customer saved or Linear factory calibrated balance current values from EEPROM into global shadow RAM.
148 //! @return void
149 void Eeprom_Current_Load(int8 board_num, //!< The logical address for the PCB containing this EEPROM data.
150  int8 mfg_key //!< Key allows access for Linear factory calibrated values.
151  );
152 
153 //! Saves the customer saved or Linear factory calibrated balance current values from global shadow RAM into EEPROM.
154 //! @return void
155 void Eeprom_Current_Save(int8 board_num, //!< The logical address for the PCB containing this EEPROM data.
156  int8 mfg_key //!< Key allows access for Linear factory calibrated values.
157  );
158 
159 //! Loads Linear factory calibrated or nominal balance current values.
160 //! @return void
161 void Eeprom_Current_Load_Defaults(int8 board_num, //!< The logical address for the PCB containing this EEPROM data.
162  int8 mfg_key //!< Key allows access for Linear factory calibrated values.
163  );
164 
165 //! Resets customer saved balance current values to Linear factory calibrated balance current values, or factory calibrated balance current values to nominal.
166 //! @return void
167 void Eeprom_Current_Save_Defaults(int8 board_num, //!< The logical address for the PCB containing this EEPROM data.
168  int8 mfg_key //!< Key allows access for Linear factory calibrated values.
169  );
170 
171 //! Loads the Manufacturing Board ID Data from EEPROM into global shadow RAM.
172 //! @return True if Mfg Board ID Data is valid.
173 BOOLEAN Eeprom_Mfg_Data_Get(int8 board_num, //!< The logical address for the PCB containing this EEPROM data.
174  EEPROM_MFG_DATA_TYPE* mfg_data //!< Pointer where read data should be stored.
175  );
176 
177 //! Saves the Manufacturing Board ID Data from global shadow RAM into EEPROM.
178 //! @return void
179 void Eeprom_Mfg_Data_Set(int8 board_num, //!< The logical address for the PCB containing this EEPROM data.
180  EEPROM_MFG_DATA_TYPE* mfg_data //!< Pointer to data to write.
181  );
182 
183 #endif
void Eeprom_Current_Load_Defaults(int8 board_num, int8 mfg_key)
Loads Linear factory calibrated or nominal balance current values.
Definition: EEPROM.c:244
char cap_demo
True if DC2100A was manufactured into a SuperCap Demo System.
Definition: EEPROM.h:73
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
Structure containing manufacturing data for one DC2100A PCB.
Definition: EEPROM.h:71
EEPROM_CAP_TYPE Eeprom_cap_values[DC2100A_MAX_BOARDS]
@ EEPROM Shadow RAMShadow RAM for cell data stored in DC2100A EEPROM.
Definition: EEPROM.c:122
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
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
signed int8 charge
charge current calibration factor
Definition: EEPROM.h:85
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
void Eeprom_Init(void)
Initializes the EEPROM code module.
Definition: EEPROM.c:144
void Eeprom_Cap_Load_Defaults(int8 board_num, int8 mfg_key)
Loads Linear factory calibrated or nominal capacity values.
Definition: EEPROM.c:229
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
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
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
Structure containing capacity data for one DC2100A PCB.
Definition: EEPROM.h:78
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
BOOLEAN Eeprom_Reset(int8 board_num, char *reset_key)
Resets the EEPROM to blank values.
Definition: EEPROM.c:157
EEPROM_CURRENT_TYPE Eeprom_current_values[DC2100A_MAX_BOARDS]
Copy of balance currents values allows quick balance calculations.
Definition: EEPROM.c:123
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