foxBMS-UnitTests  1.0.0
The foxBMS Unit Tests API Documentation
debug_default.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 debug_default.c
44  * @author foxBMS Team
45  * @date 2020-09-17 (date of creation)
46  * @updated 2020-11-09 (date of last update)
47  * @ingroup DRIVER
48  * @prefix FAKE
49  *
50  * @brief Driver implementation for the fake measurement IC
51  *
52  */
53 
54 /*========== Includes =======================================================*/
55 #include "general.h"
56 
57 #include "debug_default.h"
58 
59 #include "battery_cell_cfg.h"
60 #include "battery_system_cfg.h"
61 
62 #include "database.h"
63 #include "diag.h"
64 #include "os.h"
65 
66 /*========== Macros and Definitions =========================================*/
67 /** faked cell voltage value for all cell voltages in mV */
68 #define FAKE_CELL_VOLTAGE_mV (BC_VOLTAGE_NOMINAL_mV)
69 
70 /** faked cell temperature for all cell temperatures in deci °C */
71 #define FAKE_CELL_TEMPERATURE_ddegC ((BC_TEMPERATURE_MAX_CHARGE_MOL_ddegC + BC_TEMPERATURE_MIN_CHARGE_MOL_ddegC) / 2u)
72 
73 /**
74  * statemachine short time definition in #FAKE_TriggerMeasurementIc calls
75  * until next state is processed
76  */
77 #define FAKE_FSM_SHORT_TIME (1u)
78 
79 /**
80  * statemachine medium time definition in #FAKE_TriggerMeasurementIc calls
81  * until next state/substate is processed
82  */
83 #define FAKE_FSM_MEDIUM_TIME (5u)
84 
85 /**
86  * statemachine long time definition in #FAKE_TriggerMeasurementIc calls
87  * until next state/substate is processed
88  */
89 #define FAKE_FSM_LONG_TIME (10u)
90 
91 /** Symbolic names to check for multiple calls of #FAKE_TriggerMeasurementIc */
93  FAKE_MULTIPLE_CALLS_NO, /*!< no multiple calls, OK */
94  FAKE_MULTIPLE_CALLS_YES, /*!< multiple calls, not OK */
96 
97 /*========== Static Constant and Variable Definitions =======================*/
98 
99 /** local copies of database tables */
100 /**@{*/
109 /**@}*/
110 
111 /*========== Extern Constant and Variable Definitions =======================*/
112 
113 /** local instance of the driver-state */
115  .timer = 0,
116  .triggerEntry = 0,
117  .nextState = FAKE_FSM_STATE_HAS_NEVER_RUN,
118  .currentState = FAKE_FSM_STATE_HAS_NEVER_RUN,
119  .previousState = FAKE_FSM_STATE_HAS_NEVER_RUN,
120  .nextSubstate = FAKE_FSM_SUBSTATE_DUMMY,
121  .currentSubstate = FAKE_FSM_SUBSTATE_DUMMY,
122  .previousSubstate = FAKE_FSM_SUBSTATE_DUMMY,
123  .firstMeasurementFinished = false,
124  .data.allGpioVoltages = &fake_allGpioVoltage,
125  .data.balancingControl = &fake_balancingControl,
126  .data.balancingFeedback = &fake_balancingFeedback,
127  .data.cellTemperature = &fake_cellTemperature,
128  .data.cellVoltage = &fake_cellVoltage,
129  .data.openWire = &fake_openWire,
130  .data.slaveControl = &fake_slaveControl,
131 };
132 
133 /*========== Static Function Prototypes =====================================*/
134 /**
135  * @brief check for multiple calls of state machine trigger function
136  * @details The trigger function is not reentrant, which means it cannot
137  * be called multiple times. This functions increments the
138  * triggerEntry counter once and must be called each time the
139  * trigger function is called. If triggerEntry is greater than
140  * one, there were multiple calls. For this function to work,
141  * triggerEntry must be decremented each time the trigger function
142  * is called, even if no processing do because the timer is
143  * non-zero.
144  * @param pFakeState state of the fake state machine
145  * @return true if there were multiple calls, false otherwise
146  */
147 static bool FAKE_CheckMultipleCalls(FAKE_STATE_s *pFakeState);
148 
149 /**
150  * @brief Sets the next state, the next substate and the timer value
151  * of the state variable.
152  * @param pFakeState state of the example state machine
153  * @param nextState state to be transferred into
154  * @param nextSubstate substate to be transferred into
155  * @param idleTime wait time for the state machine
156  */
157 static void FAKE_SetState(
158  FAKE_STATE_s *pFakeState,
159  FAKE_FSM_STATES_e nextState,
160  FAKE_FSM_SUBSTATES_e nextSubstate,
161  uint16_t idleTime);
162 
163 /**
164  * @brief Sets the next substate and the timer value
165  * of the state variable.
166  * @param pFakeState state of the example state machine
167  * @param nextSubstate substate to be transferred into
168  * @param idleTime wait time for the state machine
169  */
170 static void FAKE_SetSubstate(FAKE_STATE_s *pFakeState, FAKE_FSM_SUBSTATES_e nextSubstate, uint16_t idleTime);
171 
172 /**
173  * @brief Sets the indicator that one full measurement cycles was successfull
174  * @param pFakeState state of the fake state machine
175  * @return true if it is a reentrance, false otherwise
176  */
177 static void FAKE_SetFirstMeasurementCycleFinished(FAKE_STATE_s *pFakeState);
178 
179 /**
180  * @brief Write voltage measurement data
181  * @param pFakeState state of the fake state machine
182  * @return #STD_OK if successfull, #STD_NOT_OK otherwise
183  */
185 
186 /**
187  * @brief Write temperature measurement data
188  * @param pFakeState state of the fake state machine
189  * @return #STD_OK if successfull, #STD_NOT_OK otherwise
190  */
192 
193 /**
194  * @brief Processes the initialization state
195  * @param pFakeState state of the fake state machine
196  * @return Always #STD_OK
197  */
199 
200 /**
201  * @brief Processes the running state
202  * @param pFakeState state of the fake state machine
203  * @return Always #STD_OK
204  */
206 
207 /**
208  * @brief Defines the state transitions
209  * @details This function contains the implementation of the state
210  * machine, i.e., the sequence of states and substates.
211  * It is called by the trigger function every time
212  * the state machine timer has a non-zero value.
213  * @param pFakeState state of the example state machine
214  * @return Always #STD_OK
215  */
217 
218 /*========== Static Function Implementations ================================*/
219 
220 static bool FAKE_CheckMultipleCalls(FAKE_STATE_s *pFakeState) {
221  FAS_ASSERT(pFakeState != NULL_PTR);
222  bool reentrance = false;
224  if (pFakeState->triggerEntry == 0u) {
225  pFakeState->triggerEntry++;
226  } else {
227  reentrance = true; /* multiple calls of function */
228  }
230  return reentrance;
231 }
232 
233 static void FAKE_SetState(
234  FAKE_STATE_s *pFakeState,
235  FAKE_FSM_STATES_e nextState,
236  FAKE_FSM_SUBSTATES_e nextSubstate,
237  uint16_t idleTime) {
238  FAS_ASSERT(pFakeState != NULL_PTR);
239  bool earlyExit = false;
240 
241  pFakeState->timer = idleTime;
242 
243  if ((pFakeState->currentState == nextState) && (pFakeState->currentSubstate == nextSubstate)) {
244  /* Next state and next substate equal to current state and substate: nothing to do */
245  pFakeState->nextState = FAKE_FSM_STATE_DUMMY; /* no state transistion required -> reset */
246  pFakeState->nextSubstate = FAKE_FSM_SUBSTATE_DUMMY; /* no substate transistion required -> reset */
247  earlyExit = true;
248  }
249 
250  if (earlyExit == false) {
251  if (pFakeState->currentState != nextState) {
252  /* Next state is different: switch to it and set substate to entry value */
253  pFakeState->previousState = pFakeState->currentState;
254  pFakeState->currentState = nextState;
255  pFakeState->previousSubstate = pFakeState->currentSubstate;
256  pFakeState->currentSubstate = FAKE_FSM_SUBSTATE_ENTRY; /* Use entry state after a top level state change */
257  pFakeState->nextState = FAKE_FSM_STATE_DUMMY; /* no state transistion required -> reset */
258  pFakeState->nextSubstate = FAKE_FSM_SUBSTATE_DUMMY; /* no substate transistion required -> reset */
259  } else if (pFakeState->currentSubstate != nextSubstate) {
260  /* Only the next substate is different, switch to it */
261  FAKE_SetSubstate(pFakeState, nextSubstate, idleTime);
262  } else {
263  ;
264  }
265  }
266 }
267 
268 static void FAKE_SetSubstate(FAKE_STATE_s *pFakeState, FAKE_FSM_SUBSTATES_e nextSubstate, uint16_t idleTime) {
269  FAS_ASSERT(pFakeState != NULL_PTR);
270  pFakeState->timer = idleTime;
271  pFakeState->previousSubstate = pFakeState->currentSubstate;
272  pFakeState->currentSubstate = nextSubstate;
273  pFakeState->nextSubstate = FAKE_FSM_SUBSTATE_DUMMY; /* substate has been set, now reset value for nextSubstate */
274 }
275 
277  FAS_ASSERT(pFakeState != NULL_PTR);
279 
280  uint16_t i = 0;
281 
282  for (uint8_t stringNumber = 0u; stringNumber < BS_NR_OF_STRINGS; stringNumber++) {
284  for (i = 0; i < BS_NR_OF_BAT_CELLS; i++) {
285  pFakeState->data.cellVoltage->cellVoltage_mV[stringNumber][i] = FAKE_CELL_VOLTAGE_mV;
286  }
287 
288  pFakeState->data.cellVoltage->state = 0;
289  pFakeState->data.cellTemperature->state = 0;
290  for (i = 0; i < BS_NR_OF_TEMP_SENSORS; i++) {
292  }
293 
294  pFakeState->data.balancingFeedback->state = 0;
295  for (i = 0; i < BS_NR_OF_BAT_CELLS; i++) {
296  pFakeState->data.balancingControl->balancingState[stringNumber][i] = 0;
297  }
298  for (i = 0; i < BS_NR_OF_MODULES; i++) {
299  pFakeState->data.balancingFeedback->value[stringNumber][i] = 0;
300  }
301 
302  pFakeState->data.slaveControl->state = 0;
303  for (i = 0; i < BS_NR_OF_MODULES; i++) {
304  pFakeState->data.slaveControl->ioValueIn[i] = 0;
305  pFakeState->data.slaveControl->ioValueOut[i] = 0;
306  pFakeState->data.slaveControl->externalTemperatureSensor[i] = 0;
307  pFakeState->data.slaveControl->eepromValueRead[i] = 0;
308  pFakeState->data.slaveControl->eepromValueWrite[i] = 0;
309  }
310  pFakeState->data.slaveControl->eepromReadAddressLastUsed = 0xFFFFFFFF;
311  pFakeState->data.slaveControl->eepromReadAddressToUse = 0xFFFFFFFF;
312  pFakeState->data.slaveControl->eepromWriteAddressLastUsed = 0xFFFFFFFF;
313  pFakeState->data.slaveControl->eepromWriteAddressToUse = 0xFFFFFFFF;
314 
315  pFakeState->data.allGpioVoltages->state = 0;
316  for (i = 0; i < (BS_NR_OF_MODULES * BS_NR_OF_GPIOS_PER_MODULE); i++) {
317  pFakeState->data.allGpioVoltages->gpioVoltages_mV[stringNumber][i] = 0;
318  }
319 
320  for (i = 0; i < (BS_NR_OF_MODULES * (BS_NR_OF_CELLS_PER_MODULE + 1)); i++) {
321  pFakeState->data.openWire->openwire[stringNumber][i] = 0;
322  }
323  pFakeState->data.openWire->state = 0;
324  }
325 
326  pFakeState->firstMeasurementFinished = true;
329  pFakeState->data.cellVoltage,
330  pFakeState->data.cellTemperature,
331  pFakeState->data.balancingFeedback,
332  pFakeState->data.balancingControl);
333  DATA_WRITE_DATA(pFakeState->data.slaveControl, pFakeState->data.openWire);
334 }
335 
337  FAS_ASSERT(pFakeState != NULL_PTR);
338  STD_RETURN_TYPE_e successfullSave = STD_OK;
339 
340  for (uint8_t stringNumber = 0u; stringNumber < BS_NR_OF_STRINGS; stringNumber++) {
341  for (uint16_t i = 0u; i < BS_NR_OF_BAT_CELLS; i++) {
342  pFakeState->data.cellVoltage->cellVoltage_mV[stringNumber][i] = FAKE_CELL_VOLTAGE_mV;
343  }
344  }
345 
346  DATA_WRITE_DATA(pFakeState->data.cellVoltage);
347 
348  return successfullSave;
349 }
350 
352  FAS_ASSERT(pFakeState != NULL_PTR);
353  STD_RETURN_TYPE_e successfullSave = STD_OK;
354 
355  for (uint8_t stringNumber = 0u; stringNumber < BS_NR_OF_STRINGS; stringNumber++) {
356  for (uint16_t i = 0u; i < BS_NR_OF_TEMP_SENSORS; i++) {
358  }
359  }
360 
361  DATA_WRITE_DATA(pFakeState->data.cellTemperature);
362 
363  return successfullSave;
364 }
365 
367  FAKE_FSM_STATES_e nextState = FAKE_FSM_STATE_INITIALIZATION; /* default behavior: stay in state */
368  static uint8_t waitForDataSaving = 0;
369  switch (pFakeState->currentSubstate) {
371  /* Nothing to do, just transfer to next substate */
374  break;
375 
377  if (true == FAKE_IsFirstMeasurementCycleFinished(pFakeState)) {
380  } else {
381  if (waitForDataSaving == 0u) {
382  if (STD_OK == FAKE_SaveFakeVoltageMeasurementData(pFakeState)) {
383  waitForDataSaving++;
384  } else {
385  /* Voltages could not be saved, transfer to error state */
386  nextState = FAKE_FSM_STATE_ERROR;
387  }
388  } else if (waitForDataSaving == 1u) {
389  if (STD_OK == FAKE_SaveFakeTemperatureMeasurementData(pFakeState)) {
390  waitForDataSaving = 0u;
392  } else {
393  /* First measurement cycle could not be finished, transfer to error state */
394  nextState = FAKE_FSM_STATE_ERROR;
395  }
396  } else {
397  /* must never happen */
398  nextState = FAKE_FSM_STATE_ERROR;
399  }
400  }
401  break;
402 
404  /* Nothing to do, just transfer to next substate */
406  break;
407 
409  /* Nothing to do, just transfer to next state */
410  nextState = FAKE_FSM_STATE_RUNNING;
411  break;
412 
413  default:
415  break;
416  }
417  return nextState;
418 }
419 
421  FAKE_FSM_STATES_e nextState = FAKE_FSM_STATE_RUNNING; /* default behavior: stay in state */
422 
423  switch (pFakeState->currentSubstate) {
425  /* Nothing to do, just transfer to next substate */
427  break;
428 
430  if (STD_OK == FAKE_SaveFakeVoltageMeasurementData(pFakeState)) {
433  } else {
434  nextState = FAKE_FSM_STATE_ERROR;
435  }
436  break;
437 
439  if (STD_OK == FAKE_SaveFakeVoltageMeasurementData(pFakeState)) {
442  } else {
443  nextState = FAKE_FSM_STATE_ERROR;
444  }
445  break;
446 
447  default:
449  break;
450  }
451 
452  return nextState;
453 }
454 
456  STD_RETURN_TYPE_e ranStateMachine = STD_OK;
458  switch (pFakeState->currentState) {
459  /********************************************** STATE: HAS NEVER RUN */
461  /* Nothing to do, just transfer */
463  break;
464 
465  /********************************************** STATE: UNINITIALIZED */
467  /* Nothing to do, just transfer */
469  break;
470 
471  /********************************************* STATE: INITIALIZATION */
473  nextState = FAKE_ProcessInitializationState(pFakeState);
474  if (nextState == FAKE_FSM_STATE_INITIALIZATION) {
475  /* staying in state, processed by state function */
476  } else if (nextState == FAKE_FSM_STATE_ERROR) {
478  } else if (nextState == FAKE_FSM_STATE_RUNNING) {
480  } else {
481  FAS_ASSERT(FAS_TRAP); /* Something went wrong */
482  }
483  break;
484 
485  /**************************************************** STATE: RUNNING */
487  nextState = FAKE_ProcessRunningState(pFakeState);
488  if (nextState == FAKE_FSM_STATE_RUNNING) {
489  /* staying in state, processed by state function */
490  } else if (nextState == FAKE_FSM_STATE_ERROR) {
492  } else {
493  FAS_ASSERT(FAS_TRAP); /* Something went wrong */
494  }
495  break;
496 
497  /****************************************************** STATE: ERROR */
499  /* this case must never happen for the dummy measurement IC, as all cases are processed */
501  break;
502 
503  /**************************************************** STATE: DEFAULT */
504  default:
505  /* all cases must be processed, trap if unknown state arrives */
507  break;
508  }
509 
510  return ranStateMachine;
511 }
512 
513 /*========== Extern Function Implementations ================================*/
515  return STD_OK;
516 }
517 
519  FAS_ASSERT(pFakeState != NULL_PTR);
520  bool returnValue = false;
522  returnValue = pFakeState->firstMeasurementFinished;
524  return returnValue;
525 }
526 
528  FAS_ASSERT(pFakeState != NULL_PTR);
529  bool earlyExit = false;
530  STD_RETURN_TYPE_e returnValue = STD_OK;
531  FAS_ASSERT(pFakeState != NULL_PTR);
532 
533  /* Check re-entrance of function */
535  returnValue = STD_NOT_OK;
536  earlyExit = true;
537  }
538 
539  if (earlyExit == false) {
540  if (pFakeState->timer > 0u) {
541  if ((--pFakeState->timer) > 0u) {
542  pFakeState->triggerEntry--;
543  returnValue = STD_OK;
544  earlyExit = true;
545  }
546  }
547  }
548 
549  if (earlyExit == false) {
550  FAKE_RunStateMachine(pFakeState);
551  pFakeState->triggerEntry--;
552  }
553  return returnValue;
554 }
555 
556 /*========== Externalized Static Function Implementations (Unit Test) =======*/
557 #ifdef UNITY_UNIT_TEST
558 extern bool TEST_FAKE_CheckMultipleCalls(FAKE_STATE_s *pFakeState) {
559  return FAKE_CheckMultipleCalls(pFakeState);
560 }
561 
564 }
565 
566 extern void TEST_FAKE_SetState(
567  FAKE_STATE_s *pFakeState,
568  FAKE_FSM_STATES_e nextState,
569  FAKE_FSM_SUBSTATES_e nextSubstate,
570  uint16_t idleTime) {
571  FAKE_SetState(pFakeState, nextState, nextSubstate, idleTime);
572 }
573 
575  return FAKE_SaveFakeVoltageMeasurementData(pFakeState);
576 }
577 
579  return FAKE_SaveFakeTemperatureMeasurementData(pFakeState);
580 }
581 
582 #endif
FAKE_DATABASE_ENTRIES::cellTemperature
DATA_BLOCK_CELL_TEMPERATURE_s * cellTemperature
Definition: debug_default.h:88
os.h
Implementation of the tasks used by the system, headers.
TEST_FAKE_SaveFakeVoltageMeasurementData
STD_RETURN_TYPE_e TEST_FAKE_SaveFakeVoltageMeasurementData(FAKE_STATE_s *pFakeState)
Definition: debug_default.c:574
FAKE_MULTIPLE_CALLS_NO
@ FAKE_MULTIPLE_CALLS_NO
Definition: debug_default.c:93
FAKE_STATE::nextState
FAKE_FSM_STATES_e nextState
Definition: debug_default.h:100
BS_NR_OF_BAT_CELLS
#define BS_NR_OF_BAT_CELLS
Definition: battery_system_cfg.h:156
TEST_FAKE_SetState
void TEST_FAKE_SetState(FAKE_STATE_s *pFakeState, FAKE_FSM_STATES_e nextState, FAKE_FSM_SUBSTATES_e nextSubstate, uint16_t idleTime)
Definition: debug_default.c:566
general.h
TODO.
DATA_BLOCK_OPENWIRE
Definition: database_cfg.h:296
FAKE_STATE::nextSubstate
FAKE_FSM_SUBSTATES_e nextSubstate
Definition: debug_default.h:103
fake_balancingFeedback
static DATA_BLOCK_BALANCING_FEEDBACK_s fake_balancingFeedback
Definition: debug_default.c:103
FAKE_DATABASE_ENTRIES::cellVoltage
DATA_BLOCK_CELL_VOLTAGE_s * cellVoltage
Definition: debug_default.h:87
BS_NR_OF_TEMP_SENSORS
#define BS_NR_OF_TEMP_SENSORS
Definition: battery_system_cfg.h:158
DATA_BLOCK_SLAVE_CONTROL::ioValueIn
uint8_t ioValueIn[BS_NR_OF_MODULES]
Definition: database_cfg.h:269
FAKE_SetFirstMeasurementCycleFinished
static void FAKE_SetFirstMeasurementCycleFinished(FAKE_STATE_s *pFakeState)
Sets the indicator that one full measurement cycles was successfull.
Definition: debug_default.c:276
DATA_BLOCK_SLAVE_CONTROL::eepromValueWrite
uint8_t eepromValueWrite[BS_NR_OF_MODULES]
Definition: database_cfg.h:270
fake_allGpioVoltage
static DATA_BLOCK_ALL_GPIO_VOLTAGES_s fake_allGpioVoltage
Definition: debug_default.c:107
TEST_FAKE_SetFirstMeasurementCycleFinished
void TEST_FAKE_SetFirstMeasurementCycleFinished(FAKE_STATE_s *pFakeState)
Definition: debug_default.c:562
FAKE_FSM_SHORT_TIME
#define FAKE_FSM_SHORT_TIME
Definition: debug_default.c:77
FAKE_DATABASE_ENTRIES::balancingFeedback
DATA_BLOCK_BALANCING_FEEDBACK_s * balancingFeedback
Definition: debug_default.h:89
BS_NR_OF_MODULES
#define BS_NR_OF_MODULES
number of modules in battery pack
Definition: battery_system_cfg.h:96
fake_openWire
static DATA_BLOCK_OPEN_WIRE_s fake_openWire
Definition: debug_default.c:108
DATA_BLOCK_ID_BALANCING_FEEDBACK_BASE
@ DATA_BLOCK_ID_BALANCING_FEEDBACK_BASE
Definition: database_cfg.h:79
DATA_BLOCK_ID_CELL_TEMPERATURE_BASE
@ DATA_BLOCK_ID_CELL_TEMPERATURE_BASE
Definition: database_cfg.h:95
FAKE_RunStateMachine
static STD_RETURN_TYPE_e FAKE_RunStateMachine(FAKE_STATE_s *pFakeState)
Defines the state transitions.
Definition: debug_default.c:455
FAKE_DATABASE_ENTRIES::allGpioVoltages
DATA_BLOCK_ALL_GPIO_VOLTAGES_s * allGpioVoltages
Definition: debug_default.h:92
FAKE_STATE::previousState
FAKE_FSM_STATES_e previousState
Definition: debug_default.h:102
DATA_BLOCK_ID_OPEN_WIRE_BASE
@ DATA_BLOCK_ID_OPEN_WIRE_BASE
Definition: database_cfg.h:81
DATA_BLOCK_SLAVE_CONTROL::eepromWriteAddressToUse
uint32_t eepromWriteAddressToUse
Definition: database_cfg.h:266
fake_state
FAKE_STATE_s fake_state
Definition: debug_default.c:114
DATA_BLOCK_SLAVE_CONTROL::state
uint8_t state
Definition: database_cfg.h:263
STD_RETURN_TYPE_e
enum STD_RETURN_TYPE STD_RETURN_TYPE_e
FAKE_CELL_TEMPERATURE_ddegC
#define FAKE_CELL_TEMPERATURE_ddegC
Definition: debug_default.c:71
diag.h
Diagnosis driver header.
FAKE_CHECK_MULTIPLE_CALLS_e
enum FAKE_CHECK_MULTIPLE_CALLS FAKE_CHECK_MULTIPLE_CALLS_e
FAKE_FSM_SUBSTATES_e
enum FAKE_FSM_SUBSTATES FAKE_FSM_SUBSTATES_e
DATA_BLOCK_SLAVE_CONTROL::eepromValueRead
uint8_t eepromValueRead[BS_NR_OF_MODULES]
Definition: database_cfg.h:271
DATA_BLOCK_ALL_GPIO_VOLTAGES::gpioVoltages_mV
uint16_t gpioVoltages_mV[BS_NR_OF_STRINGS][BS_NR_OF_MODULES *BS_NR_OF_GPIOS_PER_MODULE]
Definition: database_cfg.h:314
FAKE_MULTIPLE_CALLS_YES
@ FAKE_MULTIPLE_CALLS_YES
Definition: debug_default.c:94
DATA_BLOCK_SLAVE_CONTROL
Definition: database_cfg.h:258
FAKE_TriggerMeasurementIc
STD_RETURN_TYPE_e FAKE_TriggerMeasurementIc(FAKE_STATE_s *pFakeState)
Trigger function for the driver, called to advance the state machine.
Definition: debug_default.c:527
FAKE_DATABASE_ENTRIES::balancingControl
DATA_BLOCK_BALANCING_CONTROL_s * balancingControl
Definition: debug_default.h:90
DATA_WRITE_DATA
#define DATA_WRITE_DATA(...)
Definition: database.h:82
FAKE_SetState
static void FAKE_SetState(FAKE_STATE_s *pFakeState, FAKE_FSM_STATES_e nextState, FAKE_FSM_SUBSTATES_e nextSubstate, uint16_t idleTime)
Sets the next state, the next substate and the timer value of the state variable.
Definition: debug_default.c:233
DATA_BLOCK_CELL_VOLTAGE::packVoltage_mV
int32_t packVoltage_mV[BS_NR_OF_STRINGS]
Definition: database_cfg.h:121
FAKE_FSM_SUBSTATE_INITIALIZATION_FINISH_FIRST_MEASUREMENT
@ FAKE_FSM_SUBSTATE_INITIALIZATION_FINISH_FIRST_MEASUREMENT
Definition: debug_default.h:78
DATA_BLOCK_CELL_TEMPERATURE::state
uint8_t state
Definition: database_cfg.h:136
FAKE_FSM_SUBSTATE_INITIALIZATION_EXIT
@ FAKE_FSM_SUBSTATE_INITIALIZATION_EXIT
Definition: debug_default.h:80
FAKE_FSM_STATES_e
enum FAKE_FSM_STATES FAKE_FSM_STATES_e
DATA_BLOCK_SLAVE_CONTROL::eepromWriteAddressLastUsed
uint32_t eepromWriteAddressLastUsed
Definition: database_cfg.h:267
battery_system_cfg.h
Configuration of the battery system (e.g., number of battery modules, battery cells,...
fake_cellTemperature
static DATA_BLOCK_CELL_TEMPERATURE_s fake_cellTemperature
Definition: debug_default.c:102
FAKE_FSM_SUBSTATE_RUNNING_SAVE_VOLTAGE_MEASUREMENT_DATA
@ FAKE_FSM_SUBSTATE_RUNNING_SAVE_VOLTAGE_MEASUREMENT_DATA
Definition: debug_default.h:81
DATA_BLOCK_ID_SLAVE_CONTROL
@ DATA_BLOCK_ID_SLAVE_CONTROL
Definition: database_cfg.h:78
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
FAKE_SaveFakeTemperatureMeasurementData
static STD_RETURN_TYPE_e FAKE_SaveFakeTemperatureMeasurementData(FAKE_STATE_s *pFakeState)
Write temperature measurement data.
Definition: debug_default.c:351
FAKE_STATE::previousSubstate
FAKE_FSM_SUBSTATES_e previousSubstate
Definition: debug_default.h:105
DATA_BLOCK_SLAVE_CONTROL::eepromReadAddressLastUsed
uint32_t eepromReadAddressLastUsed
Definition: database_cfg.h:265
FAKE_FSM_SUBSTATE_DUMMY
@ FAKE_FSM_SUBSTATE_DUMMY
Definition: debug_default.h:76
FAKE_STATE
Definition: debug_default.h:97
FAKE_IsFirstMeasurementCycleFinished
bool FAKE_IsFirstMeasurementCycleFinished(FAKE_STATE_s *pFakeState)
return whether the first measurement cycle is finished
Definition: debug_default.c:518
DATA_BLOCK_BALANCING_CONTROL::header
DATA_BLOCK_HEADER_s header
Definition: database_cfg.h:249
FAS_ASSERT
#define FAS_ASSERT(x)
Assertion macro that asserts that x is true.
Definition: fassert.h:233
FAKE_CELL_VOLTAGE_mV
#define FAKE_CELL_VOLTAGE_mV
Definition: debug_default.c:68
DATA_BLOCK_BALANCING_FEEDBACK
Definition: database_cfg.h:276
FAKE_FSM_SUBSTATE_ENTRY
@ FAKE_FSM_SUBSTATE_ENTRY
Definition: debug_default.h:77
OS_ExitTaskCritical
void OS_ExitTaskCritical(void)
Exit Critical interface function for use in FreeRTOS-Tasks and FreeRTOS-ISR.
Definition: os.c:178
DATA_BLOCK_CELL_TEMPERATURE::header
DATA_BLOCK_HEADER_s header
Definition: database_cfg.h:135
FAKE_FSM_STATE_UNINITIALIZED
@ FAKE_FSM_STATE_UNINITIALIZED
Definition: debug_default.h:68
FAKE_FSM_STATE_HAS_NEVER_RUN
@ FAKE_FSM_STATE_HAS_NEVER_RUN
Definition: debug_default.h:67
DATA_BLOCK_ID_CELL_VOLTAGE_BASE
@ DATA_BLOCK_ID_CELL_VOLTAGE_BASE
Definition: database_cfg.h:94
FAKE_DATABASE_ENTRIES::openWire
DATA_BLOCK_OPEN_WIRE_s * openWire
Definition: debug_default.h:93
FAKE_FSM_SUBSTATE_RUNNING_SAVE_TEMPERATURE_MEASUREMENT_DATA
@ FAKE_FSM_SUBSTATE_RUNNING_SAVE_TEMPERATURE_MEASUREMENT_DATA
Definition: debug_default.h:82
FAKE_STATE::firstMeasurementFinished
bool firstMeasurementFinished
Definition: debug_default.h:106
STD_OK
@ STD_OK
Definition: fstd_types.h:72
FAKE_ProcessInitializationState
static FAKE_FSM_STATES_e FAKE_ProcessInitializationState(FAKE_STATE_s *pFakeState)
Processes the initialization state.
Definition: debug_default.c:366
FAKE_FSM_STATE_INITIALIZATION
@ FAKE_FSM_STATE_INITIALIZATION
Definition: debug_default.h:69
DATA_BLOCK_ID_ALL_GPIO_VOLTAGES_BASE
@ DATA_BLOCK_ID_ALL_GPIO_VOLTAGES_BASE
Definition: database_cfg.h:82
FAKE_FSM_STATE_RUNNING
@ FAKE_FSM_STATE_RUNNING
Definition: debug_default.h:70
FAKE_SetSubstate
static void FAKE_SetSubstate(FAKE_STATE_s *pFakeState, FAKE_FSM_SUBSTATES_e nextSubstate, uint16_t idleTime)
Sets the next substate and the timer value of the state variable.
Definition: debug_default.c:268
OS_EnterTaskCritical
void OS_EnterTaskCritical(void)
Enter Critical interface function for use in FreeRTOS-Tasks and FreeRTOS-ISR.
Definition: os.c:174
STD_NOT_OK
@ STD_NOT_OK
Definition: fstd_types.h:73
DATA_BLOCK_ALL_GPIO_VOLTAGES::header
DATA_BLOCK_HEADER_s header
Definition: database_cfg.h:312
DATA_BLOCK_BALANCING_FEEDBACK::header
DATA_BLOCK_HEADER_s header
Definition: database_cfg.h:280
battery_cell_cfg.h
Configuration of the battery cell (e.g., minimum and maximum cell voltage)
DATA_BLOCK_CELL_VOLTAGE::cellVoltage_mV
int16_t cellVoltage_mV[BS_NR_OF_STRINGS][BS_NR_OF_BAT_CELLS]
Definition: database_cfg.h:122
DATA_BLOCK_SLAVE_CONTROL::eepromReadAddressToUse
uint32_t eepromReadAddressToUse
Definition: database_cfg.h:264
FAKE_DATABASE_ENTRIES::slaveControl
DATA_BLOCK_SLAVE_CONTROL_s * slaveControl
Definition: debug_default.h:91
FAKE_FSM_SUBSTATE_INITIALIZATION_FIRST_MEASUREMENT_FINISHED
@ FAKE_FSM_SUBSTATE_INITIALIZATION_FIRST_MEASUREMENT_FINISHED
Definition: debug_default.h:79
fake_cellVoltage
static DATA_BLOCK_CELL_VOLTAGE_s fake_cellVoltage
Definition: debug_default.c:101
DATA_BLOCK_CELL_TEMPERATURE
Definition: database_cfg.h:131
DATA_BLOCK_ID_BALANCING_CONTROL
@ DATA_BLOCK_ID_BALANCING_CONTROL
Definition: database_cfg.h:77
DATA_BLOCK_BALANCING_CONTROL::balancingState
uint8_t balancingState[BS_NR_OF_STRINGS][BS_NR_OF_BAT_CELLS]
Definition: database_cfg.h:253
DATA_BLOCK_CELL_VOLTAGE
Definition: database_cfg.h:115
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
DATA_BLOCK_ALL_GPIO_VOLTAGES::state
uint8_t state
Definition: database_cfg.h:313
DATA_BLOCK_BALANCING_FEEDBACK::value
uint16_t value[BS_NR_OF_STRINGS][BS_NR_OF_MODULES]
Definition: database_cfg.h:282
FAKE_SaveFakeVoltageMeasurementData
static STD_RETURN_TYPE_e FAKE_SaveFakeVoltageMeasurementData(FAKE_STATE_s *pFakeState)
Write voltage measurement data.
Definition: debug_default.c:336
database.h
Database module header.
NULL_PTR
#define NULL_PTR
Null pointer.
Definition: fstd_types.h:66
FAKE_STATE::currentState
FAKE_FSM_STATES_e currentState
Definition: debug_default.h:101
DATA_BLOCK_BALANCING_FEEDBACK::state
uint8_t state
Definition: database_cfg.h:281
FAKE_CheckMultipleCalls
static bool FAKE_CheckMultipleCalls(FAKE_STATE_s *pFakeState)
check for multiple calls of state machine trigger function
Definition: debug_default.c:220
FAKE_FSM_STATE_DUMMY
@ FAKE_FSM_STATE_DUMMY
Definition: debug_default.h:66
FAKE_STATE::data
FAKE_DATABASE_ENTRIES_s data
Definition: debug_default.h:107
FAKE_CHECK_MULTIPLE_CALLS
FAKE_CHECK_MULTIPLE_CALLS
Definition: debug_default.c:92
FAKE_STATE::timer
uint16_t timer
Definition: debug_default.h:98
FAKE_ProcessRunningState
static FAKE_FSM_STATES_e FAKE_ProcessRunningState(FAKE_STATE_s *pFakeState)
Processes the running state.
Definition: debug_default.c:420
FAKE_STATE::triggerEntry
uint8_t triggerEntry
Definition: debug_default.h:99
DATA_BLOCK_ALL_GPIO_VOLTAGES
Definition: database_cfg.h:308
BS_NR_OF_GPIOS_PER_MODULE
#define BS_NR_OF_GPIOS_PER_MODULE
Number of GPIOs on the LTC IC.
Definition: battery_system_cfg.h:145
TEST_FAKE_SaveFakeTemperatureMeasurementData
STD_RETURN_TYPE_e TEST_FAKE_SaveFakeTemperatureMeasurementData(FAKE_STATE_s *pFakeState)
Definition: debug_default.c:578
debug_default.h
Header for the driver of the fake measurement IC driver.
DATA_BLOCK_SLAVE_CONTROL::ioValueOut
uint8_t ioValueOut[BS_NR_OF_MODULES]
Definition: database_cfg.h:268
TEST_FAKE_CheckMultipleCalls
bool TEST_FAKE_CheckMultipleCalls(FAKE_STATE_s *pFakeState)
Definition: debug_default.c:558
FAS_TRAP
#define FAS_TRAP
Define that evaluates to essential boolean false thus tripping an assert.
Definition: fassert.h:108
DATA_BLOCK_OPENWIRE::state
uint8_t state
Definition: database_cfg.h:301
DATA_BLOCK_OPENWIRE::header
DATA_BLOCK_HEADER_s header
Definition: database_cfg.h:300
FAKE_Initialize
STD_RETURN_TYPE_e FAKE_Initialize(void)
initialize driver
Definition: debug_default.c:514
DATA_BLOCK_SLAVE_CONTROL::header
DATA_BLOCK_HEADER_s header
Definition: database_cfg.h:262
FAKE_FSM_LONG_TIME
#define FAKE_FSM_LONG_TIME
Definition: debug_default.c:89
DATA_BLOCK_BALANCING_CONTROL
Definition: database_cfg.h:245
DATA_BLOCK_CELL_VOLTAGE::state
uint8_t state
Definition: database_cfg.h:120
DATA_BLOCK_CELL_VOLTAGE::header
DATA_BLOCK_HEADER_s header
Definition: database_cfg.h:119
FAKE_STATE::currentSubstate
FAKE_FSM_SUBSTATES_e currentSubstate
Definition: debug_default.h:104
BS_NR_OF_STRINGS
#define BS_NR_OF_STRINGS
Definition: battery_system_cfg.h:89
fake_balancingControl
static DATA_BLOCK_BALANCING_CONTROL_s fake_balancingControl
Definition: debug_default.c:105
DATA_BLOCK_CELL_TEMPERATURE::cellTemperature_ddegC
int16_t cellTemperature_ddegC[BS_NR_OF_STRINGS][BS_NR_OF_TEMP_SENSORS]
Definition: database_cfg.h:137
fake_slaveControl
static DATA_BLOCK_SLAVE_CONTROL_s fake_slaveControl
Definition: debug_default.c:106
DATA_BLOCK_SLAVE_CONTROL::externalTemperatureSensor
uint8_t externalTemperatureSensor[BS_NR_OF_MODULES]
Definition: database_cfg.h:272
DATA_BLOCKHEADER::uniqueId
DATA_BLOCK_ID_e uniqueId
Definition: database_cfg.h:109
FAKE_FSM_STATE_ERROR
@ FAKE_FSM_STATE_ERROR
Definition: debug_default.h:71