foxBMS  1.6.0
The foxBMS Battery Management System API Documentation
diag_cfg.h
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_cfg.h
44  * @author foxBMS Team
45  * @date 2019-11-28 (date of creation)
46  * @updated 2023-10-12 (date of last update)
47  * @version v1.6.0
48  * @ingroup ENGINE_CONFIGURATION
49  * @prefix DIAG
50  *
51  * @brief Diagnostic module configuration header
52  * @details In this header filer are the different diagnosis channel defines
53  * assigned to different diagnosis IDs. Furthermore are the diagnosis
54  * error log settings be configured here.
55  */
56 
57 #ifndef FOXBMS__DIAG_CFG_H_
58 #define FOXBMS__DIAG_CFG_H_
59 
60 /*========== Includes =======================================================*/
61 
62 #include "battery_system_cfg.h"
63 #include "database_cfg.h"
64 
65 #include <stdbool.h>
66 #include <stdint.h>
67 
68 /*========== Macros and Definitions =========================================*/
69 #define DIAG_ERROR_SENSITIVITY_FIRST_EVENT (0) /*!< logging at first event */
70 #define DIAG_ERROR_SENSITIVITY_THIRD_EVENT (2) /*!< logging at third event */
71 #define DIAG_ERROR_SENSITIVITY_FIFTH_EVENT (4) /*!< logging at fifth event */
72 #define DIAG_ERROR_SENSITIVITY_TENTH_EVENT (9) /*!< logging at tenth event */
73 
74 #define DIAG_ERROR_SENSITIVITY_HIGH (0) /*!< logging at first event */
75 #define DIAG_ERROR_SENSITIVITY_MID (5) /*!< logging at fifth event */
76 #define DIAG_ERROR_SENSITIVITY_LOW (10) /*!< logging at tenth event */
77 
78 #define DIAG_ERROR_INTERLOCK_SENSITIVITY (10) /*!< logging level of interlock */
79 
80 #define DIAG_ERROR_VOLTAGE_SENSITIVITY_MSL (500) /*!< MSL level for event occurrence if over/under voltage event */
81 #define DIAG_ERROR_VOLTAGE_SENSITIVITY_RSL (500) /*!< RSL level for event occurrence if over/under voltage event */
82 #define DIAG_ERROR_VOLTAGE_SENSITIVITY_MOL (500) /*!< MOL level for event occurrence if over/under voltage event */
83 
84 /** MSL level for event occurrence if over/under temperature event */
85 #define DIAG_ERROR_TEMPERATURE_SENSITIVITY_MSL (500)
86 /** RSL level for event occurrence if over/under temperature event */
87 #define DIAG_ERROR_TEMPERATURE_SENSITIVITY_RSL (500)
88 /** MOL level for event occurrence if over/under temperature event */
89 #define DIAG_ERROR_TEMPERATURE_SENSITIVITY_MOL (500)
90 
91 /** MSL level for event occurrence if over/under current event */
92 #define DIAG_ERROR_CURRENT_SENSITIVITY_MSL (500)
93 /** RSL level for event occurrence if over/under current event */
94 #define DIAG_ERROR_CURRENT_SENSITIVITY_RSL (500)
95 /** MOL level for event occurrence if over/under current event */
96 #define DIAG_ERROR_CURRENT_SENSITIVITY_MOL (500)
97 
98 #define DIAG_ERROR_LTC_PEC_SENSITIVITY (5) /*!< logging level of LTC PEC errors */
99 #define DIAG_ERROR_LTC_MUX_SENSITIVITY (5) /*!< logging level of LTC MUX errors */
100 #define DIAG_ERROR_LTC_SPI_SENSITIVITY (5) /*!< logging level of LTC SPI errors */
101 
102 #define DIAG_ERROR_CAN_TIMING_SENSITIVITY (100) /*!< logging level of CAN timing errors */
103 #define DIAG_ERROR_CAN_TIMING_CC_SENSITIVITY (100) /*!< logging level of CAN timing errors on the current sensor */
104 #define DIAG_ERROR_CAN_SENSOR_SENSITIVITY (100) /*!< logging level of CAN errors on the current sensor */
105 
106 /**
107  * Logging after 20th event for errors connected related to the contactor
108  * feedback. This value is chosen to be so large because of the time delay
109  * between the request for a state and the actual physical response. It is
110  * caused by the SPI transaction to the SPS module, the rise time of the
111  * control signal and the actual opening/closing of the contactor. Only then
112  * can the feedback be read correctly, which also take some additional delay
113  * depending on the feedback source. */
114 #define DIAG_ERROR_CONTACTOR_FEEDBACK_SENSITIVITY (20)
115 
116 /** ---------------- DEFINES FOR ERROR STATE TRANSITION DELAY----------------
117  * These defines configure the delay before the transition to the error state
118  * occurs if a fault is detected. During this time the BMS can alert a
119  * superordinate control unit that the contactors will be opened soon. The
120  * superior control unit can take action and e.g., reduce the current until
121  * the transition to error state takes place.
122  *
123  * The delay is not taken into account if severity level #DIAG_FATAL_ERROR of
124  * type #DIAG_SEVERITY_LEVEL_e is configured in config array #diag_diagnosisIdConfiguration.
125  * For any other severity, #DIAG_DELAY_DISCARDED can be used as a dummy value.
126  */
127 #define DIAG_DELAY_DISCARDED (UINT32_MAX)
128 /** no delay after error is detected, open contactors instantaneous */
129 #define DIAG_NO_DELAY (0u)
130 /** delay for interlock error */
131 #define DIAG_DELAY_INTERLOCK_ms (100u)
132 /** delay for overvoltage errors */
133 #define DIAG_DELAY_OVERVOLTAGE_ms (200u)
134 /** delay for undervoltage errors */
135 #define DIAG_DELAY_UNDERVOLTAGE_ms (200u)
136 /** delay for temperature errors */
137 #define DIAG_DELAY_TEMPERATURE_ms (1000u)
138 /** delay for overcurrent errors */
139 #define DIAG_DELAY_OVERCURRENT_ms (100u)
140 /** delay for AFE related errors */
141 #define DIAG_DELAY_AFE_ms (100u)
142 /** delay for can timing error */
143 #define DIAG_DELAY_CAN_TIMING_ms (200u)
144 /** delay for energy counting/coulomb counting timing error */
145 #define DIAG_DELAY_EC_CC_TIMING_ms (2000u)
146 /** delay for current sensor response error */
147 #define DIAG_DELAY_CURRENT_SENSOR_ms (200u)
148 /** delay for SBC related errors */
149 #define DIAG_DELAY_SBC_ms (100u)
150 /** delay for pack voltage plausibility error */
151 #define DIAG_DELAY_PL_PACK_VOLTAGE_ms (100u)
152 /** delay for contactor feedback errors */
153 #define DIAG_DELAY_CONTACTOR_FEEDBACK_ms (100u)
154 /** delay for deep-discharge error */
155 #define DIAG_DELAY_DEEP_DISCHARGE_ms (100u)
156 /** delay redundancy measurement timeout errors */
157 #define DIAG_DELAY_REDUNDANCY_MEAS_TIMEOUT_ms (100u)
158 /** delay redundancy measurement errors */
159 #define DIAG_DELAY_REDUNDANCY_MEAS_ERROR_ms (100u)
160 
161 /** Maximum number of the same errors that are logged */
162 #define DIAG_MAX_ENTRIES_OF_ERROR (5)
163 
164 /** composite type for storing and passing on the local database table handles */
165 typedef struct {
166  DATA_BLOCK_ERROR_STATE_s *pTableError; /*!< database table with error states */
167  DATA_BLOCK_MOL_FLAG_s *pTableMol; /*!< database table with MOL flags */
168  DATA_BLOCK_RSL_FLAG_s *pTableRsl; /*!< database table with RSL flags */
169  DATA_BLOCK_MSL_FLAG_s *pTableMsl; /*!< database table with MSL flags */
171 
172 /** variable for storing and passing on the local database table handles */
174 
175 /** list of diag IDs */
176 typedef enum {
177  DIAG_ID_FLASHCHECKSUM, /*!< the checksum of the flashed software could not be validated */
178  DIAG_ID_SYSTEM_MONITORING, /*!< the system monitoring module has detected a deviation from task timing limits */
179  DIAG_ID_CONFIGASSERT, /*!< TODO */
180  DIAG_ID_AFE_SPI, /*!< issues with the SPI communication of the AFE */
181  DIAG_ID_AFE_COM_INTEGRITY, /*!< error on the communication integrity of the AFE, e.g. PEC error for LTC */
182  DIAG_ID_AFE_MUX, /*!< the multiplexer that is connected to the AFE does not react in an expected way */
183  DIAG_ID_AFE_CONFIG, /*!< the AFE driver has recognized a configuration error */
184  DIAG_ID_CAN_TIMING, /*!< the BMS does not receive CAN messages or they are not inside the expected timing constraints */
185  DIAG_ID_CAN_RX_QUEUE_FULL, /*!< the reception queue of the driver is full; no new messages can be received */
186  DIAG_ID_CAN_TX_QUEUE_FULL, /*!< the transmission queue of the driver is full; all new messages will be lost */
187  DIAG_ID_CAN_CC_RESPONDING, /*!< current counter measurements on the CAN bus are missing or not inside expected timing constraints */
188  DIAG_ID_CAN_EC_RESPONDING, /*!< energy counter measurements on the CAN bus are missing or not inside expected timing constraints */
189  DIAG_ID_CURRENT_SENSOR_RESPONDING, /*!< current sensor measurements on the CAN bus are missing or not inside expected timing constraints */
190  DIAG_ID_PLAUSIBILITY_CELL_VOLTAGE, /*!< redundant measurement of the cell voltages has returned implausible values */
191  DIAG_ID_AFE_CELL_VOLTAGE_MEAS_ERROR, /*!< the AFE driver has determined a cell voltage measurement to be implausible */
192  DIAG_ID_AFE_CELL_TEMPERATURE_MEAS_ERROR, /*!< the AFE driver has determined a cell temperature measurement to be implausible */
193  DIAG_ID_PLAUSIBILITY_CELL_TEMP, /*!< redundant measurement of the cell temperatures has returned implausible values */
194  DIAG_ID_PLAUSIBILITY_CELL_VOLTAGE_SPREAD, /*!< the spread (difference between min and max values) of the cell voltages is implausibly high */
195  DIAG_ID_PLAUSIBILITY_CELL_TEMPERATURE_SPREAD, /*!< the spread (difference between min and max values) of the cell temperatures is implausibly high */
196  DIAG_ID_CELL_VOLTAGE_OVERVOLTAGE_MSL, /*!< Cell voltage limits violated */
197  DIAG_ID_CELL_VOLTAGE_OVERVOLTAGE_RSL, /*!< Cell voltage limits violated */
198  DIAG_ID_CELL_VOLTAGE_OVERVOLTAGE_MOL, /*!< Cell voltage limits violated */
199  DIAG_ID_CELL_VOLTAGE_UNDERVOLTAGE_MSL, /*!< Cell voltage limits violated */
200  DIAG_ID_CELL_VOLTAGE_UNDERVOLTAGE_RSL, /*!< Cell voltage limits violated */
201  DIAG_ID_CELL_VOLTAGE_UNDERVOLTAGE_MOL, /*!< Cell voltage limits violated */
202  DIAG_ID_TEMP_OVERTEMPERATURE_CHARGE_MSL, /*!< Temperature limits violated */
203  DIAG_ID_TEMP_OVERTEMPERATURE_CHARGE_RSL, /*!< Temperature limits violated */
204  DIAG_ID_TEMP_OVERTEMPERATURE_CHARGE_MOL, /*!< Temperature limits violated */
205  DIAG_ID_TEMP_OVERTEMPERATURE_DISCHARGE_MSL, /*!< Temperature limits violated */
206  DIAG_ID_TEMP_OVERTEMPERATURE_DISCHARGE_RSL, /*!< Temperature limits violated */
207  DIAG_ID_TEMP_OVERTEMPERATURE_DISCHARGE_MOL, /*!< Temperature limits violated */
208  DIAG_ID_TEMP_UNDERTEMPERATURE_CHARGE_MSL, /*!< Temperature limits violated */
209  DIAG_ID_TEMP_UNDERTEMPERATURE_CHARGE_RSL, /*!< Temperature limits violated */
210  DIAG_ID_TEMP_UNDERTEMPERATURE_CHARGE_MOL, /*!< Temperature limits violated */
211  DIAG_ID_TEMP_UNDERTEMPERATURE_DISCHARGE_MSL, /*!< Temperature limits violated */
212  DIAG_ID_TEMP_UNDERTEMPERATURE_DISCHARGE_RSL, /*!< Temperature limits violated */
213  DIAG_ID_TEMP_UNDERTEMPERATURE_DISCHARGE_MOL, /*!< Temperature limits violated */
214  DIAG_ID_OVERCURRENT_CHARGE_CELL_MSL, /*!< Overcurrent on cell-level */
215  DIAG_ID_OVERCURRENT_CHARGE_CELL_RSL, /*!< Overcurrent on cell-level */
216  DIAG_ID_OVERCURRENT_CHARGE_CELL_MOL, /*!< Overcurrent on cell-level */
217  DIAG_ID_OVERCURRENT_DISCHARGE_CELL_MSL, /*!< Overcurrent on cell-level */
218  DIAG_ID_OVERCURRENT_DISCHARGE_CELL_RSL, /*!< Overcurrent on cell-level */
219  DIAG_ID_OVERCURRENT_DISCHARGE_CELL_MOL, /*!< Overcurrent on cell-level */
220  DIAG_ID_STRING_OVERCURRENT_CHARGE_MSL, /*!< Overcurrent on string-level */
221  DIAG_ID_STRING_OVERCURRENT_CHARGE_RSL, /*!< Overcurrent on string-level */
222  DIAG_ID_STRING_OVERCURRENT_CHARGE_MOL, /*!< Overcurrent on string-level */
223  DIAG_ID_STRING_OVERCURRENT_DISCHARGE_MSL, /*!< Overcurrent on string-level */
224  DIAG_ID_STRING_OVERCURRENT_DISCHARGE_RSL, /*!< Overcurrent on string-level */
225  DIAG_ID_STRING_OVERCURRENT_DISCHARGE_MOL, /*!< Overcurrent on string-level */
226  DIAG_ID_PACK_OVERCURRENT_CHARGE_MSL, /*!< Overcurrent on string-level */
227  DIAG_ID_PACK_OVERCURRENT_DISCHARGE_MSL, /*!< Overcurrent on pack-level */
228  DIAG_ID_CURRENT_ON_OPEN_STRING, /*!< Current flowing on open string */
229  DIAG_ID_DEEP_DISCHARGE_DETECTED, /*!< the deep discharge flag has been set in persistent memory */
230  DIAG_ID_AFE_OPEN_WIRE, /*!< an open (broken) sense wire has been detected on the battery cell measurement */
231  DIAG_ID_PLAUSIBILITY_PACK_VOLTAGE, /*!< the plausibility module has decided that the pack voltage is implausible */
232  DIAG_ID_INTERLOCK_FEEDBACK, /*!< the interlock feedback indicates it to be open (but it is expected to be closed) */
233  DIAG_ID_STRING_MINUS_CONTACTOR_FEEDBACK, /*!< the feedback on a string minus contactor does not match the expected value */
234  DIAG_ID_STRING_PLUS_CONTACTOR_FEEDBACK, /*!< the feedback on a string plus contactor does not match the expected value */
235  DIAG_ID_PRECHARGE_CONTACTOR_FEEDBACK, /*!< the feedback on a precharge contactor does not match the expected value */
236  DIAG_ID_SBC_FIN_STATE, /*!< the state of the FIN signal in the SBC is not ok */
237  DIAG_ID_SBC_RSTB_STATE, /*!< an activation of the RSTB pin of the SBC has been detected */
238  DIAG_ID_BASE_CELL_VOLTAGE_MEASUREMENT_TIMEOUT, /*!< the redundancy module has detected that the base cell voltage measurements are missing */
239  DIAG_ID_REDUNDANCY0_CELL_VOLTAGE_MEASUREMENT_TIMEOUT, /*!< the redundancy module has detected that the redundancy0 cell voltage measurements are missing */
240  DIAG_ID_BASE_CELL_TEMPERATURE_MEASUREMENT_TIMEOUT, /*!< the redundancy module has detected that the base cell temperature measurements are missing */
241  DIAG_ID_REDUNDANCY0_CELL_TEMPERATURE_MEASUREMENT_TIMEOUT, /*!< the redundancy module has detected that the redundancy0 temperature measurements are missing */
242  DIAG_ID_PRECHARGE_ABORT_REASON_VOLTAGE, /*!< precharging aborted due to a too high voltage difference */
243  DIAG_ID_PRECHARGE_ABORT_REASON_CURRENT, /*!< precharging aborted because measured current was too high */
244  DIAG_ID_CURRENT_MEASUREMENT_TIMEOUT, /*!< the redundancy module has detected that the current measurement on a string is not updated */
245  DIAG_ID_CURRENT_MEASUREMENT_ERROR, /*!< the redundancy module has detected a current measurement to be invalid */
246  DIAG_ID_CURRENT_SENSOR_V1_MEASUREMENT_TIMEOUT, /*!< the redundancy module has detected that the voltage 1 measurement of a current sensor is not updated */
247  DIAG_ID_CURRENT_SENSOR_V2_MEASUREMENT_TIMEOUT, /*!< the redundancy module has detected that the voltage 2 measurement of a current sensor is not updated */
248  DIAG_ID_CURRENT_SENSOR_V3_MEASUREMENT_TIMEOUT, /*!< the redundancy module has detected that the voltage 3 measurement of a current sensor is not updated */
249  DIAG_ID_CURRENT_SENSOR_POWER_MEASUREMENT_TIMEOUT, /*!< the redundancy module has detected that the power measurement of a current sensor is not updated */
250  DIAG_ID_POWER_MEASUREMENT_ERROR, /*!< the redundancy module has detected a power measurement to be invalid */
251  DIAG_ID_INSULATION_MEASUREMENT_VALID, /*!< the insulation measurement is valid or invalid */
252  DIAG_ID_LOW_INSULATION_RESISTANCE_ERROR, /*!< a critical low insulation resistance has been measured */
253  DIAG_ID_LOW_INSULATION_RESISTANCE_WARNING, /*!< a warnable low insulation resistance has been measured */
254  DIAG_ID_INSULATION_GROUND_ERROR, /*!< insulation monitoring has detected a ground error */
255  DIAG_ID_I2C_PEX_ERROR, /*!< general error with the port expanders */
256  DIAG_ID_I2C_RTC_ERROR, /*!< i2c communication error with the RTC */
257  DIAG_ID_RTC_CLOCK_INTEGRITY_ERROR, /*!< clock integrity not garanteed error in RTC IC */
258  DIAG_ID_RTC_BATTERY_LOW_ERROR, /*!< RTC IC battery low flag set */
259  DIAG_ID_FRAM_READ_CRC_ERROR, /*!< CRC does not match when reading from the FRAM */
260  DIAG_ID_ALERT_MODE, /*!< Critical error while opening the contactors. Fuse has not triggered */
261  DIAG_ID_AEROSOL_ALERT, /*!< high aerosol concentration detected */
262  DIAG_ID_MAX, /*!< MAX indicator - do not change */
263 } DIAG_ID_e;
264 
265 /** diagnosis check result (event) */
266 typedef enum {
267  DIAG_EVENT_OK, /**< diag channel event OK */
268  DIAG_EVENT_NOT_OK, /**< diag channel event NOK */
269  DIAG_EVENT_RESET, /**< reset diag channel event counter to 0 */
270 } DIAG_EVENT_e;
271 
272 /** enable or disable the diagnosis handling for an event */
273 typedef enum {
274  DIAG_EVALUATION_ENABLED, /**< enables evaluation of diagnosis handling */
275  DIAG_EVALUATION_DISABLED, /**< disables evaluation of diagnosis handling */
277 
278 /** impact level of diagnosis event, e.g., influences the event the whole system or only a string */
279 typedef enum {
280  DIAG_SYSTEM, /**< diag event impact is system related e.g., can timing */
281  DIAG_STRING, /**< diag event impact is string related e.g., overvoltage in string x */
283 
284 /**
285  * @def DIAG_CAN_TIMING
286  * @brief Value that is written into the field that describes whether CAN
287  * timing diag entries should be generated
288  */
289 #if BS_CHECK_CAN_TIMING == true
290 #define DIAG_CAN_TIMING (DIAG_EVALUATION_ENABLED)
291 #else
292 #define DIAG_CAN_TIMING (DIAG_EVALUATION_DISABLED)
293 #endif
294 
295 /**
296  * @def DIAG_CAN_SENSOR_PRESENT
297  * @brief Value that is written into the field that describes whether current
298  * sensor diag entries should be generated if it is not present
299  */
300 #if BS_CURRENT_SENSOR_PRESENT == true
301 #define DIAG_CAN_SENSOR_PRESENT (DIAG_EVALUATION_ENABLED)
302 #else /* BS_CURRENT_SENSOR_PRESENT == true */
303 #define DIAG_CAN_SENSOR_PRESENT (DIAG_EVALUATION_DISABLED)
304 #endif /* BS_CURRENT_SENSOR_PRESENT */
305 
306 /** diagnosis severity level */
307 typedef enum {
308  DIAG_FATAL_ERROR, /*!< severity level fatal error */
309  DIAG_WARNING, /*!< severity level warning */
310  DIAG_INFO, /*!< severity level info */
312 
313 /** diagnosis recording activation */
314 typedef enum {
315  DIAG_RECORDING_ENABLED, /**< enable diagnosis event recording */
316  DIAG_RECORDING_DISABLED, /**< disable diagnosis event recording */
318 
319 /**
320  * @brief function type for diag callbacks
321  * @param[in] diagId ID of diag entry
322  * @param[in] event #DIAG_EVENT_e
323  * @param[in] kpkDiagShim shim to the database entries
324  * @param[in] data data
325  */
327  DIAG_ID_e diagId,
328  DIAG_EVENT_e event,
329  const DIAG_DATABASE_SHIM_s *const kpkDiagShim,
330  uint32_t data);
331 
332 /** Channel configuration of one diag channel */
333 typedef struct {
334  DIAG_ID_e id; /**< diagnosis event id diag_id */
335  uint16_t threshold; /**< threshold for number of events which will be
336  * tolerated before generating a notification in both directions:
337  * threshold = 0: reports the value at first occurrence,
338  * threshold = 1: reports the value at second occurrence */
340  severity; /**< severity of diag entry, #DIAG_FATAL_ERROR will lead to an opening of the contactors */
341  uint32_t
342  delay_ms; /**< delay in ms after error detection if severity is #DIAG_FATAL_ERROR until an opening the contactors */
343  DIAG_RECORDING_e enable_recording; /**< if enabled recording in diag_memory * will be activated */
344  DIAG_EVALUATE_e enable_evaluate; /**< if enabled diagnosis event will be evaluated */
345  DIAG_CALLBACK_FUNCTION_f *fpCallback; /**< will be called if
346  * number of events exceeds threshold in both
347  * directions with parameter DIAG_EVENT_e
348  * string id or system related data */
349 } DIAG_ID_CFG_s;
350 
351 /** struct for device Configuration of diag module */
352 typedef struct {
353  uint8_t nrOfConfiguredDiagnosisEntries; /*!< number of entries in DIAG_ID_CFG_s */
354  DIAG_ID_CFG_s *pConfigurationOfDiagnosisEntries; /*!< pointer to configuration array for all diagnosis entries */
355  uint16_t numberOfFatalErrors; /*!< number of configured diagnosis entries with severity #DIAG_FATAL_ERROR */
356  DIAG_ID_CFG_s *pFatalErrorLinkTable
357  [DIAG_ID_MAX]; /*!< list with pointers to all diagnosis entries with severity #DIAG_FATAL_ERROR */
358 } DIAG_DEV_s;
359 
360 /*========== Extern Constant and Variable Declarations ======================*/
361 /** diag device configuration struct */
362 extern DIAG_DEV_s diag_device;
364 
365 /*========== Extern Function Prototypes =====================================*/
366 /**
367  * @brief update function for diagnosis flags
368  * @details TODO
369  */
370 extern void DIAG_UpdateFlags(void);
371 
372 /*========== Externalized Static Functions Prototypes (Unit Test) ===========*/
373 #ifdef UNITY_UNIT_TEST
374 #endif
375 
376 #endif /* FOXBMS__DIAG_CFG_H_ */
Configuration of the battery system (e.g., number of battery modules, battery cells,...
Database configuration header.
void DIAG_CALLBACK_FUNCTION_f(DIAG_ID_e diagId, DIAG_EVENT_e event, const DIAG_DATABASE_SHIM_s *const kpkDiagShim, uint32_t data)
function type for diag callbacks
Definition: diag_cfg.h:326
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_IMPACT_LEVEL_e
Definition: diag_cfg.h:279
@ DIAG_SYSTEM
Definition: diag_cfg.h:280
@ DIAG_STRING
Definition: diag_cfg.h:281
DIAG_EVALUATE_e
Definition: diag_cfg.h:273
@ DIAG_EVALUATION_ENABLED
Definition: diag_cfg.h:274
@ DIAG_EVALUATION_DISABLED
Definition: diag_cfg.h:275
DIAG_SEVERITY_LEVEL_e
Definition: diag_cfg.h:307
@ DIAG_WARNING
Definition: diag_cfg.h:309
@ DIAG_INFO
Definition: diag_cfg.h:310
@ DIAG_FATAL_ERROR
Definition: diag_cfg.h:308
DIAG_ID_e
Definition: diag_cfg.h:176
@ DIAG_ID_AFE_MUX
Definition: diag_cfg.h:182
@ DIAG_ID_TEMP_OVERTEMPERATURE_DISCHARGE_MSL
Definition: diag_cfg.h:205
@ DIAG_ID_POWER_MEASUREMENT_ERROR
Definition: diag_cfg.h:250
@ DIAG_ID_CELL_VOLTAGE_UNDERVOLTAGE_MSL
Definition: diag_cfg.h:199
@ DIAG_ID_PACK_OVERCURRENT_CHARGE_MSL
Definition: diag_cfg.h:226
@ DIAG_ID_I2C_RTC_ERROR
Definition: diag_cfg.h:256
@ DIAG_ID_OVERCURRENT_CHARGE_CELL_RSL
Definition: diag_cfg.h:215
@ DIAG_ID_CURRENT_SENSOR_V2_MEASUREMENT_TIMEOUT
Definition: diag_cfg.h:247
@ DIAG_ID_AFE_CELL_VOLTAGE_MEAS_ERROR
Definition: diag_cfg.h:191
@ DIAG_ID_CAN_CC_RESPONDING
Definition: diag_cfg.h:187
@ DIAG_ID_CURRENT_MEASUREMENT_TIMEOUT
Definition: diag_cfg.h:244
@ DIAG_ID_AFE_CELL_TEMPERATURE_MEAS_ERROR
Definition: diag_cfg.h:192
@ DIAG_ID_RTC_CLOCK_INTEGRITY_ERROR
Definition: diag_cfg.h:257
@ DIAG_ID_TEMP_UNDERTEMPERATURE_CHARGE_MSL
Definition: diag_cfg.h:208
@ DIAG_ID_PLAUSIBILITY_CELL_TEMPERATURE_SPREAD
Definition: diag_cfg.h:195
@ DIAG_ID_TEMP_OVERTEMPERATURE_DISCHARGE_RSL
Definition: diag_cfg.h:206
@ DIAG_ID_STRING_OVERCURRENT_DISCHARGE_MOL
Definition: diag_cfg.h:225
@ DIAG_ID_INSULATION_MEASUREMENT_VALID
Definition: diag_cfg.h:251
@ DIAG_ID_STRING_OVERCURRENT_DISCHARGE_RSL
Definition: diag_cfg.h:224
@ DIAG_ID_PLAUSIBILITY_CELL_VOLTAGE_SPREAD
Definition: diag_cfg.h:194
@ DIAG_ID_BASE_CELL_TEMPERATURE_MEASUREMENT_TIMEOUT
Definition: diag_cfg.h:240
@ DIAG_ID_AFE_OPEN_WIRE
Definition: diag_cfg.h:230
@ DIAG_ID_TEMP_UNDERTEMPERATURE_DISCHARGE_RSL
Definition: diag_cfg.h:212
@ DIAG_ID_CELL_VOLTAGE_UNDERVOLTAGE_RSL
Definition: diag_cfg.h:200
@ DIAG_ID_PLAUSIBILITY_PACK_VOLTAGE
Definition: diag_cfg.h:231
@ DIAG_ID_CELL_VOLTAGE_OVERVOLTAGE_MSL
Definition: diag_cfg.h:196
@ DIAG_ID_STRING_OVERCURRENT_CHARGE_RSL
Definition: diag_cfg.h:221
@ DIAG_ID_STRING_PLUS_CONTACTOR_FEEDBACK
Definition: diag_cfg.h:234
@ DIAG_ID_I2C_PEX_ERROR
Definition: diag_cfg.h:255
@ DIAG_ID_PLAUSIBILITY_CELL_VOLTAGE
Definition: diag_cfg.h:190
@ DIAG_ID_FLASHCHECKSUM
Definition: diag_cfg.h:177
@ DIAG_ID_PLAUSIBILITY_CELL_TEMP
Definition: diag_cfg.h:193
@ DIAG_ID_OVERCURRENT_DISCHARGE_CELL_MSL
Definition: diag_cfg.h:217
@ DIAG_ID_CONFIGASSERT
Definition: diag_cfg.h:179
@ DIAG_ID_TEMP_UNDERTEMPERATURE_CHARGE_RSL
Definition: diag_cfg.h:209
@ DIAG_ID_TEMP_OVERTEMPERATURE_DISCHARGE_MOL
Definition: diag_cfg.h:207
@ DIAG_ID_STRING_OVERCURRENT_CHARGE_MSL
Definition: diag_cfg.h:220
@ DIAG_ID_STRING_MINUS_CONTACTOR_FEEDBACK
Definition: diag_cfg.h:233
@ DIAG_ID_STRING_OVERCURRENT_CHARGE_MOL
Definition: diag_cfg.h:222
@ DIAG_ID_TEMP_OVERTEMPERATURE_CHARGE_MSL
Definition: diag_cfg.h:202
@ DIAG_ID_AFE_COM_INTEGRITY
Definition: diag_cfg.h:181
@ DIAG_ID_CURRENT_SENSOR_POWER_MEASUREMENT_TIMEOUT
Definition: diag_cfg.h:249
@ DIAG_ID_BASE_CELL_VOLTAGE_MEASUREMENT_TIMEOUT
Definition: diag_cfg.h:238
@ DIAG_ID_SYSTEM_MONITORING
Definition: diag_cfg.h:178
@ DIAG_ID_CELL_VOLTAGE_OVERVOLTAGE_RSL
Definition: diag_cfg.h:197
@ DIAG_ID_INSULATION_GROUND_ERROR
Definition: diag_cfg.h:254
@ DIAG_ID_TEMP_OVERTEMPERATURE_CHARGE_MOL
Definition: diag_cfg.h:204
@ DIAG_ID_TEMP_UNDERTEMPERATURE_CHARGE_MOL
Definition: diag_cfg.h:210
@ DIAG_ID_FRAM_READ_CRC_ERROR
Definition: diag_cfg.h:259
@ DIAG_ID_PRECHARGE_ABORT_REASON_CURRENT
Definition: diag_cfg.h:243
@ DIAG_ID_MAX
Definition: diag_cfg.h:262
@ DIAG_ID_SBC_RSTB_STATE
Definition: diag_cfg.h:237
@ DIAG_ID_PRECHARGE_CONTACTOR_FEEDBACK
Definition: diag_cfg.h:235
@ DIAG_ID_CAN_TIMING
Definition: diag_cfg.h:184
@ DIAG_ID_RTC_BATTERY_LOW_ERROR
Definition: diag_cfg.h:258
@ DIAG_ID_PACK_OVERCURRENT_DISCHARGE_MSL
Definition: diag_cfg.h:227
@ DIAG_ID_CURRENT_SENSOR_V1_MEASUREMENT_TIMEOUT
Definition: diag_cfg.h:246
@ DIAG_ID_DEEP_DISCHARGE_DETECTED
Definition: diag_cfg.h:229
@ DIAG_ID_CURRENT_SENSOR_V3_MEASUREMENT_TIMEOUT
Definition: diag_cfg.h:248
@ DIAG_ID_TEMP_UNDERTEMPERATURE_DISCHARGE_MOL
Definition: diag_cfg.h:213
@ DIAG_ID_PRECHARGE_ABORT_REASON_VOLTAGE
Definition: diag_cfg.h:242
@ DIAG_ID_SBC_FIN_STATE
Definition: diag_cfg.h:236
@ DIAG_ID_CELL_VOLTAGE_UNDERVOLTAGE_MOL
Definition: diag_cfg.h:201
@ DIAG_ID_LOW_INSULATION_RESISTANCE_ERROR
Definition: diag_cfg.h:252
@ DIAG_ID_CELL_VOLTAGE_OVERVOLTAGE_MOL
Definition: diag_cfg.h:198
@ DIAG_ID_CURRENT_ON_OPEN_STRING
Definition: diag_cfg.h:228
@ DIAG_ID_STRING_OVERCURRENT_DISCHARGE_MSL
Definition: diag_cfg.h:223
@ DIAG_ID_REDUNDANCY0_CELL_VOLTAGE_MEASUREMENT_TIMEOUT
Definition: diag_cfg.h:239
@ DIAG_ID_OVERCURRENT_CHARGE_CELL_MSL
Definition: diag_cfg.h:214
@ DIAG_ID_OVERCURRENT_DISCHARGE_CELL_MOL
Definition: diag_cfg.h:219
@ DIAG_ID_CURRENT_SENSOR_RESPONDING
Definition: diag_cfg.h:189
@ DIAG_ID_CURRENT_MEASUREMENT_ERROR
Definition: diag_cfg.h:245
@ DIAG_ID_CAN_RX_QUEUE_FULL
Definition: diag_cfg.h:185
@ DIAG_ID_AEROSOL_ALERT
Definition: diag_cfg.h:261
@ DIAG_ID_AFE_SPI
Definition: diag_cfg.h:180
@ DIAG_ID_OVERCURRENT_CHARGE_CELL_MOL
Definition: diag_cfg.h:216
@ DIAG_ID_CAN_EC_RESPONDING
Definition: diag_cfg.h:188
@ DIAG_ID_ALERT_MODE
Definition: diag_cfg.h:260
@ DIAG_ID_CAN_TX_QUEUE_FULL
Definition: diag_cfg.h:186
@ DIAG_ID_TEMP_OVERTEMPERATURE_CHARGE_RSL
Definition: diag_cfg.h:203
@ DIAG_ID_INTERLOCK_FEEDBACK
Definition: diag_cfg.h:232
@ DIAG_ID_OVERCURRENT_DISCHARGE_CELL_RSL
Definition: diag_cfg.h:218
@ DIAG_ID_AFE_CONFIG
Definition: diag_cfg.h:183
@ DIAG_ID_TEMP_UNDERTEMPERATURE_DISCHARGE_MSL
Definition: diag_cfg.h:211
@ DIAG_ID_REDUNDANCY0_CELL_TEMPERATURE_MEASUREMENT_TIMEOUT
Definition: diag_cfg.h:241
@ DIAG_ID_LOW_INSULATION_RESISTANCE_WARNING
Definition: diag_cfg.h:253
void DIAG_UpdateFlags(void)
update function for diagnosis flags
Definition: diag_cfg.c:250
const DIAG_DATABASE_SHIM_s diag_kDatabaseShim
Definition: diag_cfg.c:113
DIAG_ID_CFG_s diag_diagnosisIdConfiguration[DIAG_ID_MAX]
Definition: diag_cfg.c:124
DIAG_DEV_s diag_device
Definition: diag_cfg.c:240
DIAG_RECORDING_e
Definition: diag_cfg.h:314
@ DIAG_RECORDING_ENABLED
Definition: diag_cfg.h:315
@ DIAG_RECORDING_DISABLED
Definition: diag_cfg.h:316
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
DATA_BLOCK_ERROR_STATE_s * pTableError
Definition: diag_cfg.h:166
uint8_t nrOfConfiguredDiagnosisEntries
Definition: diag_cfg.h:353
DIAG_ID_CFG_s * pConfigurationOfDiagnosisEntries
Definition: diag_cfg.h:354
uint16_t numberOfFatalErrors
Definition: diag_cfg.h:355
DIAG_RECORDING_e enable_recording
Definition: diag_cfg.h:343
DIAG_SEVERITY_LEVEL_e severity
Definition: diag_cfg.h:340
uint32_t delay_ms
Definition: diag_cfg.h:342
DIAG_CALLBACK_FUNCTION_f * fpCallback
Definition: diag_cfg.h:345
uint16_t threshold
Definition: diag_cfg.h:335
DIAG_EVALUATE_e enable_evaluate
Definition: diag_cfg.h:344
DIAG_ID_e id
Definition: diag_cfg.h:334