foxBMS  1.0.0
The foxBMS Battery Management System API Documentation
bms.c
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 bms.c
44  * @author foxBMS Team
45  * @date 2020-02-24 (date of creation)
46  * @updated 2021-03-24 (date of last update)
47  * @ingroup ENGINE
48  * @prefix BMS
49  *
50  * @brief bms driver implementation
51  */
52 
53 /*========== Includes =======================================================*/
54 #include "bms.h"
55 
56 #include "battery_cell_cfg.h"
57 
58 #include "bal.h"
59 #include "contactor.h"
60 #include "database.h"
61 #include "diag.h"
62 #include "foxmath.h"
63 #include "interlock.h"
64 #include "meas.h"
65 #include "mic.h"
66 #include "os.h"
67 #include "soa.h"
68 
69 /*========== Macros and Definitions =========================================*/
70 
71 /**
72  * Saves the last state and the last substate
73  */
74 #define BMS_SAVELASTSTATES() \
75  bms_state.laststate = bms_state.state; \
76  bms_state.lastsubstate = bms_state.substate
77 
78 /*========== Static Constant and Variable Definitions =======================*/
79 
80 /**
81  * contains the state of the bms state machine
82  */
84  .timer = 0,
85  .stateRequest = BMS_STATE_NO_REQUEST,
87  .substate = BMS_ENTRY,
88  .laststate = BMS_STATEMACH_UNINITIALIZED,
89  .lastsubstate = BMS_ENTRY,
90  .triggerentry = 0u,
91  .ErrRequestCounter = 0u,
92  .initFinished = STD_NOT_OK,
93  .counter = 0u,
94  .OscillationTimeout = 0u,
95  .PrechargeTryCounter = 0u,
96  .powerline = BMS_PL_OPEN,
97  .closedStrings = {0u},
98  .closedPrechargeContactors = {0u},
99  .numberOfClosedStrings = 0u,
100  .deactivatedStrings = {0},
101  .firstClosedString = 0u,
102  .stringOpenTimeout = 0u,
103  .nextstringclosedtimer = 0u,
104  .stringCloseTimeout = 0u,
105  .nextstate = BMS_STATEMACH_STANDBY,
106  .restTimer_10ms = BS_RELAXATION_PERIOD_10ms,
107  .currentFlowState = BMS_RELAXATION,
108 };
109 
110 /** local copies of database tables */
111 /**@{*/
115 /**@}*/
116 
117 /*========== Extern Constant and Variable Definitions =======================*/
118 
119 /*========== Static Function Prototypes =====================================*/
120 
121 /**
122  * @brief checks the state requests that are made.
123  * @details This function checks the validity of the state requests. The
124  * results of the checked is returned immediately.
125  * @param[in] statereq state request to be checked
126  * @return result of the state request that was made
127  */
129 
130 /**
131  * @brief transfers the current state request to the state machine.
132  * @details This function takes the current state request from #bms_state
133  * transfers it to the state machine. It resets the value from
134  * #bms_state to #BMS_STATE_NO_REQUEST
135  * @return current state request
136  */
138 
139 /**
140  * @brief re-entrance check of SYS state machine trigger function
141  * @details This function is not re-entrant and should only be called time- or
142  * event-triggered. It increments the triggerentry counter from the
143  * state variable ltc_state. It should never be called by two
144  * different processes, so if it is the case, triggerentry should
145  * never be higher than 0 when this function is called.
146  * @return retval 0 if no further instance of the function is active, 0xff
147  * else
148  */
149 static uint8_t BMS_CheckReEntrance(void);
150 
151 /**
152  * @brief Checks the state requests made to the BMS state machine.
153  * @details Checks of the state request in the database and sets this value as
154  * return value.
155  * @return requested state
156  */
157 static uint8_t BMS_CheckCanRequests(void);
158 
159 /**
160  * @brief Checks the error flags
161  * @details Checks all the error flags from the database and returns an error
162  * if at least one is set.
163  * @return #STD_OK if no error flag is set, otherwise #STD_NOT_OK
164  */
166 
167 /** Get latest database entries for static module variables */
168 static void BMS_GetMeasurementValues(void);
169 
170 /**
171  * @brief Check for any open voltage sense wire
172  */
173 static void BMS_CheckOpenSenseWire(void);
174 
175 /**
176  * @brief Checks if the current limitations are violated
177  * @param[in] stringNumber string addressed
178  * @param[in] pPackValues pointer to pack values database entry
179  * @return #STD_OK if the current limitations are NOT violated, else
180  * #STD_NOT_OK (type: #STD_RETURN_TYPE_e)
181  */
182 static STD_RETURN_TYPE_e BMS_CheckPrecharge(uint8_t stringNumber, const DATA_BLOCK_PACK_VALUES_s *pPackValues);
183 
184 /**
185  * @brief Returns ID of string with highest total voltage
186  * @details This is used to close the first string when drive-off is requested.
187  * @param[in] precharge If #BMS_DO_NOT_TAKE_PRECHARGE_INTO_ACCCOUNT,
188  * precharge availability for string is ignored.
189  * if #BMS_TAKE_PRECHARGE_INTO_ACCCOUNT, only select
190  * string that has precharge available.
191  * @param[in] pPackValues pointer to pack values database entry
192  * @return index of string with highest voltage If no string is available,
193  * returns #BMS_NO_STRING_AVAILABLE.
194  */
195 static uint8_t BMS_GetHighestString(BMS_CONSIDER_PRECHARGE_e precharge, DATA_BLOCK_PACK_VALUES_s *pPackValues);
196 
197 /**
198  * @brief Returns ID of string with voltage closest to first closed string voltage
199  * @details This is used to close further strings in drive.
200  * @param[in] precharge If #BMS_DO_NOT_TAKE_PRECHARGE_INTO_ACCCOUNT,
201  * precharge availability for string is ignored.
202  * if #BMS_TAKE_PRECHARGE_INTO_ACCCOUNT, only select
203  * string that has precharge available.
204  * @param[in] pPackValues pointer to pack values database entry
205  * @return index of string with voltage closest to the first closed string voltage.
206  * If no string is available, returns #BMS_NO_STRING_AVAILABLE.
207  */
208 static uint8_t BMS_GetClosestString(BMS_CONSIDER_PRECHARGE_e precharge, DATA_BLOCK_PACK_VALUES_s *pPackValues);
209 
210 /**
211  * @brief Returns ID of string with lowest total voltage
212  * @details This is used to close the first string when charge-off is requested.
213  *
214  * @param[in] precharge If 0, precharge availability for string is ignored.
215  * If 1, only selects a string that has precharge
216  * available.
217  * @param[in] pPackValues pointer to pack values database entry
218  * @return index of string with lowest voltage. If no string is available,
219  * returns #BMS_NO_STRING_AVAILABLE.
220  */
221 static uint8_t BMS_GetLowestString(BMS_CONSIDER_PRECHARGE_e precharge, DATA_BLOCK_PACK_VALUES_s *pPackValues);
222 
223 /**
224  * @brief Returns voltage difference between first closed string and
225  * string ID
226  * @details This function is used to check voltage when trying to close further
227  * strings.
228  * @param[in] string ID of string that must be compared with first closed
229  * string
230  * @param[in] pPackValues pointer to pack values database entry
231  * @return voltage difference in mV, will return INT32_MAX if voltages are
232  * invalid and difference can not be calculated
233  */
234 static int32_t BMS_GetStringVoltageDifference(uint8_t string, const DATA_BLOCK_PACK_VALUES_s *pPackValues);
235 
236 /**
237  * @brief Returns the average current flowing through all strings.
238  * @details This function is used when closing strings.
239  * @param[in] pPackValues pointer to pack values database entry
240  * @return average current taking all strings into account in mA. INT32_MAX if there is no valid current measurement
241  */
242 static int32_t BMS_GetAverageStringCurrent(DATA_BLOCK_PACK_VALUES_s *pPackValues);
243 
244 /**
245  * @brief Updates battery system state variable depending on measured/recent
246  * current values
247  * @param[in] pPackValues recent measured values from current sensor
248  */
249 static void BMS_UpdateBatsysState(DATA_BLOCK_PACK_VALUES_s *pPackValues);
250 
251 /*========== Static Function Implementations ================================*/
252 
254  if (statereq == BMS_STATE_ERROR_REQUEST) {
255  return BMS_OK;
256  }
257 
259  /* init only allowed from the uninitialized state */
260  if (statereq == BMS_STATE_INIT_REQUEST) {
262  return BMS_OK;
263  } else {
265  }
266  } else {
267  return BMS_ILLEGAL_REQUEST;
268  }
269  } else {
270  return BMS_REQUEST_PENDING;
271  }
272 }
273 
274 static uint8_t BMS_CheckReEntrance(void) {
275  uint8_t retval = 0;
277  if (!bms_state.triggerentry) {
279  } else {
280  retval = 0xFF; /* multiple calls of function */
281  }
283  return retval;
284 }
285 
288 
290  retval = bms_state.stateRequest;
293  return retval;
294 }
295 
296 static void BMS_GetMeasurementValues(void) {
298 }
299 
300 static uint8_t BMS_CheckCanRequests(void) {
301  uint8_t retVal = BMS_REQ_ID_NOREQ;
303 
304  DATA_READ_DATA(&request);
305 
306  if (request.stateRequestViaCan == BMS_REQ_ID_STANDBY) {
307  retVal = BMS_REQ_ID_STANDBY;
308  } else if (request.stateRequestViaCan == BMS_REQ_ID_NORMAL) {
309  retVal = BMS_REQ_ID_NORMAL;
310  }
311 
312 #if BS_SEPARATE_POWERLINES == 1
313  else if (request.stateRequestViaCan == BMS_REQ_ID_CHARGE) { /* NOLINT(readability/braces) */
314  retVal = BMS_REQ_ID_CHARGE;
315  }
316 #endif /* BS_SEPARATE_POWERLINES == 1 */
317 
318  return retVal;
319 }
320 
321 static void BMS_CheckOpenSenseWire(void) {
322  uint8_t openWireDetected = 0;
323 
324  for (uint8_t s = 0u; s < BS_NR_OF_STRINGS; s++) {
325  /* Iterate over all modules */
326  for (uint8_t m = 0u; m < BS_NR_OF_MODULES; m++) {
327  /* Iterate over all voltage sense wires: cells per module + 1 */
328  for (uint8_t wire = 0u; wire < (BS_NR_OF_CELLS_PER_MODULE + 1); wire++) {
329  /* open wire detected */
330  if (bms_tableOpenWire.openwire[s][(wire + (m * (BS_NR_OF_CELLS_PER_MODULE + 1))) == 1] > 0u) {
331  openWireDetected++;
332 
333  /* Add additional error handling here */
334  }
335  }
336  }
337  /* Set error if open wire detected */
338  if (openWireDetected == 0u) {
340  } else {
342  }
343  }
344 }
345 
346 static STD_RETURN_TYPE_e BMS_CheckPrecharge(uint8_t stringNumber, const DATA_BLOCK_PACK_VALUES_s *pPackValues) {
347  STD_RETURN_TYPE_e retVal = STD_NOT_OK;
348  /* make sure that we do not access the arrays in the database
349  tables out of bounds */
350  FAS_ASSERT(stringNumber < BS_NR_OF_STRINGS);
351  FAS_ASSERT(pPackValues != NULL_PTR);
352 
353  /* Only check precharging if current value and voltages are valid */
354  if ((0u == pPackValues->invalidStringCurrent[stringNumber]) &&
355  (0u == pPackValues->invalidStringVoltage[stringNumber]) && (0u == pPackValues->invalidHvBusVoltage)) {
356  /* Only current not current direction is checked */
357  const int32_t current_mA = MATH_AbsInt32(pPackValues->stringCurrent_mA[stringNumber]);
358  const int64_t cont_prechargeVoltDiff_mV = MATH_AbsInt64(
359  (int64_t)pPackValues->stringVoltage_mV[stringNumber] - (int64_t)pPackValues->highVoltageBusVoltage_mV);
360 
361  if ((cont_prechargeVoltDiff_mV < BMS_PRECHARGE_VOLTAGE_THRESHOLD_mV) &&
362  (current_mA < BMS_PRECHARGE_CURRENT_THRESHOLD_mA)) {
363  retVal = STD_OK;
364  } else {
365  retVal = STD_NOT_OK;
366  }
367  }
368 
369  return retVal;
370 }
371 
373  STD_RETURN_TYPE_e retVal = STD_OK; /* is set to STD_NOT_OK if error detected */
376 
377  DATA_READ_DATA(&error_flags);
378  DATA_READ_DATA(&msl_flags);
379 
380  for (uint8_t s = 0u; s < BS_NR_OF_STRINGS; s++) {
381  /* Check maximum safety limit flags */
382  if ((error_flags.currentOnOpenString[s] == 1u) || (msl_flags.cellChargeOvercurrent[s] == 1u) ||
383  (msl_flags.stringDischargeOvercurrent[s] == 1u) || (msl_flags.cellDischargeOvercurrent[s] == 1u) ||
384  (msl_flags.stringChargeOvercurrent[s] == 1u) || (msl_flags.overVoltage[s] == 1u) ||
385  (msl_flags.underVoltage[s] == 1u) || (msl_flags.overtemperatureCharge[s] == 1u) ||
386  (msl_flags.overtemperatureDischarge[s] == 1u) || (msl_flags.undertemperatureCharge[s] == 1u) ||
387  (msl_flags.undertemperatureDischarge[s] == 1u)) {
388  /* error detected */
389  retVal = STD_NOT_OK;
390  }
391  }
392 
393  for (uint8_t s = 0u; s < BS_NR_OF_STRINGS; s++) {
394  /* Check system error flags */
395  if ((error_flags.deepDischargeDetected[s] == 1u) || (error_flags.fuseStateNormal[s] == 1u) ||
396  (error_flags.fuseStateCharge[s] == 1u) || (error_flags.crcError[s] == 1u) ||
397  (error_flags.muxError[s] == 1u) || (error_flags.spiError[s] == 1u) ||
398  (error_flags.micConfigurationError[s] == 1u) || (error_flags.currentSensor[s] == 1u) ||
399  (error_flags.open_wire[s] == 1u) || (error_flags.stringContactor[s] == 1u) ||
400  (error_flags.prechargeContactor[s] == 1u) || (error_flags.canTimingCc[s] == 1u) ||
401  (error_flags.canTimingEc[s] == 1u)) {
402  /* error detected */
403  retVal = STD_NOT_OK;
404  }
405  }
406 
407  if ((msl_flags.packDischargeOvercurrent == 1u) || (msl_flags.packChargeOvercurrent == 1u) ||
409  (error_flags.insulationError == 1u) ||
410 #endif /* BMS_OPEN_CONTACTORS_ON_INSULATION_ERROR */
411  (error_flags.interlock == 1u) || (error_flags.canTiming == 1u)) {
412  /* error detected */
413  retVal = STD_NOT_OK;
414  }
415 
416  return retVal;
417 }
418 
420  FAS_ASSERT(pPackValues != NULL_PTR);
421  uint8_t highest_string_index = BMS_NO_STRING_AVAILABLE;
422  int32_t max_stringVoltage_mV = INT32_MIN;
423 
424  for (uint8_t s = 0u; s < BS_NR_OF_STRINGS; s++) {
425  if ((pPackValues->stringVoltage_mV[s] >= max_stringVoltage_mV) &&
426  (0u == pPackValues->invalidStringVoltage[s])) {
427  if (bms_state.deactivatedStrings[s] == 0u) {
428  if (precharge == BMS_DO_NOT_TAKE_PRECHARGE_INTO_ACCCOUNT) {
429  max_stringVoltage_mV = pPackValues->stringVoltage_mV[s];
430  highest_string_index = s;
431  } else {
433  max_stringVoltage_mV = pPackValues->stringVoltage_mV[s];
434  highest_string_index = s;
435  }
436  }
437  }
438  }
439  }
440 
441  return highest_string_index;
442 }
443 
445  FAS_ASSERT(pPackValues != NULL_PTR);
446  uint8_t closestStringIndex = BMS_NO_STRING_AVAILABLE;
447  int32_t closedStringVoltage_mV = 0;
448  bool searchString = false;
449 
450  /* Get voltage of first closed string */
451  if (0u == pPackValues->invalidStringVoltage[bms_state.firstClosedString]) {
452  closedStringVoltage_mV = pPackValues->stringVoltage_mV[bms_state.firstClosedString];
453  searchString = true;
454  } else if (0u == pPackValues->invalidHvBusVoltage) {
455  /* Use high voltage bus voltage if measured string voltage is invalid */
456  closedStringVoltage_mV = pPackValues->highVoltageBusVoltage_mV;
457  searchString = true;
458  } else {
459  /* Do not search for next string if no valid voltages could be measured */
460  searchString = false;
461  }
462 
463  if (true == searchString) {
464  for (uint8_t s = 0u; s < BS_NR_OF_STRINGS; s++) {
465  const bool isStringClosed = BMS_IsStringClosed(s);
466  const uint8_t isStringVoltageValid = pPackValues->invalidStringVoltage[s];
467  if ((false == isStringClosed) && (0u == isStringVoltageValid)) {
468  /* Only check open strings with valid voltages */
469  int32_t minimumVoltageDifference_mV = INT32_MAX;
470  int32_t voltageDifference_mV = labs(closedStringVoltage_mV - pPackValues->stringVoltage_mV[s]);
471  if (voltageDifference_mV <= minimumVoltageDifference_mV) {
472  if (bms_state.deactivatedStrings[s] == 0u) {
473  if (precharge == BMS_TAKE_PRECHARGE_INTO_ACCCOUNT) {
475  minimumVoltageDifference_mV = voltageDifference_mV;
476  closestStringIndex = s;
477  }
478  } else {
479  minimumVoltageDifference_mV = voltageDifference_mV;
480  closestStringIndex = s;
481  }
482  }
483  }
484  }
485  }
486  }
487  return closestStringIndex;
488 }
489 
491  FAS_ASSERT(pPackValues != NULL_PTR);
492  uint8_t lowest_string_index = BMS_NO_STRING_AVAILABLE;
493  int32_t min_stringVoltage_mV = INT32_MAX;
494 
495  for (uint8_t s = 0u; s < BS_NR_OF_STRINGS; s++) {
496  if ((pPackValues->stringVoltage_mV[s] <= min_stringVoltage_mV) &&
497  (0u == pPackValues->invalidStringVoltage[s])) {
498  if (bms_state.deactivatedStrings[s] == 0u) {
499  if (precharge == BMS_DO_NOT_TAKE_PRECHARGE_INTO_ACCCOUNT) {
500  min_stringVoltage_mV = pPackValues->stringVoltage_mV[s];
501  lowest_string_index = s;
502  } else {
504  min_stringVoltage_mV = pPackValues->stringVoltage_mV[s];
505  lowest_string_index = s;
506  }
507  }
508  }
509  }
510  }
511  return lowest_string_index;
512 }
513 
514 static int32_t BMS_GetStringVoltageDifference(uint8_t string, const DATA_BLOCK_PACK_VALUES_s *pPackValues) {
515  FAS_ASSERT(string < BS_NR_OF_STRINGS);
516  FAS_ASSERT(pPackValues != NULL_PTR);
517  int32_t voltageDifference_mV = INT32_MAX;
518  if ((0u == pPackValues->invalidStringVoltage[string]) &&
519  (0u == pPackValues->invalidStringVoltage[bms_state.firstClosedString])) {
520  /* Calculate difference between string voltages */
521  voltageDifference_mV = MATH_AbsInt32(
522  pPackValues->stringVoltage_mV[string] - pPackValues->stringVoltage_mV[bms_state.firstClosedString]);
523  } else if ((0u == pPackValues->invalidStringVoltage[string]) && (0u == pPackValues->invalidHvBusVoltage)) {
524  /* Calculate difference between string and high voltage bus voltage */
525  voltageDifference_mV =
526  MATH_AbsInt32(pPackValues->stringVoltage_mV[string] - pPackValues->highVoltageBusVoltage_mV);
527  } else {
528  /* No valid voltages for comparison -> do not calculate difference and return INT32_MAX */
529  voltageDifference_mV = INT32_MAX;
530  }
531  return voltageDifference_mV;
532 }
533 
535  FAS_ASSERT(pPackValues != NULL_PTR);
536  int32_t average_current = pPackValues->packCurrent_mA / (int32_t)BS_NR_OF_STRINGS;
537  if (1u == pPackValues->invalidPackCurrent) {
538  average_current = INT32_MAX;
539  }
540  return average_current;
541 }
542 
544  FAS_ASSERT(pPackValues != NULL_PTR);
545 
546  /* Only update system state if current value is valid */
547  if (0u == pPackValues->invalidPackCurrent) {
548  if (POSITIVE_DISCHARGE_CURRENT == true) {
549  /* Positive current values equal a discharge of the battery system */
550  if (pPackValues->packCurrent_mA >= BS_REST_CURRENT_mA) { /* TODO: string use pack current */
553  } else if (pPackValues->packCurrent_mA <= -BS_REST_CURRENT_mA) {
556  } else {
557  /* Current below rest current: either battery system is at rest
558  * or the relaxation process is still ongoing */
559  if (bms_state.restTimer_10ms == 0u) {
560  /* Rest timer elapsed -> battery system at rest */
562  } else {
565  }
566  }
567  } else {
568  /* Negative current values equal a discharge of the battery system */
569  if (pPackValues->packCurrent_mA <= -BS_REST_CURRENT_mA) {
572  } else if (pPackValues->packCurrent_mA >= BS_REST_CURRENT_mA) {
575  } else {
576  /* Current below rest current: either battery system is at rest
577  * or the relaxation process is still ongoing */
578  if (bms_state.restTimer_10ms == 0u) {
579  /* Rest timer elapsed -> battery system at rest */
581  } else {
584  }
585  }
586  }
587  }
588 }
589 
590 /*========== Extern Function Implementations ================================*/
591 
593  return bms_state.initFinished;
594 }
595 
597  return bms_state.state;
598 }
599 
601  BMS_RETURN_TYPE_e retVal = BMS_OK;
602 
604  retVal = BMS_CheckStateRequest(statereq);
605 
606  if (retVal == BMS_OK) {
607  bms_state.stateRequest = statereq;
608  }
610 
611  return retVal;
612 }
613 
614 void BMS_Trigger(void) {
617  uint32_t timestamp = OS_GetTickCount();
618  static uint32_t nextOpenWireCheck = 0;
619  STD_RETURN_TYPE_e retVal = STD_NOT_OK;
620  static uint8_t stringNumber = 0u;
621  static uint8_t nextStringNumber = 0u;
623  STD_RETURN_TYPE_e contRetVal = STD_NOT_OK;
624 
634  }
635  /* Check re-entrance of function */
636  if (BMS_CheckReEntrance() > 0u) {
637  return;
638  }
639 
640  if (bms_state.nextstringclosedtimer > 0u) {
642  }
643  if (bms_state.stringOpenTimeout > 0u) {
645  }
646 
647  if (bms_state.stringCloseTimeout > 0u) {
649  }
650 
651  if (bms_state.OscillationTimeout > 0u) {
653  }
654 
655  if (bms_state.timer > 0u) {
656  if ((--bms_state.timer) > 0u) {
658  return; /* handle state machine only if timer has elapsed */
659  }
660  }
661 
662  /****Happens every time the state machine is triggered**************/
663  switch (bms_state.state) {
664  /****************************UNINITIALIZED****************************/
666  /* waiting for Initialization Request */
667  statereq = BMS_TransferStateRequest();
668  if (statereq == BMS_STATE_INIT_REQUEST) {
673  } else if (statereq == BMS_STATE_NO_REQUEST) {
674  /* no actual request pending */
675  } else {
676  bms_state.ErrRequestCounter++; /* illegal request pending */
677  }
678  break;
679 
680  /****************************INITIALIZATION***************************/
683 
687  break;
688 
689  /****************************INITIALIZED******************************/
696  break;
697 
698  /****************************IDLE*************************************/
699  case BMS_STATEMACH_IDLE:
701 
702  if (bms_state.substate == BMS_ENTRY) {
703  DATA_READ_DATA(&systemstate);
704  systemstate.bmsCanState = BMS_CANSTATE_IDLE;
705  DATA_WRITE_DATA(&systemstate);
708  break;
709  } else if (bms_state.substate == BMS_CHECK_ERROR_FLAGS) {
715  break;
716  } else {
719  break;
720  }
727  break;
728  } else {
731  break;
732  }
733  }
734  break;
735 
736  /****************************OPEN CONTACTORS**************************/
739 
740  if (bms_state.substate == BMS_ENTRY) {
744  break;
746  for (stringNumber = 0u; stringNumber < BS_NR_OF_STRINGS; stringNumber++) {
747  if (bs_stringsWithPrecharge[stringNumber] == BS_STRING_WITH_PRECHARGE) {
748  CONT_OpenPrecharge(stringNumber);
749  bms_state.closedPrechargeContactors[stringNumber] = 0u;
750  }
751  }
752  /* Now go to string opening */
753  stringNumber = BS_NR_OF_STRINGS - 1u; /* Select last string */
756  } else if (bms_state.substate == BMS_OPEN_STRINGS) {
757  CONT_OpenString(stringNumber);
761  break;
762  } else if (bms_state.substate == BMS_CHECK_STRING_OPEN) {
763  contstate = CONT_GetState(stringNumber);
764  if (contstate == CONT_SWITCH_OFF) {
765  if (bms_state.numberOfClosedStrings > 0u) {
767  }
768  bms_state.closedStrings[stringNumber] = 0u;
769  if (stringNumber > 0u) {
770  stringNumber--;
773  break;
774  } else {
777  }
778  break;
779  } else if (bms_state.stringOpenTimeout == 0u) {
780  /* String takes too long to close, go to next string */
783  break;
784  } else {
785  /* String not opened, re-issue closing request */
786  CONT_OpenString(nextStringNumber);
788  break;
789  }
790  } else if (bms_state.substate == BMS_OPEN_STRINGS_EXIT) {
795  break;
796  } else {
800  }
801  }
802  break;
803 
804  /****************************STANDBY**********************************/
807  if (bms_state.substate == BMS_ENTRY) {
810 #if LTC_STANDBY_PERIODIC_OPEN_WIRE_CHECK == TRUE
811  nextOpenWireCheck = timestamp + LTC_STANDBY_OPEN_WIRE_PERIOD_ms;
812 #endif /* LTC_STANDBY_PERIODIC_OPEN_WIRE_CHECK == TRUE */
815  DATA_READ_DATA(&systemstate);
816  systemstate.bmsCanState = BMS_CANSTATE_STANDBY;
817  DATA_WRITE_DATA(&systemstate);
818  break;
825  break;
826  } else {
829  break;
830  }
831  } else if (bms_state.substate == BMS_INTERLOCK_CHECKED) {
834  break;
835  } else if (bms_state.substate == BMS_CHECK_ERROR_FLAGS) {
841  break;
842  } else {
845  break;
846  }
854  break;
855  }
862  break;
863  } else {
864 #if LTC_STANDBY_PERIODIC_OPEN_WIRE_CHECK == TRUE
865  if (nextOpenWireCheck <= timestamp) {
867  nextOpenWireCheck = timestamp + LTC_STANDBY_OPEN_WIRE_PERIOD_ms;
868  }
869 #endif /* LTC_STANDBY_PERIODIC_OPEN_WIRE_CHECK == TRUE */
872  break;
873  }
874  }
875  break;
876 
877  /****************************PRECHARGE********************************/
880 
881  if (bms_state.substate == BMS_ENTRY) {
882  DATA_READ_DATA(&systemstate);
883  systemstate.bmsCanState = BMS_CANSTATE_PRECHARGE;
884  DATA_WRITE_DATA(&systemstate);
887  } else {
889  }
890  if (stringNumber == BMS_NO_STRING_AVAILABLE) {
895  break;
896  }
897  bms_state.firstClosedString = stringNumber;
898  if (bms_state.OscillationTimeout == 0u) {
901  } else if (BMS_CheckAnyErrorFlagSet() == STD_NOT_OK) {
902  /* If precharge re-enter timeout not elapsed, wait (and check errors while waiting) */
907  break;
908  }
909  break;
913  bms_state.closedPrechargeContactors[stringNumber] = 1u;
914  if (contRetVal == STD_OK) {
918  } else {
923  }
924  break;
931  break;
932  } else {
935  break;
936  }
943  break;
944  } else {
947  }
950  if (retVal == STD_OK) {
954  break;
955  } else {
958  bms_state.closedPrechargeContactors[stringNumber] = 0u;
959  if (contRetVal == STD_OK) {
963  } else {
968  }
969  break;
970  } else {
972  bms_state.closedPrechargeContactors[stringNumber] = 0u;
977  break;
978  }
979  }
987  if (contstate == CONT_SWITCH_ON) {
992  break;
993  } else if (bms_state.stringCloseTimeout == 0u) {
994  /* String takes too long to close */
999  break;
1000  } else {
1001  /* String not closed, re-issue closing request */
1005  break;
1006  }
1013  break;
1014  } else {
1017  break;
1018  }
1020  /* Always make one error check after the first string was closed successfully */
1026  break;
1027  } else {
1030  break;
1031  }
1034  if (contRetVal == STD_OK) {
1035  bms_state.closedPrechargeContactors[stringNumber] = 0u;
1039  } else {
1044  }
1045  break;
1046  }
1047  break;
1048 
1049  /****************************NORMAL**************************************/
1050  case BMS_STATEMACH_NORMAL:
1052 
1053  if (bms_state.substate == BMS_ENTRY) {
1054 #if LTC_NORMAL_PERIODIC_OPEN_WIRE_CHECK == TRUE
1055  nextOpenWireCheck = timestamp + LTC_NORMAL_OPEN_WIRE_PERIOD_ms;
1056 #endif /* LTC_NORMAL_PERIODIC_OPEN_WIRE_CHECK == TRUE */
1057  DATA_READ_DATA(&systemstate);
1059  systemstate.bmsCanState = BMS_CANSTATE_CHARGE;
1060  } else {
1061  systemstate.bmsCanState = BMS_CANSTATE_NORMAL;
1062  }
1063  DATA_WRITE_DATA(&systemstate);
1067  break;
1068  } else if (bms_state.substate == BMS_CHECK_ERROR_FLAGS) {
1073  break;
1074  } else {
1077  break;
1078  }
1085  break;
1086  } else {
1087 #if LTC_NORMAL_PERIODIC_OPEN_WIRE_CHECK == TRUE
1088  if (nextOpenWireCheck <= timestamp) {
1090  nextOpenWireCheck = timestamp + LTC_NORMAL_OPEN_WIRE_PERIOD_ms;
1091  }
1092 #endif /* LTC_NORMAL_PERIODIC_OPEN_WIRE_CHECK == TRUE */
1095  break;
1096  }
1098  if (bms_state.nextstringclosedtimer == 0u) {
1099  nextStringNumber =
1101  if (nextStringNumber == BMS_NO_STRING_AVAILABLE) {
1104  break;
1105  } else if (
1106  (BMS_GetStringVoltageDifference(nextStringNumber, &bms_tablePackValues) <=
1109  /* Voltage/current conditions suitable to close a further string */
1110  CONT_CloseString(nextStringNumber);
1114  break;
1115  }
1116  } else {
1119  break;
1120  }
1121  } else if (bms_state.substate == BMS_CHECK_STRING_CLOSED) {
1122  contstate = CONT_GetState(nextStringNumber);
1123  if (contstate == CONT_SWITCH_ON) {
1125  bms_state.closedStrings[nextStringNumber] = 1u;
1127  /* Go to begin of NORMAL case to redo the full procedure with error check and request check */
1129  break;
1130  } else if (bms_state.stringCloseTimeout == 0u) {
1131  /* String takes too long to close */
1136  break;
1137  } else if (BMS_CheckAnyErrorFlagSet() == STD_NOT_OK) {
1142  break;
1143  } else if (BMS_CheckCanRequests() == BMS_REQ_ID_STANDBY) {
1148  break;
1149  } else {
1150  /* String not closed, re-issue closing request */
1151  CONT_CloseString(nextStringNumber);
1153  break;
1154  }
1155  }
1156  break;
1157 
1158  /****************************ERROR*************************************/
1159  case BMS_STATEMACH_ERROR:
1161 
1162  if (bms_state.substate == BMS_ENTRY) {
1166  DATA_READ_DATA(&systemstate);
1167  systemstate.bmsCanState = BMS_CANSTATE_ERROR;
1168  DATA_WRITE_DATA(&systemstate);
1169  break;
1170  } else if (bms_state.substate == BMS_OPEN_INTERLOCK) {
1172  nextOpenWireCheck = timestamp + MIC_ERROR_OPEN_WIRE_PERIOD_ms;
1175  break;
1176  } else if (bms_state.substate == BMS_CHECK_ERROR_FLAGS) {
1178  /* we stay already in requested state */
1179  if (nextOpenWireCheck <= timestamp) {
1180  /* Perform open-wire check periodically */
1181  /* MEAS_RequestOpenWireCheck(); */ /*TODO: check with strings */
1182  nextOpenWireCheck = timestamp + MIC_ERROR_OPEN_WIRE_PERIOD_ms;
1183  }
1184  } else {
1187  break;
1188  }
1195  /* TODO: above and below this line are redundant assignments */
1198  break;
1199  } else {
1202  break;
1203  }
1206  /* TODO: check */
1212  break;
1213  } else {
1216  break;
1217  }
1218  }
1219  break;
1220  default:
1221  /* invalid state */
1223  break;
1224  } /* end switch (bms_state.state) */
1225 
1227  bms_state.counter++;
1228 }
1229 
1231  return bms_state.currentFlowState;
1232 }
1233 
1236 
1237  if (POSITIVE_DISCHARGE_CURRENT == true) {
1238  if (current_mA >= BS_REST_CURRENT_mA) {
1239  retVal = BMS_DISCHARGING;
1240  } else if (current_mA <= -BS_REST_CURRENT_mA) {
1241  retVal = BMS_CHARGING;
1242  } else {
1243  retVal = BMS_AT_REST;
1244  }
1245  } else {
1246  if (current_mA <= -BS_REST_CURRENT_mA) {
1247  retVal = BMS_DISCHARGING;
1248  } else if (current_mA >= BS_REST_CURRENT_mA) {
1249  retVal = BMS_CHARGING;
1250  } else {
1251  retVal = BMS_AT_REST;
1252  }
1253  }
1254  return retVal;
1255 }
1256 
1257 bool BMS_IsStringClosed(uint8_t stringNumber) {
1258  FAS_ASSERT(stringNumber < BS_NR_OF_STRINGS);
1259  bool retval = false;
1260  if (bms_state.closedStrings[stringNumber] == 1u) {
1261  retval = true;
1262  }
1263  return retval;
1264 }
1265 
1266 bool BMS_IsStringPrecharging(uint8_t stringNumber) {
1267  FAS_ASSERT(stringNumber < BS_NR_OF_STRINGS);
1268  bool retval = false;
1269  if (bms_state.closedPrechargeContactors[stringNumber] == 1u) {
1270  retval = true;
1271  }
1272  return retval;
1273 }
1274 
1275 /*========== Externalized Static Function Implementations (Unit Test) =======*/
1276 #ifdef UNITY_UNIT_TEST
1277 extern BMS_RETURN_TYPE_e TEST_BMS_CheckStateRequest(BMS_STATE_REQUEST_e statereq) {
1278  return BMS_CheckStateRequest(statereq);
1279 }
1280 extern BMS_STATE_REQUEST_e TEST_BMS_TransferStateRequest(void) {
1281  return BMS_TransferStateRequest();
1282 }
1283 extern uint8_t TEST_BMS_CheckReEntrance(void) {
1284  return BMS_CheckReEntrance();
1285 }
1286 extern uint8_t TEST_BMS_CheckCanRequests(void) {
1287  return BMS_CheckCanRequests();
1288 }
1289 extern STD_RETURN_TYPE_e TEST_BMS_CheckAnyErrorFlagSet(void) {
1290  return BMS_CheckAnyErrorFlagSet();
1291 }
1292 extern void TEST_BMS_GetMeasurementValues(void) {
1294  return;
1295 }
1296 extern void TEST_BMS_CheckOpenSenseWire(void) {
1298  return;
1299 }
1300 extern STD_RETURN_TYPE_e TEST_BMS_CheckPrecharge(uint8_t stringNumber, DATA_BLOCK_PACK_VALUES_s *pPackValues) {
1301  return BMS_CheckPrecharge(stringNumber, pPackValues);
1302 }
1303 extern uint8_t TEST_BMS_GetHighestString(BMS_CONSIDER_PRECHARGE_e precharge, DATA_BLOCK_PACK_VALUES_s *pPackValues) {
1304  return BMS_GetHighestString(precharge, pPackValues);
1305 }
1306 extern uint8_t TEST_BMS_GetClosestString(BMS_CONSIDER_PRECHARGE_e precharge, DATA_BLOCK_PACK_VALUES_s *pPackValues) {
1307  return BMS_GetClosestString(precharge, pPackValues);
1308 }
1309 
1310 extern uint8_t TEST_BMS_GetLowestString(BMS_CONSIDER_PRECHARGE_e precharge, DATA_BLOCK_PACK_VALUES_s *pPackValues) {
1311  return BMS_GetLowestString(precharge, pPackValues);
1312 }
1313 extern int32_t TEST_BMS_GetStringVoltageDifference(uint8_t string, DATA_BLOCK_PACK_VALUES_s *pPackValues) {
1314  return BMS_GetStringVoltageDifference(string, pPackValues);
1315 }
1316 extern int32_t TEST_BMS_GetAverageStringCurrent(DATA_BLOCK_PACK_VALUES_s *pPackValues) {
1317  return BMS_GetAverageStringCurrent(pPackValues);
1318 }
1319 extern void TEST_BMS_UpdateBatsysState(DATA_BLOCK_PACK_VALUES_s *pPackValues) {
1320  BMS_UpdateBatsysState(pPackValues);
1321  return;
1322 }
1323 
1324 #endif
BMS_STATE_NO_REQUEST
@ BMS_STATE_NO_REQUEST
Definition: bms.h:158
ILCK_SWITCH_ON
@ ILCK_SWITCH_ON
Definition: interlock_cfg.h:97
BMS_CHECK_ERROR_FLAGS
@ BMS_CHECK_ERROR_FLAGS
Definition: bms.h:125
CONT_OpenPrecharge
STD_RETURN_TYPE_e CONT_OpenPrecharge(uint8_t stringNumber)
Opens precharge.
Definition: contactor.c:260
os.h
Implementation of the tasks used by the system, headers.
CONT_CheckFeedback
void CONT_CheckFeedback(void)
checks the feedback of the contactors
Definition: contactor.c:212
DATA_BLOCK_PACK_VALUES::highVoltageBusVoltage_mV
int32_t highVoltageBusVoltage_mV
Definition: database_cfg.h:196
DATA_BLOCK_ERRORSTATE::crcError
uint8_t crcError[BS_NR_OF_STRINGS]
Definition: database_cfg.h:329
bms_tableOpenWire
static DATA_BLOCK_OPEN_WIRE_s bms_tableOpenWire
Definition: bms.c:113
BMS_OPEN_STRINGS_EXIT
@ BMS_OPEN_STRINGS_EXIT
Definition: bms.h:151
DATA_BLOCK_ERRORSTATE::insulationError
uint8_t insulationError
Definition: database_cfg.h:345
DATA_BLOCK_ID_PACK_VALUES
@ DATA_BLOCK_ID_PACK_VALUES
Definition: database_cfg.h:103
BMS_TIME_WAIT_AFTER_OPENING_PRECHARGE
#define BMS_TIME_WAIT_AFTER_OPENING_PRECHARGE
Definition: bms_cfg.h:148
DATA_BLOCK_MSL_FLAG::packDischargeOvercurrent
uint8_t packDischargeOvercurrent
Definition: database_cfg.h:429
DATA_BLOCK_MSL_FLAG::stringDischargeOvercurrent
uint8_t stringDischargeOvercurrent[BS_NR_OF_STRINGS]
Definition: database_cfg.h:439
DATA_BLOCK_OPENWIRE
Definition: database_cfg.h:296
BMS_CURRENT_FLOW_STATE_e
enum BMS_CURRENT_FLOW_STATE BMS_CURRENT_FLOW_STATE_e
BMS_GetStringVoltageDifference
static int32_t BMS_GetStringVoltageDifference(uint8_t string, const DATA_BLOCK_PACK_VALUES_s *pPackValues)
Returns voltage difference between first closed string and string ID.
Definition: bms.c:514
CONT_OpenString
STD_RETURN_TYPE_e CONT_OpenString(uint8_t stringNumber)
Opens the contactor of a string.
Definition: contactor.c:225
BMS_STATEMACH_ERROR
@ BMS_STATEMACH_ERROR
Definition: bms.h:98
BMS_TIME_WAIT_AFTER_OPENING_STRING
#define BMS_TIME_WAIT_AFTER_OPENING_STRING
Definition: bms_cfg.h:124
BMS_CLOSE_FIRST_STRING_PRECHARGE_STATE
@ BMS_CLOSE_FIRST_STRING_PRECHARGE_STATE
Definition: bms.h:137
BMS_STATE
Definition: bms.h:185
BMS_CHECK_ERROR_FLAGS_PRECHARGE_FIRST_STRING
@ BMS_CHECK_ERROR_FLAGS_PRECHARGE_FIRST_STRING
Definition: bms.h:140
BMS_CHECK_ERROR_FLAGS_PRECHARGE_CLOSINGSTRINGS
@ BMS_CHECK_ERROR_FLAGS_PRECHARGE_CLOSINGSTRINGS
Definition: bms.h:143
BMS_PRECHARGE_TRIES
#define BMS_PRECHARGE_TRIES
Definition: bms_cfg.h:164
BS_NR_OF_MODULES
#define BS_NR_OF_MODULES
number of modules in battery pack
Definition: battery_system_cfg.h:96
BMS_STATEMACH_MEDIUMTIME
#define BMS_STATEMACH_MEDIUMTIME
BMS statemachine medium time definition in BMS_Trigger() calls until next state/substate is processed...
Definition: bms_cfg.h:106
BMS_PL_0
@ BMS_PL_0
Definition: bms.h:176
BMS_STATEMACH_UNINITIALIZED
@ BMS_STATEMACH_UNINITIALIZED
Definition: bms.h:88
DATA_BLOCK_STATEREQUEST::header
DATA_BLOCK_HEADER_s header
Definition: database_cfg.h:506
CONT_SWITCH_ON
@ CONT_SWITCH_ON
Definition: contactor_cfg.h:72
DATA_BLOCK_MIN_MAX::header
DATA_BLOCK_HEADER_s header
Definition: database_cfg.h:162
DATA_BLOCK_ID_OPEN_WIRE_BASE
@ DATA_BLOCK_ID_OPEN_WIRE_BASE
Definition: database_cfg.h:81
BMS_PRECHARGE_CHECK_VOLTAGES
@ BMS_PRECHARGE_CHECK_VOLTAGES
Definition: bms.h:132
DATA_BLOCK_ID_MSL_FLAG
@ DATA_BLOCK_ID_MSL_FLAG
Definition: database_cfg.h:88
BMS_CHECK_STRING_OPEN
@ BMS_CHECK_STRING_OPEN
Definition: bms.h:150
STD_RETURN_TYPE_e
enum STD_RETURN_TYPE STD_RETURN_TYPE_e
BMS_STATEMACH_VERYLONGTIME
#define BMS_STATEMACH_VERYLONGTIME
BMS statemachine very long time definition in BMS_Trigger() calls until next state/substate is proces...
Definition: bms_cfg.h:118
BMS_OPEN_INTERLOCK
@ BMS_OPEN_INTERLOCK
Definition: bms.h:128
DATA_BLOCK_PACK_VALUES::invalidStringCurrent
uint8_t invalidStringCurrent[BS_NR_OF_STRINGS]
Definition: database_cfg.h:203
DATA_BLOCK_PACK_VALUES::invalidStringVoltage
uint8_t invalidStringVoltage[BS_NR_OF_STRINGS]
Definition: database_cfg.h:201
SOA_CheckTemperatures
void SOA_CheckTemperatures(DATA_BLOCK_MIN_MAX_s *pMinimumMaximumCellTemperatures, DATA_BLOCK_PACK_VALUES_s *pCurrent)
checks the abidance by the safe operating area
Definition: soa.c:143
BMS_REQ_ID_NOREQ
#define BMS_REQ_ID_NOREQ
Definition: bms_cfg.h:64
diag.h
Diagnosis driver header.
BMS_ILLEGAL_REQUEST
@ BMS_ILLEGAL_REQUEST
Definition: bms.h:168
DATA_BLOCK_ERRORSTATE::currentSensor
uint8_t currentSensor[BS_NR_OF_STRINGS]
Definition: database_cfg.h:325
DATA_BLOCK_STATEREQUEST::stateRequestViaCan
uint8_t stateRequestViaCan
Definition: database_cfg.h:507
bms.h
bms driver header
BMS_STATEMACH_IDLE
@ BMS_STATEMACH_IDLE
Definition: bms.h:91
BMS_CheckOpenSenseWire
static void BMS_CheckOpenSenseWire(void)
Check for any open voltage sense wire.
Definition: bms.c:321
SOA_CheckCurrent
void SOA_CheckCurrent(DATA_BLOCK_PACK_VALUES_s *pTablePackValues)
checks the abidance by the safe operating area
Definition: soa.c:275
BMS_CANSTATE_ERROR
@ BMS_CANSTATE_ERROR
Definition: bms.h:115
DATA_WRITE_DATA
#define DATA_WRITE_DATA(...)
Definition: database.h:82
BMS_REQ_ID_NORMAL
#define BMS_REQ_ID_NORMAL
Definition: bms_cfg.h:70
CONT_ClosePrecharge
STD_RETURN_TYPE_e CONT_ClosePrecharge(uint8_t stringNumber)
Closes precharge.
Definition: contactor.c:234
BMS_STATE::state
BMS_STATEMACH_e state
Definition: bms.h:188
DATA_BLOCK_ERRORSTATE::fuseStateCharge
uint8_t fuseStateCharge[BS_NR_OF_STRINGS]
Definition: database_cfg.h:347
DATA_BLOCK_PACK_VALUES::invalidPackCurrent
uint8_t invalidPackCurrent
Definition: database_cfg.h:192
BMS_STATE::PrechargeTryCounter
uint8_t PrechargeTryCounter
Definition: bms.h:199
BMS_STATE::nextstringclosedtimer
uint32_t nextstringclosedtimer
Definition: bms.h:203
bal.h
Header for the driver for balancing.
DATA_BLOCK_ERRORSTATE::prechargeContactor
uint8_t prechargeContactor[BS_NR_OF_STRINGS]
Definition: database_cfg.h:327
BS_RELAXATION_PERIOD_10ms
#define BS_RELAXATION_PERIOD_10ms
Wait time in 10ms before battery system is at rest. Balancing for example only starts if battery syst...
Definition: battery_system_cfg.h:293
BMS_STATEMACH_INITIALIZED
@ BMS_STATEMACH_INITIALIZED
Definition: bms.h:90
BS_STRING_WITH_PRECHARGE
@ BS_STRING_WITH_PRECHARGE
Definition: battery_system_cfg.h:69
BMS_STATE_REQUEST_e
enum BMS_STATE_REQUEST BMS_STATE_REQUEST_e
BMS_GetCurrentFlowDirection
BMS_CURRENT_FLOW_STATE_e BMS_GetCurrentFlowDirection(int32_t current_mA)
Get current flow direction, current value as function parameter.
Definition: bms.c:1234
DATA_BLOCK_MSL_FLAG::stringChargeOvercurrent
uint8_t stringChargeOvercurrent[BS_NR_OF_STRINGS]
Definition: database_cfg.h:437
DATA_BLOCK_ERRORSTATE::currentOnOpenString
uint8_t currentOnOpenString[BS_NR_OF_STRINGS]
Definition: database_cfg.h:360
BMS_INTERLOCK_CHECKED
@ BMS_INTERLOCK_CHECKED
Definition: bms.h:122
BS_NR_OF_CELLS_PER_MODULE
#define BS_NR_OF_CELLS_PER_MODULE
number of battery cells per battery module (parallel cells are counted as one)
Definition: battery_system_cfg.h:104
BMS_STATE::deactivatedStrings
uint8_t deactivatedStrings[BS_NR_OF_STRINGS]
Definition: bms.h:211
BMS_RETURN_TYPE_e
enum BMS_RETURN_TYPE BMS_RETURN_TYPE_e
DATA_BLOCK_SYSTEMSTATE_s
Definition: database_cfg.h:414
BMS_CANSTATE_CHARGE
@ BMS_CANSTATE_CHARGE
Definition: bms.h:114
BMS_NO_STRING_AVAILABLE
#define BMS_NO_STRING_AVAILABLE
Functions searching for next string return this value if no further string is available.
Definition: bms_cfg.h:78
CONT_GetState
CONT_ELECTRICAL_STATE_TYPE_e CONT_GetState(uint8_t contactorNumber)
Gets the current state.
Definition: contactor.c:286
BMS_STATE::OscillationTimeout
uint16_t OscillationTimeout
Definition: bms.h:198
BMS_OPEN_CONTACTORS_ON_INSULATION_ERROR
#define BMS_OPEN_CONTACTORS_ON_INSULATION_ERROR
Defines behaviour if an insulation error is detected.
Definition: battery_system_cfg.h:245
DIAG_EVENT_OK
@ DIAG_EVENT_OK
Definition: diag_cfg.h:201
MATH_AbsInt32
int32_t MATH_AbsInt32(int32_t value)
Returns the absolute value of passed int32_t value.
Definition: foxmath.c:105
DIAG_Handler
DIAG_RETURNTYPE_e DIAG_Handler(DIAG_ID_e diag_id, DIAG_EVENT_e event, DIAG_IMPACT_LEVEL_e impact, uint32_t data)
DIAG_Handler provides generic error handling, based on diagnosis group.
Definition: diag.c:199
CONT_CloseString
STD_RETURN_TYPE_e CONT_CloseString(uint8_t stringNumber)
Closes the contactor of a string.
Definition: contactor.c:217
DATA_BLOCK_MSL_FLAG::undertemperatureCharge
uint8_t undertemperatureCharge[BS_NR_OF_STRINGS]
Definition: database_cfg.h:434
BAL_STATE_NO_BALANCING_REQUEST
@ BAL_STATE_NO_BALANCING_REQUEST
Definition: bal.h:102
BMS_STRING_CLOSE_TIMEOUT
#define BMS_STRING_CLOSE_TIMEOUT
Timeout in BMS_Trigger() calls when closing a string after which the state machines goes to error if ...
Definition: bms_cfg.h:130
DATA_BLOCK_ERRORSTATE::fuseStateNormal
uint8_t fuseStateNormal[BS_NR_OF_STRINGS]
Definition: database_cfg.h:346
BMS_TIME_WAIT_AFTER_STRING_CLOSED
#define BMS_TIME_WAIT_AFTER_STRING_CLOSED
Definition: bms_cfg.h:121
BMS_PL_1
@ BMS_PL_1
Definition: bms.h:177
BMS_STATEMACH_e
enum BMS_STATEMACH BMS_STATEMACH_e
BMS_OPEN_ALL_PRECHARGES
@ BMS_OPEN_ALL_PRECHARGES
Definition: bms.h:146
BMS_STATEMACH_SHORTTIME
#define BMS_STATEMACH_SHORTTIME
BMS statemachine short time definition in BMS_Trigger() calls until next state/substate is processed.
Definition: bms_cfg.h:100
LTC_STANDBY_OPEN_WIRE_PERIOD_ms
#define LTC_STANDBY_OPEN_WIRE_PERIOD_ms
Definition: ltc_6806_cfg.h:258
BMS_TransferStateRequest
static BMS_STATE_REQUEST_e BMS_TransferStateRequest(void)
transfers the current state request to the state machine.
Definition: bms.c:286
BMS_STATEMACH_CHARGE
@ BMS_STATEMACH_CHARGE
Definition: bms.h:97
BMS_ENTRY
@ BMS_ENTRY
Definition: bms.h:120
BMS_STATEMACH_NORMAL
@ BMS_STATEMACH_NORMAL
Definition: bms.h:95
BMS_REQUEST_PENDING
@ BMS_REQUEST_PENDING
Definition: bms.h:167
DATA_BLOCK_ERRORSTATE::canTimingCc
uint8_t canTimingCc[BS_NR_OF_STRINGS]
Definition: database_cfg.h:350
DATA_BLOCK_MSL_FLAG::overtemperatureDischarge
uint8_t overtemperatureDischarge[BS_NR_OF_STRINGS]
Definition: database_cfg.h:433
FAS_ASSERT
#define FAS_ASSERT(x)
Assertion macro that asserts that x is true.
Definition: fassert.h:237
DATA_BLOCK_ERRORSTATE::interlock
uint8_t interlock
Definition: database_cfg.h:328
BMS_CHECK_ERROR_FLAGS_INTERLOCK
@ BMS_CHECK_ERROR_FLAGS_INTERLOCK
Definition: bms.h:121
OS_ExitTaskCritical
void OS_ExitTaskCritical(void)
Exit Critical interface function for use in FreeRTOS-Tasks and FreeRTOS-ISR.
Definition: os.c:178
bms_state
static BMS_STATE_s bms_state
Definition: bms.c:83
BMS_STATE::counter
uint8_t counter
Definition: bms.h:195
BMS_OK
@ BMS_OK
Definition: bms.h:165
BMS_DO_NOT_TAKE_PRECHARGE_INTO_ACCCOUNT
@ BMS_DO_NOT_TAKE_PRECHARGE_INTO_ACCCOUNT
Definition: bms.h:81
BMS_PRECHARGE_CLOSE_PRECHARGE
@ BMS_PRECHARGE_CLOSE_PRECHARGE
Definition: bms.h:131
DATA_BLOCK_MSL_FLAG::overtemperatureCharge
uint8_t overtemperatureCharge[BS_NR_OF_STRINGS]
Definition: database_cfg.h:432
DIAG_ID_OPEN_WIRE
@ DIAG_ID_OPEN_WIRE
Definition: diag_cfg.h:176
BMS_STATEMACH_STANDBY
@ BMS_STATEMACH_STANDBY
Definition: bms.h:93
BMS_PRECHARGE_CURRENT_THRESHOLD_mA
#define BMS_PRECHARGE_CURRENT_THRESHOLD_mA
Definition: bms_cfg.h:170
OS_GetTickCount
uint32_t OS_GetTickCount(void)
Returns OS based system tick value.
Definition: os.c:182
BMS_STATE::powerline
BMS_POWERLINE_TYPE_e powerline
Definition: bms.h:200
BMS_STATE::ErrRequestCounter
uint32_t ErrRequestCounter
Definition: bms.h:192
BMS_STATE::closedStrings
uint8_t closedStrings[BS_NR_OF_STRINGS]
Definition: bms.h:210
SOA_CheckSlaveTemperatures
void SOA_CheckSlaveTemperatures(void)
FOR FUTURE COMPATIBILITY; DUMMY FUNCTION; DO NOT USE.
Definition: soa.c:357
DATA_BLOCK_ID_MIN_MAX
@ DATA_BLOCK_ID_MIN_MAX
Definition: database_cfg.h:75
BMS_CheckAnyErrorFlagSet
static STD_RETURN_TYPE_e BMS_CheckAnyErrorFlagSet(void)
Checks the error flags.
Definition: bms.c:372
DIAG_STRING
@ DIAG_STRING
Definition: diag_cfg.h:215
BMS_DISCHARGING
@ BMS_DISCHARGING
Definition: bms.h:67
BMS_STATE::stateRequest
BMS_STATE_REQUEST_e stateRequest
Definition: bms.h:187
BMS_CHARGING
@ BMS_CHARGING
Definition: bms.h:66
mic.h
Measurement IC driver header.
foxmath.h
math library for often used math functions
STD_OK
@ STD_OK
Definition: fstd_types.h:72
BMS_GetMeasurementValues
static void BMS_GetMeasurementValues(void)
Definition: bms.c:296
BMS_STATE::substate
BMS_STATEMACH_SUB_e substate
Definition: bms.h:189
DATA_BLOCK_MSL_FLAG::packChargeOvercurrent
uint8_t packChargeOvercurrent
Definition: database_cfg.h:428
DATA_BLOCK_ERRORSTATE::micConfigurationError
uint8_t micConfigurationError[BS_NR_OF_STRINGS]
Definition: database_cfg.h:332
BMS_GetAverageStringCurrent
static int32_t BMS_GetAverageStringCurrent(DATA_BLOCK_PACK_VALUES_s *pPackValues)
Returns the average current flowing through all strings.
Definition: bms.c:534
BMS_STATE::numberOfClosedStrings
uint8_t numberOfClosedStrings
Definition: bms.h:201
BMS_STATEMACH_DISCHARGE
@ BMS_STATEMACH_DISCHARGE
Definition: bms.h:96
BMS_UpdateBatsysState
static void BMS_UpdateBatsysState(DATA_BLOCK_PACK_VALUES_s *pPackValues)
Updates battery system state variable depending on measured/recent current values.
Definition: bms.c:543
DATA_BLOCK_MSL_FLAG::header
DATA_BLOCK_HEADER_s header
Definition: database_cfg.h:427
DATA_BLOCK_SYSTEMSTATE_s::header
DATA_BLOCK_HEADER_s header
Definition: database_cfg.h:418
OS_EnterTaskCritical
void OS_EnterTaskCritical(void)
Enter Critical interface function for use in FreeRTOS-Tasks and FreeRTOS-ISR.
Definition: os.c:174
BMS_CONSIDER_PRECHARGE_e
enum BMS_CONSIDER_PRECHARGE BMS_CONSIDER_PRECHARGE_e
BMS_PL_OPEN
@ BMS_PL_OPEN
Definition: bms.h:175
BMS_AT_REST
@ BMS_AT_REST
Definition: bms.h:69
BMS_IsStringClosed
bool BMS_IsStringClosed(uint8_t stringNumber)
Returns string state (closed or open)
Definition: bms.c:1257
STD_NOT_OK
@ STD_NOT_OK
Definition: fstd_types.h:73
DATA_BLOCK_ERRORSTATE::stringContactor
uint8_t stringContactor[BS_NR_OF_STRINGS]
Definition: database_cfg.h:326
BMS_GetBatterySystemState
BMS_CURRENT_FLOW_STATE_e BMS_GetBatterySystemState(void)
Returns current battery system state (charging/discharging, resting or in relaxation phase)
Definition: bms.c:1230
BMS_OPEN_STRINGS
@ BMS_OPEN_STRINGS
Definition: bms.h:149
battery_cell_cfg.h
Configuration of the battery cell (e.g., minimum and maximum cell voltage)
BMS_CANSTATE_STANDBY
@ BMS_CANSTATE_STANDBY
Definition: bms.h:111
BMS_Trigger
void BMS_Trigger(void)
trigger function for the SYS driver state machine.
Definition: bms.c:614
bms_tableMinMax
static DATA_BLOCK_MIN_MAX_s bms_tableMinMax
Definition: bms.c:112
BMS_AVERAGE_STRING_CURRENT_LIMIT_MA
#define BMS_AVERAGE_STRING_CURRENT_LIMIT_MA
Definition: bms_cfg.h:142
BMS_CHECK_STRING_CLOSED
@ BMS_CHECK_STRING_CLOSED
Definition: bms.h:142
BMS_GetInitializationState
STD_RETURN_TYPE_e BMS_GetInitializationState(void)
Gets the initialization state.
Definition: bms.c:592
BMS_CheckPrecharge
static STD_RETURN_TYPE_e BMS_CheckPrecharge(uint8_t stringNumber, const DATA_BLOCK_PACK_VALUES_s *pPackValues)
Checks if the current limitations are violated.
Definition: bms.c:346
BMS_ALREADY_INITIALIZED
@ BMS_ALREADY_INITIALIZED
Definition: bms.h:169
BMS_STATE::stringOpenTimeout
uint16_t stringOpenTimeout
Definition: bms.h:202
contactor.h
Headers for the driver for the contactors.
BMS_STATE::currentFlowState
BMS_CURRENT_FLOW_STATE_e currentFlowState
Definition: bms.h:196
ILCK_SetStateRequest
ILCK_RETURN_TYPE_e ILCK_SetStateRequest(ILCK_STATE_REQUEST_e statereq)
sets the current state request of the state variable ilck_state.
Definition: interlock.c:306
BMS_STATE::initFinished
STD_RETURN_TYPE_e initFinished
Definition: bms.h:193
DATA_BLOCK_PACK_VALUES::stringCurrent_mA
int32_t stringCurrent_mA[BS_NR_OF_STRINGS]
Definition: database_cfg.h:202
DATA_BLOCK_PACK_VALUES
Definition: database_cfg.h:185
DATA_BLOCK_ERRORSTATE::muxError
uint8_t muxError[BS_NR_OF_STRINGS]
Definition: database_cfg.h:330
BMS_CHECK_CLOSE_FIRST_STRING_PRECHARGE_STATE
@ BMS_CHECK_CLOSE_FIRST_STRING_PRECHARGE_STATE
Definition: bms.h:138
DIAG_EVENT_NOT_OK
@ DIAG_EVENT_NOT_OK
Definition: diag_cfg.h:202
LTC_NORMAL_OPEN_WIRE_PERIOD_ms
#define LTC_NORMAL_OPEN_WIRE_PERIOD_ms
Definition: ltc_6806_cfg.h:264
BMS_STATE_INIT_REQUEST
@ BMS_STATE_INIT_REQUEST
Definition: bms.h:156
DATA_BLOCK_ID_STATEREQUEST
@ DATA_BLOCK_ID_STATEREQUEST
Definition: database_cfg.h:92
BMS_OSCILLATION_TIMEOUT
#define BMS_OSCILLATION_TIMEOUT
Timeout in 1*10ms to wait before re-entering to precharge.
Definition: bms_cfg.h:161
DATA_BLOCK_MSL_FLAG::overVoltage
uint8_t overVoltage[BS_NR_OF_STRINGS]
Definition: database_cfg.h:430
BMS_CANSTATE_PRECHARGE
@ BMS_CANSTATE_PRECHARGE
Definition: bms.h:112
BMS_GetHighestString
static uint8_t BMS_GetHighestString(BMS_CONSIDER_PRECHARGE_e precharge, DATA_BLOCK_PACK_VALUES_s *pPackValues)
Returns ID of string with highest total voltage.
Definition: bms.c:419
DATA_BLOCK_ERRORSTATE::header
DATA_BLOCK_HEADER_s header
Definition: database_cfg.h:324
DATA_BLOCK_MIN_MAX
Definition: database_cfg.h:158
DATA_READ_DATA
#define DATA_READ_DATA(...)
Definition: database.h:72
SOA_CheckVoltages
void SOA_CheckVoltages(DATA_BLOCK_MIN_MAX_s *pMinimumMaximumCellVoltages)
checks the abidance by the safe operating area
Definition: soa.c:77
BMS_GetClosestString
static uint8_t BMS_GetClosestString(BMS_CONSIDER_PRECHARGE_e precharge, DATA_BLOCK_PACK_VALUES_s *pPackValues)
Returns ID of string with voltage closest to first closed string voltage.
Definition: bms.c:444
DATA_BLOCK_MSL_FLAG
Definition: database_cfg.h:423
DATA_BLOCK_OPENWIRE::openwire
uint8_t openwire[BS_NR_OF_STRINGS][BS_NR_OF_MODULES *(BS_NR_OF_CELLS_PER_MODULE+1)]
Definition: database_cfg.h:304
BMS_GetState
BMS_STATEMACH_e BMS_GetState(void)
Returns the current state.
Definition: bms.c:596
DATA_BLOCK_MSL_FLAG::undertemperatureDischarge
uint8_t undertemperatureDischarge[BS_NR_OF_STRINGS]
Definition: database_cfg.h:435
DATA_BLOCK_ID_ERRORSTATE
@ DATA_BLOCK_ID_ERRORSTATE
Definition: database_cfg.h:83
meas.h
Headers for the driver for the measurements needed by the BMS (e.g., I,V,T).
BMS_IsStringPrecharging
bool BMS_IsStringPrecharging(uint8_t stringNumber)
Returns if string is currently precharging or not.
Definition: bms.c:1266
BMS_CHECK_STATE_REQUESTS
@ BMS_CHECK_STATE_REQUESTS
Definition: bms.h:123
BMS_CheckStateRequest
static BMS_RETURN_TYPE_e BMS_CheckStateRequest(BMS_STATE_REQUEST_e statereq)
checks the state requests that are made.
Definition: bms.c:253
DATA_BLOCK_ERRORSTATE::open_wire
uint8_t open_wire[BS_NR_OF_STRINGS]
Definition: database_cfg.h:348
BMS_STATEMACH_INITIALIZATION
@ BMS_STATEMACH_INITIALIZATION
Definition: bms.h:89
DATA_BLOCK_ERRORSTATE
Definition: database_cfg.h:320
DATA_BLOCK_ERRORSTATE::deepDischargeDetected
uint8_t deepDischargeDetected[BS_NR_OF_STRINGS]
Definition: database_cfg.h:359
DATA_BLOCK_ERRORSTATE::spiError
uint8_t spiError[BS_NR_OF_STRINGS]
Definition: database_cfg.h:331
DATA_BLOCK_PACK_VALUES::invalidHvBusVoltage
uint8_t invalidHvBusVoltage
Definition: database_cfg.h:197
database.h
Database module header.
BMS_CHECK_INTERLOCK_CLOSE_AFTER_ERROR
@ BMS_CHECK_INTERLOCK_CLOSE_AFTER_ERROR
Definition: bms.h:129
NULL_PTR
#define NULL_PTR
Null pointer.
Definition: fstd_types.h:66
DATA_BLOCK_MSL_FLAG::underVoltage
uint8_t underVoltage[BS_NR_OF_STRINGS]
Definition: database_cfg.h:431
BMS_GetLowestString
static uint8_t BMS_GetLowestString(BMS_CONSIDER_PRECHARGE_e precharge, DATA_BLOCK_PACK_VALUES_s *pPackValues)
Returns ID of string with lowest total voltage.
Definition: bms.c:490
BMS_STRING_OPEN_TIMEOUT
#define BMS_STRING_OPEN_TIMEOUT
Definition: bms_cfg.h:133
soa.h
Header for SOA module, responsible for checking battery parameters against safety limits.
BMS_STATE::restTimer_10ms
uint32_t restTimer_10ms
Definition: bms.h:197
BMS_STATE::firstClosedString
uint8_t firstClosedString
Definition: bms.h:206
BMS_RELAXATION
@ BMS_RELAXATION
Definition: bms.h:68
BS_REST_CURRENT_mA
#define BS_REST_CURRENT_mA
current threshold for determing rest state of battery. If absolute current is below this limit value ...
Definition: battery_system_cfg.h:287
MIC_ERROR_OPEN_WIRE_PERIOD_ms
#define MIC_ERROR_OPEN_WIRE_PERIOD_ms
Definition: mic.h:64
BMS_STATE_ERROR_REQUEST
@ BMS_STATE_ERROR_REQUEST
Definition: bms.h:157
BMS_STATEMACH_LONGTIME
#define BMS_STATEMACH_LONGTIME
BMS statemachine long time definition in BMS_Trigger() calls until next state/substate is processed.
Definition: bms_cfg.h:112
BMS_NORMAL_CLOSE_NEXT_STRING
@ BMS_NORMAL_CLOSE_NEXT_STRING
Definition: bms.h:145
ILCK_STATE_CLOSE_REQUEST
@ ILCK_STATE_CLOSE_REQUEST
Definition: interlock.h:90
BAL_SetStateRequest
BAL_RETURN_TYPE_e BAL_SetStateRequest(BAL_STATE_REQUEST_e stateRequest)
sets the current state request of the state variable bal_state.
Definition: bal_strategy_history.c:304
DATA_BLOCK_PACK_VALUES::header
DATA_BLOCK_HEADER_s header
Definition: database_cfg.h:189
BMS_SAVELASTSTATES
#define BMS_SAVELASTSTATES()
Definition: bms.c:74
DATA_BLOCK_ID_SYSTEMSTATE
@ DATA_BLOCK_ID_SYSTEMSTATE
Definition: database_cfg.h:87
BMS_STATE::stringCloseTimeout
uint16_t stringCloseTimeout
Definition: bms.h:204
DATA_BLOCK_STATEREQUEST
Definition: database_cfg.h:502
DATA_BLOCK_ERRORSTATE::canTimingEc
uint8_t canTimingEc[BS_NR_OF_STRINGS]
Definition: database_cfg.h:351
BMS_CANSTATE_NORMAL
@ BMS_CANSTATE_NORMAL
Definition: bms.h:113
ILCK_GetInterlockFeedback
ILCK_ELECTRICAL_STATE_TYPE_e ILCK_GetInterlockFeedback(void)
Reads the feedback pin of the interlock and returns its current value (ILCK_SWITCH_OFF/ILCK_SWITCH_ON...
Definition: interlock.c:287
BMS_CHECK_ERROR_FLAGS_CLOSINGPRECHARGE
@ BMS_CHECK_ERROR_FLAGS_CLOSINGPRECHARGE
Definition: bms.h:144
BMS_PRECHARGE_VOLTAGE_THRESHOLD_mV
#define BMS_PRECHARGE_VOLTAGE_THRESHOLD_mV
Definition: bms_cfg.h:167
DATA_BLOCK_PACK_VALUES::stringVoltage_mV
int32_t stringVoltage_mV[BS_NR_OF_STRINGS]
Definition: database_cfg.h:200
CONT_ELECTRICAL_STATE_TYPE_e
enum CONT_ELECTRICAL_STATE_TYPE CONT_ELECTRICAL_STATE_TYPE_e
ILCK_STATE_OPEN_REQUEST
@ ILCK_STATE_OPEN_REQUEST
Definition: interlock.h:89
DATA_BLOCK_MSL_FLAG::cellChargeOvercurrent
uint8_t cellChargeOvercurrent[BS_NR_OF_STRINGS]
Definition: database_cfg.h:436
BMS_CANSTATE_IDLE
@ BMS_CANSTATE_IDLE
Definition: bms.h:109
BMS_STATEMACH_PRECHARGE
@ BMS_STATEMACH_PRECHARGE
Definition: bms.h:94
BMS_STATE::nextstate
BMS_STATEMACH_e nextstate
Definition: bms.h:205
BMS_TIME_WAIT_AFTERPRECHARGEFAIL
#define BMS_TIME_WAIT_AFTERPRECHARGEFAIL
Time to wait in BMS_Trigger() calls after precharge opened because precharge failed.
Definition: bms_cfg.h:154
bms_tablePackValues
static DATA_BLOCK_PACK_VALUES_s bms_tablePackValues
Definition: bms.c:114
FAS_TRAP
#define FAS_TRAP
Define that evaluates to essential boolean false thus tripping an assert.
Definition: fassert.h:108
DATA_BLOCK_ERRORSTATE::canTiming
uint8_t canTiming
Definition: database_cfg.h:349
DATA_BLOCK_OPENWIRE::header
DATA_BLOCK_HEADER_s header
Definition: database_cfg.h:300
BMS_REQ_ID_STANDBY
#define BMS_REQ_ID_STANDBY
Definition: bms_cfg.h:67
BMS_NEXT_STRING_VOLTAGE_LIMIT_MV
#define BMS_NEXT_STRING_VOLTAGE_LIMIT_MV
Max voltage difference in mV between two strings to allow closing the next string.
Definition: bms_cfg.h:139
BMS_STATE::closedPrechargeContactors
uint8_t closedPrechargeContactors[BS_NR_OF_STRINGS]
Definition: bms.h:209
interlock.h
Headers for the driver for the interlock.
BMS_TAKE_PRECHARGE_INTO_ACCCOUNT
@ BMS_TAKE_PRECHARGE_INTO_ACCCOUNT
Definition: bms.h:82
BMS_STATEMACH_OPENCONTACTORS
@ BMS_STATEMACH_OPENCONTACTORS
Definition: bms.h:92
BMS_TIME_WAIT_AFTER_CLOSING_PRECHARGE
#define BMS_TIME_WAIT_AFTER_CLOSING_PRECHARGE
Definition: bms_cfg.h:145
DATA_BLOCK_MSL_FLAG::cellDischargeOvercurrent
uint8_t cellDischargeOvercurrent[BS_NR_OF_STRINGS]
Definition: database_cfg.h:438
MEAS_RequestOpenWireCheck
STD_RETURN_TYPE_e MEAS_RequestOpenWireCheck(uint8_t string)
Makes the request to the MIC state machine to perform open-wire check.
Definition: meas.c:119
DATA_BLOCK_SYSTEMSTATE_s::bmsCanState
int32_t bmsCanState
Definition: database_cfg.h:419
BMS_STATE::timer
uint16_t timer
Definition: bms.h:186
DATA_BLOCK_PACK_VALUES::packCurrent_mA
int32_t packCurrent_mA
Definition: database_cfg.h:191
POSITIVE_DISCHARGE_CURRENT
#define POSITIVE_DISCHARGE_CURRENT
Definition: battery_system_cfg.h:86
BS_NR_OF_STRINGS
#define BS_NR_OF_STRINGS
Definition: battery_system_cfg.h:89
BMS_SetStateRequest
BMS_RETURN_TYPE_e BMS_SetStateRequest(BMS_STATE_REQUEST_e statereq)
sets the current state request of the state variable bms_state.
Definition: bms.c:600
BMS_CheckCanRequests
static uint8_t BMS_CheckCanRequests(void)
Checks the state requests made to the BMS state machine.
Definition: bms.c:300
BMS_REQ_ID_CHARGE
#define BMS_REQ_ID_CHARGE
Definition: bms_cfg.h:73
CONT_SWITCH_OFF
@ CONT_SWITCH_OFF
Definition: contactor_cfg.h:71
bs_stringsWithPrecharge
BS_STRING_PRECHARGE_PRESENT_e bs_stringsWithPrecharge[BS_NR_OF_STRINGS]
Definition: battery_system_cfg.c:64
MATH_AbsInt64
int64_t MATH_AbsInt64(int64_t value)
Returns the absolute value of passed int64_t value.
Definition: foxmath.c:113
BMS_PRECHARGE_OPEN_PRECHARGE
@ BMS_PRECHARGE_OPEN_PRECHARGE
Definition: bms.h:133
BMS_CheckReEntrance
static uint8_t BMS_CheckReEntrance(void)
re-entrance check of SYS state machine trigger function
Definition: bms.c:274
BAL_STATE_ALLOWBALANCING_REQUEST
@ BAL_STATE_ALLOWBALANCING_REQUEST
Definition: bal.h:103
DATA_BLOCKHEADER::uniqueId
DATA_BLOCK_ID_e uniqueId
Definition: database_cfg.h:109
BMS_STATE::triggerentry
uint8_t triggerentry
Definition: bms.h:194