foxBMS - Unit Tests  1.2.0
The foxBMS Unit Tests API Documentation
fram_cfg.h
Go to the documentation of this file.
1 /**
2  *
3  * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V.
4  * All rights reserved.
5  *
6  * SPDX-License-Identifier: BSD-3-Clause
7  *
8  * Redistribution and use in source and binary forms, with or without
9  * modification, are permitted provided that the following conditions are met:
10  *
11  * 1. Redistributions of source code must retain the above copyright notice, this
12  * list of conditions and the following disclaimer.
13  *
14  * 2. Redistributions in binary form must reproduce the above copyright notice,
15  * this list of conditions and the following disclaimer in the documentation
16  * and/or other materials provided with the distribution.
17  *
18  * 3. Neither the name of the copyright holder nor the names of its
19  * contributors may be used to endorse or promote products derived from
20  * this software without specific prior written permission.
21  *
22  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
23  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
25  * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
26  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
27  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
28  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
29  * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
30  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
31  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32  *
33  * We kindly request you to use one or more of the following phrases to refer to
34  * foxBMS in your hardware, software, documentation or advertising materials:
35  *
36  * - ″This product uses parts of foxBMS®″
37  * - ″This product includes parts of foxBMS®″
38  * - ″This product is derived from foxBMS®″
39  *
40  */
41 
42 /**
43  * @file fram_cfg.h
44  * @author foxBMS Team
45  * @date 2020-03-05 (date of creation)
46  * @updated 2020-03-05 (date of last update)
47  * @ingroup DRIVERS
48  * @prefix FRAM
49  *
50  * @brief Headers for the configuration for the FRAM module
51  *
52  *
53  */
54 
55 #ifndef FOXBMS__FRAM_CFG_H_
56 #define FOXBMS__FRAM_CFG_H_
57 
58 /*========== Includes =======================================================*/
59 #include "general.h"
60 
61 #include "battery_system_cfg.h"
62 
63 /*========== Macros and Definitions =========================================*/
64 /**
65  * @brief IDs for projects that use a memory layout
66  * @details This enum can be use to differentiate between projects. While an older
67  * version of the same project should be upgradeable, the entry of another
68  * project should be just discarded if a conflict occurs.
69  *
70  * In order for the ID to stay the same it is important that the defined
71  * macros are not changed and that each and every macro has a different
72  * value.
73  */
74 typedef uint16_t FRAM_PROJECT_ID;
75 
76 /** this is the standard main development branch */
77 #define FRAM_PROJECT_ID_FOXBMS_BASELINE ((FRAM_PROJECT_ID)0u)
78 
79 /** configuration struct of database channel (data block) */
80 typedef struct {
81  void *blockptr;
82  uint16_t datalength;
83  uint32_t address;
85 
86 /** fram block identification numbers */
87 typedef enum FRAM_BLOCK_ID {
93  FRAM_BLOCK_MAX, /**< DO NOT CHANGE, MUST BE THE LAST ENTRY */
95 
96 /**
97  * @brief Stores the version of the memory layout of the FRAM
98  * @details This struct stores with which memory-layout version the FRAM has
99  * been written. This allows the BMS to recognize an incompatible
100  * memory layout.
101  */
102 typedef struct FRAM_VERSION {
103  FRAM_PROJECT_ID project; /*!< an identifier for the project, it is not
104  intended to migrate between different projects */
105  uint16_t version; /*!< version counter, i.e. for updating to a new version in the same project */
107 
108 /** struct for the FRAM entry of the SBC driver */
109 typedef struct FRAM_SBC_INIT {
110  uint8_t phase;
113 
114 /**
115  * state of charge (SOC). Since SOC is voltage dependent, three different
116  * values are used, min, max and average. SOC defined as a float number between
117  * 0.0f and 100.0f (0% and 100%)
118  */
119 typedef struct FRAM_SOC {
120  float minimumSoc_perc[BS_NR_OF_STRINGS]; /*!< minimum SOC */
121  float maximumSoc_perc[BS_NR_OF_STRINGS]; /*!< maximum SOC */
122  float averageSoc_perc[BS_NR_OF_STRINGS]; /*!< average SOC */
124 
125 /**
126  * state of energy (SOE). Since SOE is voltage dependent, three different
127  * values are used, min, max and average. SOE defined as a float number between
128  * 0.0f and 100.0f (0% and 100%)
129  */
130 typedef struct FRAM_SOE {
131  float minimumSoe_perc[BS_NR_OF_STRINGS]; /*!< minimum SOE */
132  float maximumSoe_perc[BS_NR_OF_STRINGS]; /*!< maximum SOE */
133  float averageSoe_perc[BS_NR_OF_STRINGS]; /*!< average SOE */
135 /**
136  * flag to indicate if a deep-discharge in a string has been detected
137  */
138 typedef struct FRAM_DEEP_DISCHARGE_FLAG {
139  bool deepDischargeFlag[BS_NR_OF_STRINGS]; /*!< false (0): no error, true (1): deep-discharge detected */
141 
142 /*========== Extern Constant and Variable Declarations ======================*/
143 
145 
146 /**
147  * Variables to be stored in FRAM
148  */
149 /**@{*/
151 extern FRAM_SOC_s fram_soc;
152 extern FRAM_SOE_s fram_soe;
155 /**@}*/
156 
157 /*========== Extern Function Prototypes =====================================*/
158 
159 /*========== Externalized Static Functions Prototypes (Unit Test) ===========*/
160 
161 #endif /* FOXBMS__FRAM_CFG_H_ */
Configuration of the battery system (e.g., number of battery modules, battery cells,...
#define BS_NR_OF_STRINGS
FRAM_SOC_s fram_soc
Definition: fram_cfg.c:70
struct FRAM_DEEP_DISCHARGE_FLAG FRAM_DEEP_DISCHARGE_FLAG_s
enum FRAM_BLOCK_ID FRAM_BLOCK_ID_e
FRAM_SOE_s fram_soe
Definition: fram_cfg.c:71
uint16_t FRAM_PROJECT_ID
IDs for projects that use a memory layout.
Definition: fram_cfg.h:74
struct FRAM_SOE FRAM_SOE_s
struct FRAM_VERSION FRAM_VERSION_s
Stores the version of the memory layout of the FRAM.
struct FRAM_SOC FRAM_SOC_s
FRAM_BLOCK_ID
Definition: fram_cfg.h:87
@ FRAM_BLOCK_ID_DEEP_DISCHARGE_FLAG
Definition: fram_cfg.h:91
@ FRAM_BLOCK_ID_VERSION
Definition: fram_cfg.h:88
@ FRAM_BLOCK_ID_SOC
Definition: fram_cfg.h:89
@ FRAM_BLOCK_ID_SBC_INIT_STATE
Definition: fram_cfg.h:90
@ FRAM_BLOCK_MAX
Definition: fram_cfg.h:93
@ FRAM_BLOCK_ID_SOE
Definition: fram_cfg.h:92
FRAM_BASE_HEADER_s fram_base_header[FRAM_BLOCK_MAX]
Definition: fram_cfg.c:83
struct FRAM_SBC_INIT FRAM_SBC_INIT_s
FRAM_DEEP_DISCHARGE_FLAG_s fram_deepDischargeFlags
Definition: fram_cfg.c:76
FRAM_SBC_INIT_s fram_sbcInit
Definition: fram_cfg.c:72
FRAM_VERSION_s fram_version
Definition: fram_cfg.c:69
enum STD_RETURN_TYPE STD_RETURN_TYPE_e
General macros and definitions for the whole platform.
uint16_t datalength
Definition: fram_cfg.h:82
uint32_t address
Definition: fram_cfg.h:83
bool deepDischargeFlag[BS_NR_OF_STRINGS]
Definition: fram_cfg.h:139
uint8_t phase
Definition: fram_cfg.h:110
STD_RETURN_TYPE_e finState
Definition: fram_cfg.h:111
float minimumSoc_perc[BS_NR_OF_STRINGS]
Definition: fram_cfg.h:120
float maximumSoc_perc[BS_NR_OF_STRINGS]
Definition: fram_cfg.h:121
float averageSoc_perc[BS_NR_OF_STRINGS]
Definition: fram_cfg.h:122
float maximumSoe_perc[BS_NR_OF_STRINGS]
Definition: fram_cfg.h:132
float averageSoe_perc[BS_NR_OF_STRINGS]
Definition: fram_cfg.h:133
float minimumSoe_perc[BS_NR_OF_STRINGS]
Definition: fram_cfg.h:131
Stores the version of the memory layout of the FRAM.
Definition: fram_cfg.h:102
uint16_t version
Definition: fram_cfg.h:105
FRAM_PROJECT_ID project
Definition: fram_cfg.h:103