foxBMS - Unit Tests  1.5.0
The foxBMS Unit Tests API Documentation
debug_default.c
Go to the documentation of this file.
1 /**
2  *
3  * @copyright © 2010 - 2023, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V.
4  * All rights reserved.
5  *
6  * SPDX-License-Identifier: BSD-3-Clause
7  *
8  * Redistribution and use in source and binary forms, with or without
9  * modification, are permitted provided that the following conditions are met:
10  *
11  * 1. Redistributions of source code must retain the above copyright notice, this
12  * list of conditions and the following disclaimer.
13  *
14  * 2. Redistributions in binary form must reproduce the above copyright notice,
15  * this list of conditions and the following disclaimer in the documentation
16  * and/or other materials provided with the distribution.
17  *
18  * 3. Neither the name of the copyright holder nor the names of its
19  * contributors may be used to endorse or promote products derived from
20  * this software without specific prior written permission.
21  *
22  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
23  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
25  * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
26  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
27  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
28  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
29  * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
30  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
31  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32  *
33  * We kindly request you to use one or more of the following phrases to refer to
34  * foxBMS in your hardware, software, documentation or advertising materials:
35  *
36  * - ″This product uses parts of foxBMS®″
37  * - ″This product includes parts of foxBMS®″
38  * - ″This product is derived from foxBMS®″
39  *
40  */
41 
42 /**
43  * @file debug_default.c
44  * @author foxBMS Team
45  * @date 2020-09-17 (date of creation)
46  * @updated 2023-02-03 (date of last update)
47  * @version v1.5.0
48  * @ingroup DRIVER
49  * @prefix FAKE
50  *
51  * @brief Driver implementation for the fake AFE
52  *
53  */
54 
55 /*========== Includes =======================================================*/
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 "fstd_types.h"
65 #include "os.h"
66 
67 #include <stdint.h>
68 
69 /*========== Macros and Definitions =========================================*/
70 /** faked cell voltage value for all cell voltages in mV */
71 #define FAKE_CELL_VOLTAGE_mV (BC_VOLTAGE_NOMINAL_mV)
72 
73 /** faked cell temperature for all cell temperatures in deci &deg;C */
74 #define FAKE_CELL_TEMPERATURE_ddegC ((BC_TEMPERATURE_MAX_CHARGE_MOL_ddegC + BC_TEMPERATURE_MIN_CHARGE_MOL_ddegC) / 2u)
75 
76 /**
77  * state machine short time definition in #FAKE_TriggerAfe calls
78  * until next state is processed
79  */
80 #define FAKE_FSM_SHORT_TIME (1u)
81 
82 /**
83  * state machine medium time definition in #FAKE_TriggerAfe calls
84  * until next state/substate is processed
85  */
86 #define FAKE_FSM_MEDIUM_TIME (5u)
87 
88 /**
89  * state machine long time definition in #FAKE_TriggerAfe calls
90  * until next state/substate is processed
91  */
92 #define FAKE_FSM_LONG_TIME (10u)
93 
94 /** Symbolic names to check for multiple calls of #FAKE_TriggerAfe */
95 typedef enum {
96  FAKE_MULTIPLE_CALLS_NO, /*!< no multiple calls, OK */
97  FAKE_MULTIPLE_CALLS_YES, /*!< multiple calls, not OK */
99 
100 /*========== Static Constant and Variable Definitions =======================*/
101 
102 /** local copies of database tables */
103 /**@{*/
112 /**@}*/
113 
114 /*========== Extern Constant and Variable Definitions =======================*/
115 
116 /** local instance of the driver-state */
118  .timer = 0,
119  .triggerEntry = 0,
120  .nextState = FAKE_FSM_STATE_HAS_NEVER_RUN,
121  .currentState = FAKE_FSM_STATE_HAS_NEVER_RUN,
122  .previousState = FAKE_FSM_STATE_HAS_NEVER_RUN,
123  .nextSubstate = FAKE_FSM_SUBSTATE_DUMMY,
124  .currentSubstate = FAKE_FSM_SUBSTATE_DUMMY,
125  .previousSubstate = FAKE_FSM_SUBSTATE_DUMMY,
126  .firstMeasurementFinished = false,
127  .data.allGpioVoltages = &fake_allGpioVoltage,
128  .data.balancingControl = &fake_balancingControl,
129  .data.balancingFeedback = &fake_balancingFeedback,
130  .data.cellTemperature = &fake_cellTemperature,
131  .data.cellVoltage = &fake_cellVoltage,
132  .data.openWire = &fake_openWire,
133  .data.slaveControl = &fake_slaveControl,
134 };
135 
136 /*========== Static Function Prototypes =====================================*/
137 /**
138  * @brief check for multiple calls of state machine trigger function
139  * @details The trigger function is not reentrant, which means it cannot
140  * be called multiple times. This functions increments the
141  * triggerEntry counter once and must be called each time the
142  * trigger function is called. If triggerEntry is greater than
143  * one, there were multiple calls. For this function to work,
144  * triggerEntry must be decremented each time the trigger function
145  * is called, even if no processing do because the timer is
146  * non-zero.
147  * @param pFakeState state of the fake state machine
148  * @return true if there were multiple calls, false otherwise
149  */
150 static bool FAKE_CheckMultipleCalls(FAKE_STATE_s *pFakeState);
151 
152 /**
153  * @brief Sets the next state, the next substate and the timer value
154  * of the state variable.
155  * @param pFakeState state of the example state machine
156  * @param nextState state to be transferred into
157  * @param nextSubstate substate to be transferred into
158  * @param idleTime wait time for the state machine
159  */
160 static void FAKE_SetState(
161  FAKE_STATE_s *pFakeState,
162  FAKE_FSM_STATES_e nextState,
163  FAKE_FSM_SUBSTATES_e nextSubstate,
164  uint16_t idleTime);
165 
166 /**
167  * @brief Sets the next substate and the timer value
168  * of the state variable.
169  * @param pFakeState state of the example state machine
170  * @param nextSubstate substate to be transferred into
171  * @param idleTime wait time for the state machine
172  */
173 static void FAKE_SetSubstate(FAKE_STATE_s *pFakeState, FAKE_FSM_SUBSTATES_e nextSubstate, uint16_t idleTime);
174 
175 /**
176  * @brief Sets the indicator that one full measurement cycles was successful
177  * @param pFakeState state of the fake state machine
178  * @return true if it is a reentrance, false otherwise
179  */
180 static void FAKE_SetFirstMeasurementCycleFinished(FAKE_STATE_s *pFakeState);
181 
182 /**
183  * @brief Write voltage measurement data
184  * @param pFakeState state of the fake state machine
185  * @return #STD_OK if successful, #STD_NOT_OK otherwise
186  */
188 
189 /**
190  * @brief Write temperature measurement data
191  * @param pFakeState state of the fake state machine
192  * @return #STD_OK if successful, #STD_NOT_OK otherwise
193  */
195 
196 /**
197  * @brief Processes the initialization state
198  * @param pFakeState state of the fake state machine
199  * @return Always #STD_OK
200  */
202 
203 /**
204  * @brief Processes the running state
205  * @param pFakeState state of the fake state machine
206  * @return Always #STD_OK
207  */
209 
210 /**
211  * @brief Defines the state transitions
212  * @details This function contains the implementation of the state
213  * machine, i.e., the sequence of states and substates.
214  * It is called by the trigger function every time
215  * the state machine timer has a non-zero value.
216  * @param pFakeState state of the example state machine
217  * @return Always #STD_OK
218  */
220 
221 /*========== Static Function Implementations ================================*/
222 
223 static bool FAKE_CheckMultipleCalls(FAKE_STATE_s *pFakeState) {
224  FAS_ASSERT(pFakeState != NULL_PTR);
225  bool reentrance = false;
227  if (pFakeState->triggerEntry == 0u) {
228  pFakeState->triggerEntry++;
229  } else {
230  reentrance = true; /* multiple calls of function */
231  }
233  return reentrance;
234 }
235 
236 static void FAKE_SetState(
237  FAKE_STATE_s *pFakeState,
238  FAKE_FSM_STATES_e nextState,
239  FAKE_FSM_SUBSTATES_e nextSubstate,
240  uint16_t idleTime) {
241  FAS_ASSERT(pFakeState != NULL_PTR);
242  bool earlyExit = false;
243 
244  pFakeState->timer = idleTime;
245 
246  if ((pFakeState->currentState == nextState) && (pFakeState->currentSubstate == nextSubstate)) {
247  /* Next state and next substate equal to current state and substate: nothing to do */
248  pFakeState->nextState = FAKE_FSM_STATE_DUMMY; /* no state transistion required -> reset */
249  pFakeState->nextSubstate = FAKE_FSM_SUBSTATE_DUMMY; /* no substate transistion required -> reset */
250  earlyExit = true;
251  }
252 
253  if (earlyExit == false) {
254  if (pFakeState->currentState != nextState) {
255  /* Next state is different: switch to it and set substate to entry value */
256  pFakeState->previousState = pFakeState->currentState;
257  pFakeState->currentState = nextState;
258  pFakeState->previousSubstate = pFakeState->currentSubstate;
259  pFakeState->currentSubstate = FAKE_FSM_SUBSTATE_ENTRY; /* Use entry state after a top level state change */
260  pFakeState->nextState = FAKE_FSM_STATE_DUMMY; /* no state transistion required -> reset */
261  pFakeState->nextSubstate = FAKE_FSM_SUBSTATE_DUMMY; /* no substate transistion required -> reset */
262  } else if (pFakeState->currentSubstate != nextSubstate) {
263  /* Only the next substate is different, switch to it */
264  FAKE_SetSubstate(pFakeState, nextSubstate, idleTime);
265  } else {
266  ;
267  }
268  }
269 }
270 
271 static void FAKE_SetSubstate(FAKE_STATE_s *pFakeState, FAKE_FSM_SUBSTATES_e nextSubstate, uint16_t idleTime) {
272  FAS_ASSERT(pFakeState != NULL_PTR);
273  pFakeState->timer = idleTime;
274  pFakeState->previousSubstate = pFakeState->currentSubstate;
275  pFakeState->currentSubstate = nextSubstate;
276  pFakeState->nextSubstate = FAKE_FSM_SUBSTATE_DUMMY; /* substate has been set, now reset value for nextSubstate */
277 }
278 
280  FAS_ASSERT(pFakeState != NULL_PTR);
282 
283  uint16_t i = 0;
284 
285  for (uint8_t s = 0u; s < BS_NR_OF_STRINGS; s++) {
287  for (i = 0; i < BS_NR_OF_CELL_BLOCKS_PER_STRING; i++) {
289  }
290 
291  pFakeState->data.cellVoltage->state = 0;
292  pFakeState->data.cellTemperature->state = 0;
293  for (i = 0; i < BS_NR_OF_TEMP_SENSORS_PER_STRING; i++) {
295  }
296 
297  pFakeState->data.balancingFeedback->state = 0;
298  for (i = 0; i < BS_NR_OF_CELL_BLOCKS_PER_STRING; i++) {
299  pFakeState->data.balancingControl->balancingState[s][i] = 0;
300  }
301  pFakeState->data.balancingControl->nrBalancedCells[s] = 0u;
302  for (i = 0; i < BS_NR_OF_MODULES_PER_STRING; i++) {
303  pFakeState->data.balancingFeedback->value[s][i] = 0;
304  }
305 
306  pFakeState->data.slaveControl->state = 0;
307  for (i = 0; i < BS_NR_OF_MODULES_PER_STRING; i++) {
308  pFakeState->data.slaveControl->ioValueIn[i] = 0;
309  pFakeState->data.slaveControl->ioValueOut[i] = 0;
310  pFakeState->data.slaveControl->externalTemperatureSensor[i] = 0;
311  pFakeState->data.slaveControl->eepromValueRead[i] = 0;
312  pFakeState->data.slaveControl->eepromValueWrite[i] = 0;
313  }
314  pFakeState->data.slaveControl->eepromReadAddressLastUsed = 0xFFFFFFFF;
315  pFakeState->data.slaveControl->eepromReadAddressToUse = 0xFFFFFFFF;
316  pFakeState->data.slaveControl->eepromWriteAddressLastUsed = 0xFFFFFFFF;
317  pFakeState->data.slaveControl->eepromWriteAddressToUse = 0xFFFFFFFF;
318 
319  pFakeState->data.allGpioVoltages->state = 0;
320  for (i = 0; i < (BS_NR_OF_MODULES_PER_STRING * BS_NR_OF_GPIOS_PER_MODULE); i++) {
321  pFakeState->data.allGpioVoltages->gpioVoltages_mV[s][i] = 0;
322  }
323 
324  for (i = 0; i < (BS_NR_OF_MODULES_PER_STRING * (BS_NR_OF_CELL_BLOCKS_PER_MODULE + 1)); i++) {
325  pFakeState->data.openWire->openWire[s][i] = 0;
326  }
327  pFakeState->data.openWire->state = 0;
328  }
329 
330  pFakeState->firstMeasurementFinished = true;
333  pFakeState->data.cellVoltage,
334  pFakeState->data.cellTemperature,
335  pFakeState->data.balancingFeedback,
336  pFakeState->data.balancingControl);
337  DATA_WRITE_DATA(pFakeState->data.slaveControl, pFakeState->data.openWire);
338 }
339 
341  FAS_ASSERT(pFakeState != NULL_PTR);
342  STD_RETURN_TYPE_e successfullSave = STD_OK;
343 
344  for (uint8_t s = 0u; s < BS_NR_OF_STRINGS; s++) {
345  pFakeState->data.cellVoltage->nrValidCellVoltages[s] = 0u;
346  for (uint16_t i = 0u; i < BS_NR_OF_CELL_BLOCKS_PER_STRING; i++) {
348  pFakeState->data.cellVoltage->nrValidCellVoltages[s] += 1u;
349  }
350  }
351 
352  DATA_WRITE_DATA(pFakeState->data.cellVoltage);
353 
354  return successfullSave;
355 }
356 
358  FAS_ASSERT(pFakeState != NULL_PTR);
359  STD_RETURN_TYPE_e successfullSave = STD_OK;
360 
361  for (uint8_t s = 0u; s < BS_NR_OF_STRINGS; s++) {
362  for (uint16_t i = 0u; i < BS_NR_OF_TEMP_SENSORS_PER_STRING; i++) {
364  }
365  }
366 
367  DATA_WRITE_DATA(pFakeState->data.cellTemperature);
368 
369  return successfullSave;
370 }
371 
373  FAKE_FSM_STATES_e nextState = FAKE_FSM_STATE_INITIALIZATION; /* default behavior: stay in state */
374  static uint8_t waitForDataSaving = 0;
375  switch (pFakeState->currentSubstate) {
377  /* Nothing to do, just transfer to next substate */
380  break;
381 
383  if (FAKE_IsFirstMeasurementCycleFinished(pFakeState) == true) {
386  } else {
387  if (waitForDataSaving == 0u) {
388  if (STD_OK == FAKE_SaveFakeVoltageMeasurementData(pFakeState)) {
389  waitForDataSaving++;
390  } else {
391  /* Voltages could not be saved, transfer to error state */
392  nextState = FAKE_FSM_STATE_ERROR;
393  }
394  } else if (waitForDataSaving == 1u) {
395  if (STD_OK == FAKE_SaveFakeTemperatureMeasurementData(pFakeState)) {
396  waitForDataSaving = 0u;
398  } else {
399  /* First measurement cycle could not be finished, transfer to error state */
400  nextState = FAKE_FSM_STATE_ERROR;
401  }
402  } else {
403  /* must never happen */
404  nextState = FAKE_FSM_STATE_ERROR;
405  }
406  }
407  break;
408 
410  /* Nothing to do, just transfer to next substate */
412  break;
413 
415  /* Nothing to do, just transfer to next state */
416  nextState = FAKE_FSM_STATE_RUNNING;
417  break;
418 
419  default:
421  break; /* LCOV_EXCL_LINE */
422  }
423  return nextState;
424 }
425 
427  FAKE_FSM_STATES_e nextState = FAKE_FSM_STATE_RUNNING; /* default behavior: stay in state */
428 
429  switch (pFakeState->currentSubstate) {
431  /* Nothing to do, just transfer to next substate */
433  break;
434 
436  if (STD_OK == FAKE_SaveFakeVoltageMeasurementData(pFakeState)) {
439  } else {
440  nextState = FAKE_FSM_STATE_ERROR;
441  }
442  break;
443 
445  if (STD_OK == FAKE_SaveFakeTemperatureMeasurementData(pFakeState)) {
448  } else {
449  nextState = FAKE_FSM_STATE_ERROR;
450  }
451  break;
452 
453  default:
455  break; /* LCOV_EXCL_LINE */
456  }
457 
458  return nextState;
459 }
460 
462  STD_RETURN_TYPE_e ranStateMachine = STD_OK;
464  switch (pFakeState->currentState) {
465  /********************************************** STATE: HAS NEVER RUN */
467  /* Nothing to do, just transfer */
469  break;
470 
471  /********************************************** STATE: UNINITIALIZED */
473  /* Nothing to do, just transfer */
475  break;
476 
477  /********************************************* STATE: INITIALIZATION */
479  nextState = FAKE_ProcessInitializationState(pFakeState);
480  if (nextState == FAKE_FSM_STATE_INITIALIZATION) {
481  /* staying in state, processed by state function */
482  } else if (nextState == FAKE_FSM_STATE_ERROR) {
484  } else if (nextState == FAKE_FSM_STATE_RUNNING) {
486  } else {
487  FAS_ASSERT(FAS_TRAP); /* Something went wrong */
488  }
489  break;
490 
491  /**************************************************** STATE: RUNNING */
493  nextState = FAKE_ProcessRunningState(pFakeState);
494  if (nextState == FAKE_FSM_STATE_RUNNING) {
495  /* staying in state, processed by state function */
496  } else if (nextState == FAKE_FSM_STATE_ERROR) {
498  } else {
499  FAS_ASSERT(FAS_TRAP); /* Something went wrong */
500  }
501  break;
502 
503  /****************************************************** STATE: ERROR */
505  /* this case must never happen for the dummy AFE, as all cases are processed */
507  break;
508 
509  /**************************************************** STATE: DEFAULT */
510  default:
511  /* all cases must be processed, trap if unknown state arrives */
513  break;
514  }
515 
516  return ranStateMachine;
517 }
518 
519 /*========== Extern Function Implementations ================================*/
521  return STD_OK;
522 }
523 
525  FAS_ASSERT(pFakeState != NULL_PTR);
526  bool returnValue = false;
528  returnValue = pFakeState->firstMeasurementFinished;
530  return returnValue;
531 }
532 
534  FAS_ASSERT(pFakeState != NULL_PTR);
535  bool earlyExit = false;
536  STD_RETURN_TYPE_e returnValue = STD_OK;
537  FAS_ASSERT(pFakeState != NULL_PTR);
538 
539  /* Check re-entrance of function */
541  returnValue = STD_NOT_OK;
542  earlyExit = true;
543  }
544 
545  if (earlyExit == false) {
546  if (pFakeState->timer > 0u) {
547  if ((--pFakeState->timer) > 0u) {
548  pFakeState->triggerEntry--;
549  returnValue = STD_OK;
550  earlyExit = true;
551  }
552  }
553  }
554 
555  if (earlyExit == false) {
556  FAKE_RunStateMachine(pFakeState);
557  pFakeState->triggerEntry--;
558  }
559  return returnValue;
560 }
561 
562 /*========== Externalized Static Function Implementations (Unit Test) =======*/
563 #ifdef UNITY_UNIT_TEST
564 extern bool TEST_FAKE_CheckMultipleCalls(FAKE_STATE_s *pFakeState) {
565  return FAKE_CheckMultipleCalls(pFakeState);
566 }
567 
570 }
571 
572 extern void TEST_FAKE_SetState(
573  FAKE_STATE_s *pFakeState,
574  FAKE_FSM_STATES_e nextState,
575  FAKE_FSM_SUBSTATES_e nextSubstate,
576  uint16_t idleTime) {
577  FAKE_SetState(pFakeState, nextState, nextSubstate, idleTime);
578 }
579 
581  return FAKE_SaveFakeVoltageMeasurementData(pFakeState);
582 }
583 
585  return FAKE_SaveFakeTemperatureMeasurementData(pFakeState);
586 }
587 
588 #endif
Configuration of the battery cell (e.g., minimum and maximum cell voltage)
Configuration of the battery system (e.g., number of battery modules, battery cells,...
#define BS_NR_OF_CELL_BLOCKS_PER_MODULE
number of cells per module
#define BS_NR_OF_STRINGS
Number of parallel strings in the battery pack.
#define BS_NR_OF_GPIOS_PER_MODULE
Defines the number of GPIOs.
#define BS_NR_OF_CELL_BLOCKS_PER_STRING
#define BS_NR_OF_MODULES_PER_STRING
number of modules in a string
#define BS_NR_OF_TEMP_SENSORS_PER_STRING
Database module header.
#define DATA_WRITE_DATA(...)
Definition: database.h:96
@ DATA_BLOCK_ID_BALANCING_CONTROL
Definition: database_cfg.h:83
@ DATA_BLOCK_ID_CELL_TEMPERATURE_BASE
Definition: database_cfg.h:101
@ DATA_BLOCK_ID_OPEN_WIRE_BASE
Definition: database_cfg.h:87
@ DATA_BLOCK_ID_SLAVE_CONTROL
Definition: database_cfg.h:84
@ DATA_BLOCK_ID_CELL_VOLTAGE_BASE
Definition: database_cfg.h:100
@ DATA_BLOCK_ID_ALL_GPIO_VOLTAGES_BASE
Definition: database_cfg.h:88
@ DATA_BLOCK_ID_BALANCING_FEEDBACK_BASE
Definition: database_cfg.h:85
static FAKE_FSM_STATES_e FAKE_ProcessInitializationState(FAKE_STATE_s *pFakeState)
Processes the initialization state.
static STD_RETURN_TYPE_e FAKE_SaveFakeVoltageMeasurementData(FAKE_STATE_s *pFakeState)
Write voltage measurement data.
static STD_RETURN_TYPE_e FAKE_SaveFakeTemperatureMeasurementData(FAKE_STATE_s *pFakeState)
Write temperature measurement data.
static bool FAKE_CheckMultipleCalls(FAKE_STATE_s *pFakeState)
check for multiple calls of state machine trigger function
static void FAKE_SetFirstMeasurementCycleFinished(FAKE_STATE_s *pFakeState)
Sets the indicator that one full measurement cycles was successful.
static DATA_BLOCK_ALL_GPIO_VOLTAGES_s fake_allGpioVoltage
static DATA_BLOCK_BALANCING_CONTROL_s fake_balancingControl
STD_RETURN_TYPE_e TEST_FAKE_SaveFakeVoltageMeasurementData(FAKE_STATE_s *pFakeState)
#define FAKE_CELL_TEMPERATURE_ddegC
Definition: debug_default.c:74
STD_RETURN_TYPE_e FAKE_Initialize(void)
initialize driver
FAKE_STATE_s fake_state
STD_RETURN_TYPE_e FAKE_TriggerAfe(FAKE_STATE_s *pFakeState)
Trigger function for the driver, called to advance the state machine.
#define FAKE_CELL_VOLTAGE_mV
Definition: debug_default.c:71
static DATA_BLOCK_CELL_TEMPERATURE_s fake_cellTemperature
static FAKE_FSM_STATES_e FAKE_ProcessRunningState(FAKE_STATE_s *pFakeState)
Processes the running state.
#define FAKE_FSM_LONG_TIME
Definition: debug_default.c:92
static DATA_BLOCK_SLAVE_CONTROL_s fake_slaveControl
STD_RETURN_TYPE_e TEST_FAKE_SaveFakeTemperatureMeasurementData(FAKE_STATE_s *pFakeState)
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.
bool FAKE_IsFirstMeasurementCycleFinished(FAKE_STATE_s *pFakeState)
return whether the first measurement cycle is finished
static DATA_BLOCK_BALANCING_FEEDBACK_s fake_balancingFeedback
void TEST_FAKE_SetFirstMeasurementCycleFinished(FAKE_STATE_s *pFakeState)
static DATA_BLOCK_CELL_VOLTAGE_s fake_cellVoltage
static DATA_BLOCK_OPEN_WIRE_s fake_openWire
#define FAKE_FSM_SHORT_TIME
Definition: debug_default.c:80
FAKE_CHECK_MULTIPLE_CALLS_e
Definition: debug_default.c:95
@ FAKE_MULTIPLE_CALLS_NO
Definition: debug_default.c:96
@ FAKE_MULTIPLE_CALLS_YES
Definition: debug_default.c:97
static STD_RETURN_TYPE_e FAKE_RunStateMachine(FAKE_STATE_s *pFakeState)
Defines the state transitions.
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.
void TEST_FAKE_SetState(FAKE_STATE_s *pFakeState, FAKE_FSM_STATES_e nextState, FAKE_FSM_SUBSTATES_e nextSubstate, uint16_t idleTime)
bool TEST_FAKE_CheckMultipleCalls(FAKE_STATE_s *pFakeState)
Header for the driver of the fake AFE driver.
FAKE_FSM_SUBSTATES_e
Definition: debug_default.h:80
@ FAKE_FSM_SUBSTATE_DUMMY
Definition: debug_default.h:81
@ FAKE_FSM_SUBSTATE_INITIALIZATION_FINISH_FIRST_MEASUREMENT
Definition: debug_default.h:83
@ FAKE_FSM_SUBSTATE_INITIALIZATION_FIRST_MEASUREMENT_FINISHED
Definition: debug_default.h:84
@ FAKE_FSM_SUBSTATE_RUNNING_SAVE_TEMPERATURE_MEASUREMENT_DATA
Definition: debug_default.h:87
@ FAKE_FSM_SUBSTATE_INITIALIZATION_EXIT
Definition: debug_default.h:85
@ FAKE_FSM_SUBSTATE_RUNNING_SAVE_VOLTAGE_MEASUREMENT_DATA
Definition: debug_default.h:86
@ FAKE_FSM_SUBSTATE_ENTRY
Definition: debug_default.h:82
FAKE_FSM_STATES_e
Definition: debug_default.h:70
@ FAKE_FSM_STATE_DUMMY
Definition: debug_default.h:71
@ FAKE_FSM_STATE_HAS_NEVER_RUN
Definition: debug_default.h:72
@ FAKE_FSM_STATE_ERROR
Definition: debug_default.h:76
@ FAKE_FSM_STATE_RUNNING
Definition: debug_default.h:75
@ FAKE_FSM_STATE_UNINITIALIZED
Definition: debug_default.h:73
@ FAKE_FSM_STATE_INITIALIZATION
Definition: debug_default.h:74
Diagnosis driver header.
#define FAS_ASSERT(x)
Assertion macro that asserts that x is true.
Definition: fassert.h:250
#define FAS_TRAP
Define that evaluates to essential boolean false thus tripping an assert.
Definition: fassert.h:129
Definition of foxBMS standard types.
STD_RETURN_TYPE_e
Definition: fstd_types.h:82
@ STD_NOT_OK
Definition: fstd_types.h:84
@ STD_OK
Definition: fstd_types.h:83
#define NULL_PTR
Null pointer.
Definition: fstd_types.h:77
Declaration of the OS wrapper interface.
void OS_ExitTaskCritical(void)
Exit Critical interface function for use in FreeRTOS-Tasks and FreeRTOS-ISR.
Definition: os_freertos.c:138
void OS_EnterTaskCritical(void)
Enter Critical interface function for use in FreeRTOS-Tasks and FreeRTOS-ISR.
Definition: os_freertos.c:134
int16_t gpioVoltages_mV[BS_NR_OF_STRINGS][BS_NR_OF_MODULES_PER_STRING *BS_NR_OF_GPIOS_PER_MODULE]
Definition: database_cfg.h:320
DATA_BLOCK_HEADER_s header
Definition: database_cfg.h:318
DATA_BLOCK_HEADER_s header
Definition: database_cfg.h:250
uint8_t balancingState[BS_NR_OF_STRINGS][BS_NR_OF_CELL_BLOCKS_PER_STRING]
Definition: database_cfg.h:255
uint16_t nrBalancedCells[BS_NR_OF_STRINGS]
Definition: database_cfg.h:258
DATA_BLOCK_HEADER_s header
Definition: database_cfg.h:285
uint16_t value[BS_NR_OF_STRINGS][BS_NR_OF_MODULES_PER_STRING]
Definition: database_cfg.h:287
DATA_BLOCK_HEADER_s header
Definition: database_cfg.h:149
int16_t cellTemperature_ddegC[BS_NR_OF_STRINGS][BS_NR_OF_TEMP_SENSORS_PER_STRING]
Definition: database_cfg.h:151
int32_t packVoltage_mV[BS_NR_OF_STRINGS]
Definition: database_cfg.h:134
DATA_BLOCK_HEADER_s header
Definition: database_cfg.h:132
uint16_t nrValidCellVoltages[BS_NR_OF_STRINGS]
Definition: database_cfg.h:139
int16_t cellVoltage_mV[BS_NR_OF_STRINGS][BS_NR_OF_CELL_BLOCKS_PER_STRING]
Definition: database_cfg.h:135
DATA_BLOCK_ID_e uniqueId
Definition: database_cfg.h:122
DATA_BLOCK_HEADER_s header
Definition: database_cfg.h:305
uint8_t openWire[BS_NR_OF_STRINGS][BS_NR_OF_MODULES_PER_STRING *BS_NR_OF_CELL_BLOCKS_PER_MODULE]
Definition: database_cfg.h:310
uint8_t ioValueOut[BS_NR_OF_MODULES_PER_STRING]
Definition: database_cfg.h:272
uint8_t ioValueIn[BS_NR_OF_MODULES_PER_STRING]
Definition: database_cfg.h:273
uint8_t eepromValueWrite[BS_NR_OF_MODULES_PER_STRING]
Definition: database_cfg.h:274
uint8_t externalTemperatureSensor[BS_NR_OF_MODULES_PER_STRING]
Definition: database_cfg.h:277
uint8_t eepromValueRead[BS_NR_OF_MODULES_PER_STRING]
Definition: database_cfg.h:275
DATA_BLOCK_HEADER_s header
Definition: database_cfg.h:266
DATA_BLOCK_BALANCING_CONTROL_s * balancingControl
Definition: debug_default.h:95
DATA_BLOCK_SLAVE_CONTROL_s * slaveControl
Definition: debug_default.h:96
DATA_BLOCK_OPEN_WIRE_s * openWire
Definition: debug_default.h:98
DATA_BLOCK_CELL_VOLTAGE_s * cellVoltage
Definition: debug_default.h:92
DATA_BLOCK_BALANCING_FEEDBACK_s * balancingFeedback
Definition: debug_default.h:94
DATA_BLOCK_CELL_TEMPERATURE_s * cellTemperature
Definition: debug_default.h:93
DATA_BLOCK_ALL_GPIO_VOLTAGES_s * allGpioVoltages
Definition: debug_default.h:97
FAKE_FSM_SUBSTATES_e nextSubstate
FAKE_FSM_STATES_e currentState
FAKE_FSM_SUBSTATES_e previousSubstate
uint16_t timer
FAKE_FSM_STATES_e nextState
FAKE_FSM_STATES_e previousState
FAKE_DATABASE_ENTRIES_s data
uint8_t triggerEntry
FAKE_FSM_SUBSTATES_e currentSubstate
bool firstMeasurementFinished