foxBMS  1.2.1
The foxBMS Battery Management System API Documentation
debug_default.h
Go to the documentation of this file.
1 /**
2  *
3  * @copyright © 2010 - 2021, 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.h
44  * @author foxBMS Team
45  * @date 2020-09-17 (date of creation)
46  * @updated 2020-11-09 (date of last update)
47  * @ingroup DRIVERS
48  * @prefix FAKE
49  *
50  * @brief Header for the driver of the fake AFE driver
51  *
52  */
53 
54 #ifndef FOXBMS__DEBUG_DEFAULT_H_
55 #define FOXBMS__DEBUG_DEFAULT_H_
56 
57 /*========== Includes =======================================================*/
58 #include "general.h"
59 
60 #include "database_cfg.h"
61 
62 /*========== Macros and Definitions =========================================*/
63 
64 /** States of the state machine */
65 typedef enum FAKE_FSM_STATES {
66  FAKE_FSM_STATE_DUMMY, /*!< dummy state - always the first state */
67  FAKE_FSM_STATE_HAS_NEVER_RUN, /*!< never run state - always the second state */
68  FAKE_FSM_STATE_UNINITIALIZED, /*!< uninitialized state */
69  FAKE_FSM_STATE_INITIALIZATION, /*!< initializing the state machine */
70  FAKE_FSM_STATE_RUNNING, /*!< operational mode of the state machine */
71  FAKE_FSM_STATE_ERROR, /*!< state for error processing */
73 
74 /** Substates of the state machine */
75 typedef enum FAKE_FSM_SUBSTATES {
76  FAKE_FSM_SUBSTATE_DUMMY, /*!< dummy state - always the first substate */
77  FAKE_FSM_SUBSTATE_ENTRY, /*!< entry state - always the second substate */
78  FAKE_FSM_SUBSTATE_INITIALIZATION_FINISH_FIRST_MEASUREMENT, /*!< finish the first fake measurement */
79  FAKE_FSM_SUBSTATE_INITIALIZATION_FIRST_MEASUREMENT_FINISHED, /*!< cleanup substate after the first fake measurement */
80  FAKE_FSM_SUBSTATE_INITIALIZATION_EXIT, /*!< last initialization substate */
81  FAKE_FSM_SUBSTATE_RUNNING_SAVE_VOLTAGE_MEASUREMENT_DATA, /*!< state to continuously save the measurement data */
82  FAKE_FSM_SUBSTATE_RUNNING_SAVE_TEMPERATURE_MEASUREMENT_DATA, /*!< state to continuously save the measurement data */
84 
85 /** This struct contains pointer to used data buffers */
86 typedef struct FAKE_DATABASE_ENTRIES {
87  DATA_BLOCK_CELL_VOLTAGE_s *cellVoltage; /*!< cell voltage */
91  DATA_BLOCK_SLAVE_CONTROL_s *slaveControl; /*!< slave control */
92  DATA_BLOCK_ALL_GPIO_VOLTAGES_s *allGpioVoltages; /*!< voltage of the slaves' GPIOs */
93  DATA_BLOCK_OPEN_WIRE_s *openWire; /*!< open wire status */
95 
96 /** This struct describes the state of the monitoring instance */
97 typedef struct FAKE_STATE {
98  uint16_t timer; /*!< timer of the state */
99  uint8_t triggerEntry; /*!< trigger entry of the state */
100  FAKE_FSM_STATES_e nextState; /*!< next state of the FSM */
101  FAKE_FSM_STATES_e currentState; /*!< current state of the FSM */
102  FAKE_FSM_STATES_e previousState; /*!< previous state of the FSM */
103  FAKE_FSM_SUBSTATES_e nextSubstate; /*!< next substate of the FSM */
104  FAKE_FSM_SUBSTATES_e currentSubstate; /*!< current substate of the FSM */
105  FAKE_FSM_SUBSTATES_e previousSubstate; /*!< previous substate of the FSM */
106  bool firstMeasurementFinished; /*!< indicator if the fist measurement has been successful */
107  FAKE_DATABASE_ENTRIES_s data; /*!< contains pointers to the local data buffer */
109 
110 /*========== Extern Constant and Variable Declarations ======================*/
111 
112 /** state of the fake state machine */
113 extern FAKE_STATE_s fake_state;
114 
115 /*========== Extern Function Prototypes =====================================*/
116 
117 /** @brief initialize driver */
119 
120 /**
121  * @brief return whether the first measurement cycle is finished
122  * @param pFakeState current state of the fake driver
123  * @returns true if the first measurement cycle was successfully finished,
124  * false otherwise
125  */
126 extern bool FAKE_IsFirstMeasurementCycleFinished(FAKE_STATE_s *pFakeState);
127 
128 /**
129  * @brief Trigger function for the driver, called to advance the
130  * state machine
131  * @param pFakeState current state of the fake driver
132  * @returns returns always #STD_OK
133  */
135 
136 /*========== Externalized Static Functions Prototypes (Unit Test) ===========*/
137 #ifdef UNITY_UNIT_TEST
138 extern bool TEST_FAKE_CheckMultipleCalls(FAKE_STATE_s *pFakeState);
139 
140 extern void TEST_FAKE_SetFirstMeasurementCycleFinished(FAKE_STATE_s *pFakeState);
141 
142 extern void TEST_FAKE_SetState(
143  FAKE_STATE_s *pFakeState,
144  FAKE_FSM_STATES_e nextState,
145  FAKE_FSM_SUBSTATES_e nextSubstate,
146  uint16_t idleTime);
147 
148 extern STD_RETURN_TYPE_e TEST_FAKE_SaveFakeVoltageMeasurementData(FAKE_STATE_s *pFakeState);
149 
150 extern STD_RETURN_TYPE_e TEST_FAKE_SaveFakeTemperatureMeasurementData(FAKE_STATE_s *pFakeState);
151 
152 #endif
153 
154 #endif /* FOXBMS__DEBUG_DEFAULT_H_ */
Database configuration header.
struct FAKE_DATABASE_ENTRIES FAKE_DATABASE_ENTRIES_s
enum FAKE_FSM_STATES FAKE_FSM_STATES_e
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.
struct FAKE_STATE FAKE_STATE_s
FAKE_FSM_SUBSTATES
Definition: debug_default.h:75
@ FAKE_FSM_SUBSTATE_DUMMY
Definition: debug_default.h:76
@ FAKE_FSM_SUBSTATE_INITIALIZATION_FINISH_FIRST_MEASUREMENT
Definition: debug_default.h:78
@ FAKE_FSM_SUBSTATE_INITIALIZATION_FIRST_MEASUREMENT_FINISHED
Definition: debug_default.h:79
@ FAKE_FSM_SUBSTATE_RUNNING_SAVE_TEMPERATURE_MEASUREMENT_DATA
Definition: debug_default.h:82
@ FAKE_FSM_SUBSTATE_INITIALIZATION_EXIT
Definition: debug_default.h:80
@ FAKE_FSM_SUBSTATE_RUNNING_SAVE_VOLTAGE_MEASUREMENT_DATA
Definition: debug_default.h:81
@ FAKE_FSM_SUBSTATE_ENTRY
Definition: debug_default.h:77
enum FAKE_FSM_SUBSTATES FAKE_FSM_SUBSTATES_e
FAKE_FSM_STATES
Definition: debug_default.h:65
@ FAKE_FSM_STATE_DUMMY
Definition: debug_default.h:66
@ FAKE_FSM_STATE_HAS_NEVER_RUN
Definition: debug_default.h:67
@ FAKE_FSM_STATE_ERROR
Definition: debug_default.h:71
@ FAKE_FSM_STATE_RUNNING
Definition: debug_default.h:70
@ FAKE_FSM_STATE_UNINITIALIZED
Definition: debug_default.h:68
@ FAKE_FSM_STATE_INITIALIZATION
Definition: debug_default.h:69
bool FAKE_IsFirstMeasurementCycleFinished(FAKE_STATE_s *pFakeState)
return whether the first measurement cycle is finished
enum STD_RETURN_TYPE STD_RETURN_TYPE_e
General macros and definitions for the whole platform.
DATA_BLOCK_BALANCING_FEEDBACK_s * balancingFeedback
Definition: debug_default.h:89
DATA_BLOCK_OPEN_WIRE_s * openWire
Definition: debug_default.h:93
DATA_BLOCK_ALL_GPIO_VOLTAGES_s * allGpioVoltages
Definition: debug_default.h:92
DATA_BLOCK_CELL_VOLTAGE_s * cellVoltage
Definition: debug_default.h:87
DATA_BLOCK_BALANCING_CONTROL_s * balancingControl
Definition: debug_default.h:90
DATA_BLOCK_CELL_TEMPERATURE_s * cellTemperature
Definition: debug_default.h:88
DATA_BLOCK_SLAVE_CONTROL_s * slaveControl
Definition: debug_default.h:91
bool firstMeasurementFinished
uint16_t timer
Definition: debug_default.h:98
uint8_t triggerEntry
Definition: debug_default.h:99
FAKE_FSM_STATES_e nextState
FAKE_FSM_SUBSTATES_e nextSubstate
FAKE_FSM_STATES_e previousState
FAKE_DATABASE_ENTRIES_s data
FAKE_FSM_SUBSTATES_e previousSubstate
FAKE_FSM_STATES_e currentState
FAKE_FSM_SUBSTATES_e currentSubstate