foxBMS  1.6.0
The foxBMS Battery Management System API Documentation
diag_cbs_temperature.c
Go to the documentation of this file.
1 /**
2  *
3  * @copyright © 2010 - 2023, 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 diag_cbs_temperature.c
44  * @author foxBMS Team
45  * @date 2021-02-17 (date of creation)
46  * @updated 2023-10-12 (date of last update)
47  * @version v1.6.0
48  * @ingroup ENGINE
49  * @prefix DIAG
50  *
51  * @brief Diagnosis driver implementation
52  * @details TODO
53  */
54 
55 /*========== Includes =======================================================*/
56 #include "diag_cbs.h"
57 #include "fassert.h"
58 #include "fstd_types.h"
59 
60 #include <stdint.h>
61 
62 /*========== Macros and Definitions =========================================*/
63 
64 /*========== Static Constant and Variable Definitions =======================*/
65 
66 /*========== Extern Constant and Variable Definitions =======================*/
67 
68 /*========== Static Function Prototypes =====================================*/
69 
70 /*========== Static Function Implementations ================================*/
71 
72 /*========== Extern Function Implementations ================================*/
74  DIAG_ID_e diagId,
75  DIAG_EVENT_e event,
76  const DIAG_DATABASE_SHIM_s *const kpkDiagShim,
77  uint32_t stringNumber) {
78  FAS_ASSERT(diagId < DIAG_ID_MAX);
79  FAS_ASSERT((event == DIAG_EVENT_OK) || (event == DIAG_EVENT_NOT_OK) || (event == DIAG_EVENT_RESET));
80  FAS_ASSERT(kpkDiagShim != NULL_PTR);
81  FAS_ASSERT(stringNumber < BS_NR_OF_STRINGS);
82 
84  if (event == DIAG_EVENT_RESET) {
85  kpkDiagShim->pTableMsl->overtemperatureCharge[stringNumber] = 0;
86  }
87  if (event == DIAG_EVENT_NOT_OK) {
88  kpkDiagShim->pTableMsl->overtemperatureCharge[stringNumber] = 1;
89  }
90  } else if (diagId == DIAG_ID_TEMP_OVERTEMPERATURE_CHARGE_RSL) {
91  if (event == DIAG_EVENT_RESET) {
92  kpkDiagShim->pTableRsl->overtemperatureCharge[stringNumber] = 0;
93  }
94  if (event == DIAG_EVENT_NOT_OK) {
95  kpkDiagShim->pTableRsl->overtemperatureCharge[stringNumber] = 1;
96  }
97  } else if (diagId == DIAG_ID_TEMP_OVERTEMPERATURE_CHARGE_MOL) {
98  if (event == DIAG_EVENT_RESET) {
99  kpkDiagShim->pTableMol->overtemperatureCharge[stringNumber] = 0;
100  }
101  if (event == DIAG_EVENT_NOT_OK) {
102  kpkDiagShim->pTableMol->overtemperatureCharge[stringNumber] = 1;
103  }
104  }
105 }
106 
108  DIAG_ID_e diagId,
109  DIAG_EVENT_e event,
110  const DIAG_DATABASE_SHIM_s *const kpkDiagShim,
111  uint32_t stringNumber) {
112  FAS_ASSERT(diagId < DIAG_ID_MAX);
113  FAS_ASSERT((event == DIAG_EVENT_OK) || (event == DIAG_EVENT_NOT_OK) || (event == DIAG_EVENT_RESET));
114  FAS_ASSERT(kpkDiagShim != NULL_PTR);
115  FAS_ASSERT(stringNumber < BS_NR_OF_STRINGS);
116 
118  if (event == DIAG_EVENT_RESET) {
119  kpkDiagShim->pTableMsl->overtemperatureDischarge[stringNumber] = 0;
120  }
121  if (event == DIAG_EVENT_NOT_OK) {
122  kpkDiagShim->pTableMsl->overtemperatureDischarge[stringNumber] = 1;
123  }
124  } else if (diagId == DIAG_ID_TEMP_OVERTEMPERATURE_DISCHARGE_RSL) {
125  if (event == DIAG_EVENT_RESET) {
126  kpkDiagShim->pTableRsl->overtemperatureDischarge[stringNumber] = 0;
127  }
128  if (event == DIAG_EVENT_NOT_OK) {
129  kpkDiagShim->pTableRsl->overtemperatureDischarge[stringNumber] = 1;
130  }
131  } else if (diagId == DIAG_ID_TEMP_OVERTEMPERATURE_DISCHARGE_MOL) {
132  if (event == DIAG_EVENT_RESET) {
133  kpkDiagShim->pTableMol->overtemperatureDischarge[stringNumber] = 0;
134  }
135  if (event == DIAG_EVENT_NOT_OK) {
136  kpkDiagShim->pTableMol->overtemperatureDischarge[stringNumber] = 1;
137  }
138  }
139 }
140 
142  DIAG_ID_e diagId,
143  DIAG_EVENT_e event,
144  const DIAG_DATABASE_SHIM_s *const kpkDiagShim,
145  uint32_t stringNumber) {
146  FAS_ASSERT(diagId < DIAG_ID_MAX);
147  FAS_ASSERT((event == DIAG_EVENT_OK) || (event == DIAG_EVENT_NOT_OK) || (event == DIAG_EVENT_RESET));
148  FAS_ASSERT(kpkDiagShim != NULL_PTR);
149  FAS_ASSERT(stringNumber < BS_NR_OF_STRINGS);
150 
152  if (event == DIAG_EVENT_RESET) {
153  kpkDiagShim->pTableMsl->undertemperatureCharge[stringNumber] = 0;
154  }
155  if (event == DIAG_EVENT_NOT_OK) {
156  kpkDiagShim->pTableMsl->undertemperatureCharge[stringNumber] = 1;
157  }
158  } else if (diagId == DIAG_ID_TEMP_UNDERTEMPERATURE_CHARGE_RSL) {
159  if (event == DIAG_EVENT_RESET) {
160  kpkDiagShim->pTableRsl->undertemperatureCharge[stringNumber] = 0;
161  }
162  if (event == DIAG_EVENT_NOT_OK) {
163  kpkDiagShim->pTableRsl->undertemperatureCharge[stringNumber] = 1;
164  }
165  } else if (diagId == DIAG_ID_TEMP_UNDERTEMPERATURE_CHARGE_MOL) {
166  if (event == DIAG_EVENT_RESET) {
167  kpkDiagShim->pTableMol->undertemperatureCharge[stringNumber] = 0;
168  }
169  if (event == DIAG_EVENT_NOT_OK) {
170  kpkDiagShim->pTableMol->undertemperatureCharge[stringNumber] = 1;
171  }
172  }
173 }
174 
176  DIAG_ID_e diagId,
177  DIAG_EVENT_e event,
178  const DIAG_DATABASE_SHIM_s *const kpkDiagShim,
179  uint32_t stringNumber) {
180  FAS_ASSERT(diagId < DIAG_ID_MAX);
181  FAS_ASSERT((event == DIAG_EVENT_OK) || (event == DIAG_EVENT_NOT_OK) || (event == DIAG_EVENT_RESET));
182  FAS_ASSERT(kpkDiagShim != NULL_PTR);
183  FAS_ASSERT(stringNumber < BS_NR_OF_STRINGS);
184 
186  if (event == DIAG_EVENT_RESET) {
187  kpkDiagShim->pTableMsl->undertemperatureDischarge[stringNumber] = 0;
188  }
189  if (event == DIAG_EVENT_NOT_OK) {
190  kpkDiagShim->pTableMsl->undertemperatureDischarge[stringNumber] = 1;
191  }
192  } else if (diagId == DIAG_ID_TEMP_UNDERTEMPERATURE_DISCHARGE_RSL) {
193  if (event == DIAG_EVENT_RESET) {
194  kpkDiagShim->pTableRsl->undertemperatureDischarge[stringNumber] = 0;
195  }
196  if (event == DIAG_EVENT_NOT_OK) {
197  kpkDiagShim->pTableRsl->undertemperatureDischarge[stringNumber] = 1;
198  }
199  } else if (diagId == DIAG_ID_TEMP_UNDERTEMPERATURE_DISCHARGE_MOL) {
200  if (event == DIAG_EVENT_RESET) {
201  kpkDiagShim->pTableMol->undertemperatureDischarge[stringNumber] = 0;
202  }
203  if (event == DIAG_EVENT_NOT_OK) {
204  kpkDiagShim->pTableMol->undertemperatureDischarge[stringNumber] = 1;
205  }
206  }
207 }
208 
209 /*========== Externalized Static Function Implementations (Unit Test) =======*/
210 #ifdef UNITY_UNIT_TEST
211 #endif
#define BS_NR_OF_STRINGS
Number of parallel strings in the battery pack.
Diagnosis driver header.
void DIAG_ErrorOvertemperatureDischarge(DIAG_ID_e diagId, DIAG_EVENT_e event, const DIAG_DATABASE_SHIM_s *const kpkDiagShim, uint32_t stringNumber)
diagnosis callback function for overtemperature discharge events
void DIAG_ErrorUndertemperatureCharge(DIAG_ID_e diagId, DIAG_EVENT_e event, const DIAG_DATABASE_SHIM_s *const kpkDiagShim, uint32_t stringNumber)
diagnosis callback function for undertemperature charge events
void DIAG_ErrorOvertemperatureCharge(DIAG_ID_e diagId, DIAG_EVENT_e event, const DIAG_DATABASE_SHIM_s *const kpkDiagShim, uint32_t stringNumber)
diagnosis callback function for overtemperature charge events
void DIAG_ErrorUndertemperatureDischarge(DIAG_ID_e diagId, DIAG_EVENT_e event, const DIAG_DATABASE_SHIM_s *const kpkDiagShim, uint32_t stringNumber)
diagnosis callback function for undertemperature discharge events
DIAG_EVENT_e
Definition: diag_cfg.h:266
@ DIAG_EVENT_RESET
Definition: diag_cfg.h:269
@ DIAG_EVENT_NOT_OK
Definition: diag_cfg.h:268
@ DIAG_EVENT_OK
Definition: diag_cfg.h:267
DIAG_ID_e
Definition: diag_cfg.h:176
@ DIAG_ID_TEMP_OVERTEMPERATURE_DISCHARGE_MSL
Definition: diag_cfg.h:205
@ DIAG_ID_TEMP_UNDERTEMPERATURE_CHARGE_MSL
Definition: diag_cfg.h:208
@ DIAG_ID_TEMP_OVERTEMPERATURE_DISCHARGE_RSL
Definition: diag_cfg.h:206
@ DIAG_ID_TEMP_UNDERTEMPERATURE_DISCHARGE_RSL
Definition: diag_cfg.h:212
@ DIAG_ID_TEMP_UNDERTEMPERATURE_CHARGE_RSL
Definition: diag_cfg.h:209
@ DIAG_ID_TEMP_OVERTEMPERATURE_DISCHARGE_MOL
Definition: diag_cfg.h:207
@ DIAG_ID_TEMP_OVERTEMPERATURE_CHARGE_MSL
Definition: diag_cfg.h:202
@ DIAG_ID_TEMP_OVERTEMPERATURE_CHARGE_MOL
Definition: diag_cfg.h:204
@ DIAG_ID_TEMP_UNDERTEMPERATURE_CHARGE_MOL
Definition: diag_cfg.h:210
@ DIAG_ID_MAX
Definition: diag_cfg.h:262
@ DIAG_ID_TEMP_UNDERTEMPERATURE_DISCHARGE_MOL
Definition: diag_cfg.h:213
@ DIAG_ID_TEMP_OVERTEMPERATURE_CHARGE_RSL
Definition: diag_cfg.h:203
@ DIAG_ID_TEMP_UNDERTEMPERATURE_DISCHARGE_MSL
Definition: diag_cfg.h:211
Assert macro implementation.
#define FAS_ASSERT(x)
Assertion macro that asserts that x is true.
Definition: fassert.h:255
Definition of foxBMS standard types.
#define NULL_PTR
Null pointer.
Definition: fstd_types.h:77
uint8_t undertemperatureDischarge[BS_NR_OF_STRINGS]
Definition: database_cfg.h:503
uint8_t overtemperatureDischarge[BS_NR_OF_STRINGS]
Definition: database_cfg.h:501
uint8_t overtemperatureCharge[BS_NR_OF_STRINGS]
Definition: database_cfg.h:500
uint8_t undertemperatureCharge[BS_NR_OF_STRINGS]
Definition: database_cfg.h:502
uint8_t undertemperatureDischarge[BS_NR_OF_STRINGS]
Definition: database_cfg.h:463
uint8_t overtemperatureCharge[BS_NR_OF_STRINGS]
Definition: database_cfg.h:460
uint8_t overtemperatureDischarge[BS_NR_OF_STRINGS]
Definition: database_cfg.h:461
uint8_t undertemperatureCharge[BS_NR_OF_STRINGS]
Definition: database_cfg.h:462
uint8_t undertemperatureDischarge[BS_NR_OF_STRINGS]
Definition: database_cfg.h:483
uint8_t undertemperatureCharge[BS_NR_OF_STRINGS]
Definition: database_cfg.h:482
uint8_t overtemperatureDischarge[BS_NR_OF_STRINGS]
Definition: database_cfg.h:481
uint8_t overtemperatureCharge[BS_NR_OF_STRINGS]
Definition: database_cfg.h:480
DATA_BLOCK_MOL_FLAG_s * pTableMol
Definition: diag_cfg.h:167
DATA_BLOCK_RSL_FLAG_s * pTableRsl
Definition: diag_cfg.h:168
DATA_BLOCK_MSL_FLAG_s * pTableMsl
Definition: diag_cfg.h:169