foxBMS-UnitTests  1.0.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
4  * angewandten Forschung e.V. All rights reserved.
5  *
6  * BSD 3-Clause License
7  * Redistribution and use in source and binary forms, with or without
8  * modification, are permitted provided that the following conditions are met:
9  * 1. Redistributions of source code must retain the above copyright notice,
10  * this list of conditions and the following disclaimer.
11  * 2. Redistributions in binary form must reproduce the above copyright
12  * notice, this list of conditions and the following disclaimer in the
13  * documentation and/or other materials provided with the distribution.
14  * 3. Neither the name of the copyright holder nor the names of its
15  * contributors may be used to endorse or promote products derived from
16  * this software without specific prior written permission.
17  *
18  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
19  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
22  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
23  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
24  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
25  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
26  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
27  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
28  * POSSIBILITY OF SUCH DAMAGE.
29  *
30  * We kindly request you to use one or more of the following phrases to refer
31  * to foxBMS in your hardware, software, documentation or advertising
32  * materials:
33  *
34  * ″This product uses parts of foxBMS®″
35  *
36  * ″This product includes parts of foxBMS®″
37  *
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_ */
FRAM_SOE
Definition: fram_cfg.h:130
fram_soe
FRAM_SOE_s fram_soe
Definition: fram_cfg.c:71
general.h
TODO.
FRAM_SBC_INIT_s
struct FRAM_SBC_INIT FRAM_SBC_INIT_s
FRAM_SOC::averageSoc_perc
float averageSoc_perc[BS_NR_OF_STRINGS]
Definition: fram_cfg.h:122
fram_soc
FRAM_SOC_s fram_soc
Definition: fram_cfg.c:70
FRAM_DEEP_DISCHARGE_FLAG::deepDischargeFlag
bool deepDischargeFlag[BS_NR_OF_STRINGS]
Definition: fram_cfg.h:139
FRAM_BLOCK_ID
FRAM_BLOCK_ID
Definition: fram_cfg.h:87
STD_RETURN_TYPE_e
enum STD_RETURN_TYPE STD_RETURN_TYPE_e
FRAM_VERSION::project
FRAM_PROJECT_ID project
Definition: fram_cfg.h:103
FRAM_DEEP_DISCHARGE_FLAG_s
struct FRAM_DEEP_DISCHARGE_FLAG FRAM_DEEP_DISCHARGE_FLAG_s
fram_version
FRAM_VERSION_s fram_version
Definition: fram_cfg.c:69
FRAM_PROJECT_ID
uint16_t FRAM_PROJECT_ID
IDs for projects that use a memory layout.
Definition: fram_cfg.h:74
fram_base_header
FRAM_BASE_HEADER_s fram_base_header[FRAM_BLOCK_MAX]
Definition: fram_cfg.c:83
battery_system_cfg.h
Configuration of the battery system (e.g., number of battery modules, battery cells,...
FRAM_BLOCK_ID_SOE
@ FRAM_BLOCK_ID_SOE
Definition: fram_cfg.h:92
FRAM_DEEP_DISCHARGE_FLAG
Definition: fram_cfg.h:138
fram_sbcInit
FRAM_SBC_INIT_s fram_sbcInit
Definition: fram_cfg.c:72
FRAM_SOE_s
struct FRAM_SOE FRAM_SOE_s
FRAM_SOE::maximumSoe_perc
float maximumSoe_perc[BS_NR_OF_STRINGS]
Definition: fram_cfg.h:132
FRAM_BLOCK_MAX
@ FRAM_BLOCK_MAX
Definition: fram_cfg.h:93
FRAM_BLOCK_ID_VERSION
@ FRAM_BLOCK_ID_VERSION
Definition: fram_cfg.h:88
FRAM_SOC
Definition: fram_cfg.h:119
fram_deepDischargeFlags
FRAM_DEEP_DISCHARGE_FLAG_s fram_deepDischargeFlags
Definition: fram_cfg.c:76
FRAM_BLOCK_ID_SOC
@ FRAM_BLOCK_ID_SOC
Definition: fram_cfg.h:89
FRAM_SOC::maximumSoc_perc
float maximumSoc_perc[BS_NR_OF_STRINGS]
Definition: fram_cfg.h:121
FRAM_BASE_HEADER_s::address
uint32_t address
Definition: fram_cfg.h:83
FRAM_BASE_HEADER_s::blockptr
void * blockptr
Definition: fram_cfg.h:81
FRAM_BLOCK_ID_SBC_INIT_STATE
@ FRAM_BLOCK_ID_SBC_INIT_STATE
Definition: fram_cfg.h:90
FRAM_BLOCK_ID_DEEP_DISCHARGE_FLAG
@ FRAM_BLOCK_ID_DEEP_DISCHARGE_FLAG
Definition: fram_cfg.h:91
FRAM_VERSION_s
struct FRAM_VERSION FRAM_VERSION_s
Stores the version of the memory layout of the FRAM.
FRAM_BASE_HEADER_s
Definition: fram_cfg.h:80
FRAM_BASE_HEADER_s::datalength
uint16_t datalength
Definition: fram_cfg.h:82
FRAM_SOC::minimumSoc_perc
float minimumSoc_perc[BS_NR_OF_STRINGS]
Definition: fram_cfg.h:120
FRAM_SOE::averageSoe_perc
float averageSoe_perc[BS_NR_OF_STRINGS]
Definition: fram_cfg.h:133
FRAM_SBC_INIT::phase
uint8_t phase
Definition: fram_cfg.h:110
FRAM_VERSION
Stores the version of the memory layout of the FRAM.
Definition: fram_cfg.h:102
FRAM_SOC_s
struct FRAM_SOC FRAM_SOC_s
FRAM_VERSION::version
uint16_t version
Definition: fram_cfg.h:105
FRAM_BLOCK_ID_e
enum FRAM_BLOCK_ID FRAM_BLOCK_ID_e
FRAM_SBC_INIT
Definition: fram_cfg.h:109
FRAM_SBC_INIT::finState
STD_RETURN_TYPE_e finState
Definition: fram_cfg.h:111
BS_NR_OF_STRINGS
#define BS_NR_OF_STRINGS
Definition: battery_system_cfg.h:89
FRAM_SOE::minimumSoe_perc
float minimumSoe_perc[BS_NR_OF_STRINGS]
Definition: fram_cfg.h:131